]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #91673 - ChrisDenton:path-absolute, r=Mark-Simulacrum
bors [Sun, 13 Feb 2022 12:03:52 +0000 (12:03 +0000)]
Auto merge of #91673 - ChrisDenton:path-absolute, r=Mark-Simulacrum

`std::path::absolute`

Implements #59117 by adding a `std::path::absolute` function that creates an absolute path without reading the filesystem. This is intended to be a drop-in replacement for [`std::fs::canonicalize`](https://doc.rust-lang.org/std/fs/fn.canonicalize.html) in cases where it isn't necessary to resolve symlinks. It can be used on paths that don't exist or where resolving symlinks is unwanted. It can also be used to avoid circumstances where `canonicalize` might otherwise fail.

On Windows this is a wrapper around [`GetFullPathNameW`](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfullpathnamew). On Unix it partially implements the POSIX [pathname resolution](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13) specification, stopping just short of actually resolving symlinks.

2 years agoAuto merge of #93763 - jsha:re-space-empty-impls, r=GuillaumeGomez
bors [Sun, 13 Feb 2022 09:41:41 +0000 (09:41 +0000)]
Auto merge of #93763 - jsha:re-space-empty-impls, r=GuillaumeGomez

rustdoc: fix spacing of non-toggled impl blocks

We [recently removed the "up here" arrows on item-infos](https://github.com/rust-lang/rust/pull/92651), and adjusted
vertical spacing so that even without the arrow, it would be visually
clear which item the item-info belonged to. The new CSS styles for
vertical spacing only applied to toggles, though. This missed
non-toggled impl blocks - for instance, those without any methods, like
https://doc.rust-lang.org/nightly/std/marker/trait.Send.html#implementors.
The result was lists of implementors that were spaced too closely. This
PR fixes the spacing by making it apply to non-toggled impl blocks as
well.

This also fixes an issue where item-infos were displayed too far below
their items. That was a result of display: table on .item-info .stab.
Changed that to display: inline-block.

Demo: https://rustdoc.crud.net/jsha/re-space-empty-impls/std/marker/trait.Send.html

Before:

<img width=300 src="https://user-images.githubusercontent.com/220205/152954394-ec0b80e7-2573-4f06-9d7a-7b10b8ceac60.png">

After:

<img width=300 src="https://user-images.githubusercontent.com/220205/152954228-abac1d30-a76d-4ab1-89ec-ef7549fe8c9c.png">

r? `@GuillaumeGomez`

2 years agoAuto merge of #93956 - matthiaskrgr:rollup-zfk35hb, r=matthiaskrgr
bors [Sun, 13 Feb 2022 07:04:56 +0000 (07:04 +0000)]
Auto merge of #93956 - matthiaskrgr:rollup-zfk35hb, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #89926 (make `Instant::{duration_since, elapsed, sub}` saturating and remove workarounds)
 - #90532 (More informative error message for E0015)
 - #93810 (Improve chalk integration)
 - #93851 (More practical examples for `Option::and_then` & `Result::and_then`)
 - #93885 (bootstrap.py: Suggest disabling download-ci-llvm option if url fails to download)
 - #93886 (Stabilise inherent_ascii_escape (FCP in #77174))
 - #93930 (add link to format_args! when mention it in docs)
 - #93936 (Couple of driver cleanups)
 - #93944 (Don't relabel to a team if there is already a team label)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #93944 - jackh726:team-exclude, r=Mark-Simulacrum
Matthias Krüger [Sun, 13 Feb 2022 05:44:19 +0000 (06:44 +0100)]
Rollup merge of #93944 - jackh726:team-exclude, r=Mark-Simulacrum

Don't relabel to a team if there is already a team label

Should prevent cases like #93628, where teams have been manually assigned, but changes are pushed. We give up adding new labels on *new* changes; but I feel like that is less frequent.

r? `@Mark-Simulacrum`

2 years agoRollup merge of #93936 - bjorn3:simplifications2, r=cjgillot
Matthias Krüger [Sun, 13 Feb 2022 05:44:18 +0000 (06:44 +0100)]
Rollup merge of #93936 - bjorn3:simplifications2, r=cjgillot

Couple of driver cleanups

* Remove the `RustcDefaultCalls` struct, which hasn't been necessary since the introduction of `rustc_interface`.
* Move the `setup_callbacks` call around for a tiny code deduplication.
* Remove the `SPAN_DEBUG` global as it isn't actually necessary.

2 years agoRollup merge of #93930 - name1e5s:chore/docs, r=Mark-Simulacrum
Matthias Krüger [Sun, 13 Feb 2022 05:44:18 +0000 (06:44 +0100)]
Rollup merge of #93930 - name1e5s:chore/docs, r=Mark-Simulacrum

add link to format_args! when mention it in docs

close #93904

2 years agoRollup merge of #93886 - clarfonthey:stable_ascii_escape, r=Mark-Simulacrum
Matthias Krüger [Sun, 13 Feb 2022 05:44:17 +0000 (06:44 +0100)]
Rollup merge of #93886 - clarfonthey:stable_ascii_escape, r=Mark-Simulacrum

Stabilise inherent_ascii_escape (FCP in #77174)

Implements #77174, which completed its FCP.

This does *not* deprecate any existing methods or structs, as that is tracked in #93887. That stated, people should prefer using `u8::escape_ascii` to `std::ascii::escape_default`.

2 years agoRollup merge of #93885 - Badel2:error-download-ci-llvm, r=Mark-Simulacrum
Matthias Krüger [Sun, 13 Feb 2022 05:44:16 +0000 (06:44 +0100)]
Rollup merge of #93885 - Badel2:error-download-ci-llvm, r=Mark-Simulacrum

bootstrap.py: Suggest disabling download-ci-llvm option if url fails to download

I got an error when trying to build the compiler using an old commit, and it turns out it was because the option `download-ci-llvm` was implicitly set to true. So this pull request tries to add a help message for other people that may run into the same problem.

To reproduce my error:

```
git checkout 8d7707f3c4f72e6eb334d897354beca692b265d1
./x.py test
[...]
spurious failure, trying again
downloading https://ci-artifacts.rust-lang.org/rustc-builds/db002a06ae9154a35d410550bc5132df883d7baa/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz
curl: (22) The requested URL returned error: 404

failed to run: curl -# -y 30 -Y 10 --connect-timeout 30 --retry 3 -Sf -o /tmp/tmp8g13rb4n https://ci-artifacts.rust-lang.org/rustc-builds/db002a06ae9154a35d410550bc5132df883d7baa/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz
Build completed unsuccessfully in 0:00:46
```

This is my `config.toml`:

```
# Includes one of the default files in src/bootstrap/defaults
profile = "compiler"
changelog-seen = 2

[rust]
debug = true
```

To reproduce an error with this branch:

Change line 618 of bootstrap.py to
```
        url = "rustc-builds-error404/{}".format(llvm_sha)
```

Delete llvm and cached tarball, and set `llvm.download-ci-llvm=true` in config.toml.

```
./x.py test
[...]
spurious failure, trying again
downloading https://ci-artifacts.rust-lang.org/rustc-builds-error404/719b04ca99be0c78e09a8ec5e2eda082a5d8ccae/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz
curl: (22) The requested URL returned error: 404

failed to run: curl -# -y 30 -Y 10 --connect-timeout 30 --retry 3 -Sf -o /tmp/tmpesl1ydvo https://ci-artifacts.rust-lang.org/rustc-builds-error404/719b04ca99be0c78e09a8ec5e2eda082a5d8ccae/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz
error: failed to download llvm from ci
help: old builds get deleted after a certain time
help: if trying to compile an old commit of rustc, disable `download-ci-llvm` in config.toml:

[llvm]
download-ci-llvm = false

Build completed unsuccessfully in 0:00:01
```

Regarding the implementation, I expected to be able to use a try/catch block in `_download_ci_llvm`, but the `run` function calls `sys.exit` instead of raising an exception so that's not possible. Also, suggestions for better wording of the help message are welcome.

2 years agoRollup merge of #93851 - cyqsimon:option-examples, r=scottmcm
Matthias Krüger [Sun, 13 Feb 2022 05:44:15 +0000 (06:44 +0100)]
Rollup merge of #93851 - cyqsimon:option-examples, r=scottmcm

More practical examples for `Option::and_then` & `Result::and_then`

To be blatantly honest, I think the current example given for `Option::and_then` is objectively terrible. (No offence to whoever wrote them initially.)

```rust
fn sq(x: u32) -> Option<u32> { Some(x * x) }
fn nope(_: u32) -> Option<u32> { None }

assert_eq!(Some(2).and_then(sq).and_then(sq), Some(16));
assert_eq!(Some(2).and_then(sq).and_then(nope), None);
assert_eq!(Some(2).and_then(nope).and_then(sq), None);
assert_eq!(None.and_then(sq).and_then(sq), None);
```

Current example:
 - does not demonstrate that `and_then` converts `Option<T>` to `Option<U>`
 - is far removed from any realistic code
 - generally just causes more confusion than it helps

So I replaced them with two blocks:
 - the first one shows basic usage (including the type conversion)
 - the second one shows an example of typical usage

Same thing with `Result::and_then`.

Hopefully this helps with clarity.

2 years agoRollup merge of #93810 - matthewjasper:chalk-and-canonical-universes, r=jackh726
Matthias Krüger [Sun, 13 Feb 2022 05:44:14 +0000 (06:44 +0100)]
Rollup merge of #93810 - matthewjasper:chalk-and-canonical-universes, r=jackh726

Improve chalk integration

- Support subtype bounds in chalk lowering
- Handle universes in canonicalization
- Handle type parameters in chalk responses
- Use `chalk_ir::LifetimeData::Empty` for `ty::ReEmpty`
- Remove `ignore-compare-mode-chalk` for tests that no longer hang (they may still fail or ICE)

This is enough to get a hello world program to compile with `-Zchalk` now. Some of the remaining issues that are needed to get Chalk integration working on larger programs are:

- rust-lang/chalk#234
- rust-lang/chalk#548
- rust-lang/chalk#734
- Generators are handled differently in chalk and rustc

r? `@jackh726`

2 years agoRollup merge of #90532 - fee1-dead:improve-const-fn-err-msg, r=oli-obk
Matthias Krüger [Sun, 13 Feb 2022 05:44:13 +0000 (06:44 +0100)]
Rollup merge of #90532 - fee1-dead:improve-const-fn-err-msg, r=oli-obk

More informative error message for E0015

Helps with #92380

2 years agoRollup merge of #89926 - the8472:saturate-instant, r=Mark-Simulacrum
Matthias Krüger [Sun, 13 Feb 2022 05:44:12 +0000 (06:44 +0100)]
Rollup merge of #89926 - the8472:saturate-instant, r=Mark-Simulacrum

make `Instant::{duration_since, elapsed, sub}` saturating and remove workarounds

This removes all mutex/atomic-based workarounds for non-monotonic clocks and makes the previously panicking methods saturating instead. Additionally `saturating_duration_since` becomes deprecated since `duration_since` now fills that role.

Effectively this moves the fixup from `Instant` construction to the comparisons.

This has some observable effects, especially on platforms without monotonic clocks:

* Incorrectly ordered Instant comparisons no longer panic in release mode. This could hide some programming errors, but since debug mode still panics tests can still catch them.
* `checked_duration_since` will now return `None` in more cases. Previously it only happened when one compared instants obtained in the wrong order or manually created ones. Now it also does on backslides.
* non-monotonic intervals will not be transitive, i.e. `b.duration_since(a) + c.duration_since(b) != c.duration_since(a)`

The upsides are reduced complexity and lower overhead of `Instant::now`.

## Motivation

Currently we must choose between two poisons. One is high worst-case latency and jitter of `Instant::now()` due to explicit synchronization; see #83093 for benchmarks, the worst-case overhead is > 100x. The other is sporadic panics on specific, rare combinations of CPU/hypervisor/operating system due to platform bugs.

Use-cases where low-overhead, fine-grained timestamps are needed - such as syscall tracing, performance profiles or sensor data acquisition (drone flight controllers were mentioned in a libs meeting) in multi-threaded programs - are negatively impacted by the synchronization.

The panics are user-visible (program crashes), hard to reproduce and can be triggered by any dependency that might be using Instants for any reason.

A solution that is fast _and_ doesn't panic is desirable.

----

closes #84448
closes #86470

2 years agoAuto merge of #93713 - klensy:deps-up, r=Mark-Simulacrum
bors [Sun, 13 Feb 2022 04:48:05 +0000 (04:48 +0000)]
Auto merge of #93713 - klensy:deps-up, r=Mark-Simulacrum

Update deps

cargo_metadata 0.12 -> 0.14, to dedupe and remove some `semver`, `semver-parser` versions
pretty_assertions 0.6 -> 0.7, to drop some `ansi_term` version
futures 0.1.29 -> 0.1.31, backported some [fixes](https://github.com/rust-lang/futures-rs/compare/0.1.29...0.1.31) to old versions
futures-* 0.3.12 -> 0.3.19, to remove `proc-macro-hack`, `proc-macro-nested` and fix some [issues](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md#0319---2021-12-18). There exist 0.3.21, but it's quite new (06.02.22), so not updated to.
itertools 0.9 -> 0.10 for rustdoc, will be droppped when rustfmt will bump `itertools` version
linked-hash-map 0.5.3 -> 0.5.4, fix [UB](https://github.com/contain-rs/linked-hash-map/pull/106)
markup5ever 0.10.0 -> 0.10.1, internally drops `serde`, reducing [build time](https://github.com/servo/html5ever/commit/3afd8d63853627e530b3063b0185eea3732cc29f#diff-4c20e8293515259c0aa26932413a55a334aa5f2b37de5a5adc92a2186f632606) for some usecases
mio 0.7.13 -> 0.7.14 fix [unsoundness](https://github.com/tokio-rs/mio/compare/v0.7.13...v0.7.14)
num_cpus 1.13.0 -> 1.13.1 fix parsing mountinfo and other [fixes](https://github.com/seanmonstar/num_cpus/compare/v1.13.0...v1.13.1)
openssl-src 111.16.0+1.1.1l -> 111.17.0+1.1.1m fix CVE-2021-4160

2 years agoAuto merge of #93696 - Amanieu:compiler-builtins-0.1.68, r=Mark-Simulacrum
bors [Sun, 13 Feb 2022 02:40:56 +0000 (02:40 +0000)]
Auto merge of #93696 - Amanieu:compiler-builtins-0.1.68, r=Mark-Simulacrum

Bump compiler-builtins to 0.1.69

This includes https://github.com/rust-lang/compiler-builtins/pull/452 which should fix some issues with duplicate symbol defintions of some intrinsics.

2 years agoAuto merge of #93670 - erikdesjardins:noundef, r=nikic
bors [Sun, 13 Feb 2022 00:14:52 +0000 (00:14 +0000)]
Auto merge of #93670 - erikdesjardins:noundef, r=nikic

Apply noundef attribute to &T, &mut T, Box<T>, bool

This doesn't handle `char` because it's a bit awkward to distinguish it from `u32` at this point in codegen.

Note that this _does not_ change whether or not it is UB for `&`, `&mut`, or `Box` to point to undef. It only applies to the pointer itself, not the pointed-to memory.

Fixes (partially) #74378.

r? `@nikic` cc `@RalfJung`

2 years agoCapitalize "Rust"
Josh Triplett [Wed, 9 Feb 2022 20:17:38 +0000 (12:17 -0800)]
Capitalize "Rust"

Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
2 years agoAdd panic docs describing old, current and possible future behavior
The 8472 [Fri, 7 Jan 2022 09:51:39 +0000 (10:51 +0100)]
Add panic docs describing old, current and possible future behavior

2 years agoAdd caveat about the monotonicity guarantee by linking to the later section
The 8472 [Fri, 7 Jan 2022 09:50:15 +0000 (10:50 +0100)]
Add caveat about the monotonicity guarantee by linking to the later section

2 years agomake Instant::{duration_since, elapsed, sub} saturating and remove workarounds
The8472 [Fri, 15 Oct 2021 21:55:23 +0000 (23:55 +0200)]
make Instant::{duration_since, elapsed, sub} saturating and remove workarounds

This removes all mutex/atomics based workarounds for non-monotonic clocks and makes the previously panicking methods saturating instead.

Effectively this moves the monotonization from `Instant` construction to the comparisons.

This has some observable effects, especially on platforms without monotonic clocks:

* Incorrectly ordered Instant comparisons no longer panic. This may hide some programming errors until someone actually looks at the resulting `Duration`
* `checked_duration_since` will now return `None` in more cases. Previously it only happened when one compared instants obtained in the wrong order or
  manually created ones. Now it also does on backslides.

The upside is reduced complexity and lower overhead of `Instant::now`.

2 years agoAuto merge of #91403 - cjgillot:inherit-async, r=oli-obk
bors [Sat, 12 Feb 2022 21:42:10 +0000 (21:42 +0000)]
Auto merge of #91403 - cjgillot:inherit-async, r=oli-obk

Inherit lifetimes for async fn instead of duplicating them.

The current desugaring of `async fn foo<'a>(&usize) -> &u8` is equivalent to
```rust
fn foo<'a, '0>(&'0 usize) -> foo<'static, 'static>::Opaque<'a, '0, '_>;
type foo<'_a, '_0>::Opaque<'a, '0, '1> = impl Future<Output = &'1 u8>;
```
following the RPIT model.

Duplicating all the inherited lifetime parameters and setting the inherited version to `'static` makes lowering more complex and causes issues like #61949. This PR removes the duplication of inherited lifetimes to directly use
```rust
fn foo<'a, '0>(&'0 usize) -> foo<'a, '0>::Opaque<'_>;
type foo<'a, '0>::Opaque<'1> = impl Future<Output = &'1 u8>;
```
following the TAIT model.

Fixes https://github.com/rust-lang/rust/issues/61949

2 years agoStabilise inherent_ascii_escape (FCP in #77174)
ltdk [Fri, 11 Feb 2022 02:09:05 +0000 (21:09 -0500)]
Stabilise inherent_ascii_escape (FCP in #77174)

2 years agoFix signature of u8::escape_ascii
ltdk [Sat, 12 Feb 2022 18:15:10 +0000 (13:15 -0500)]
Fix signature of u8::escape_ascii

2 years agomake fastcall-inreg and riscv64-lp64-lp64f-lp64d-abi tests able to run on any host...
Erik Desjardins [Sat, 12 Feb 2022 17:28:19 +0000 (12:28 -0500)]
make fastcall-inreg and riscv64-lp64-lp64f-lp64d-abi tests able to run on any host platform (with the right llvm components)

2 years agoDon't relabel to a team if there is already a team label
Jack Huey [Sat, 12 Feb 2022 16:47:00 +0000 (11:47 -0500)]
Don't relabel to a team if there is already a team label

2 years agoAuto merge of #93939 - RalfJung:miri, r=RalfJung
bors [Sat, 12 Feb 2022 16:41:24 +0000 (16:41 +0000)]
Auto merge of #93939 - RalfJung:miri, r=RalfJung

update miri

to fix the libcore test suite
r? `@ghost`

2 years agoAuto merge of #93697 - the8472:fix-windows-path-hash, r=Mark-Simulacrum
bors [Sat, 12 Feb 2022 14:01:13 +0000 (14:01 +0000)]
Auto merge of #93697 - the8472:fix-windows-path-hash, r=Mark-Simulacrum

Fix hashing for windows paths containing a CurDir component

* the logic only checked for / but not for \
* verbatim paths shouldn't skip items at all since they don't get normalized
* the extra branches get optimized out on unix since is_sep_byte is a trivial comparison and is_verbatim is always-false
* tests lacked windows coverage for these cases

That lead to equal paths not having equal hashes and to unnecessary collisions.

2 years agoAddress review comment
Matthew Jasper [Fri, 11 Feb 2022 18:20:47 +0000 (18:20 +0000)]
Address review comment

canonicalize_chalk_query -> canonicalize_query_preserving_universes

2 years agoUpdate chalk tests
Matthew Jasper [Wed, 9 Feb 2022 10:19:31 +0000 (10:19 +0000)]
Update chalk tests

2 years agoSuggest disabling download-ci-llvm option if url fails to download
Badel2 [Fri, 11 Feb 2022 01:10:02 +0000 (02:10 +0100)]
Suggest disabling download-ci-llvm option if url fails to download

2 years agoignore test on wasm32
The 8472 [Sat, 12 Feb 2022 11:54:25 +0000 (12:54 +0100)]
ignore test on wasm32

A fix applied to std::Path::hash triggers a miscompilation/assert in LLVM in this test on wasm32.
The miscompilation appears to pre-existing. Reverting some previous changes done std::Path also trigger it
and slight modifications such as changing the test path from "a" to "ccccccccccc" also make it pass, indicating
it's very flaky.
Since the fix is for a higher-tier platform than wasm it takes precedence.

2 years agoAuto merge of #93933 - matthiaskrgr:rollup-1hjae6g, r=matthiaskrgr
bors [Sat, 12 Feb 2022 11:48:53 +0000 (11:48 +0000)]
Auto merge of #93933 - matthiaskrgr:rollup-1hjae6g, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #91908 (Add 2 tests)
 - #93595 (fix ICE when parsing lifetime as function argument)
 - #93757 (Add some known GAT bugs as tests)
 - #93759 (Pretty print ItemKind::Use in rustfmt style)
 - #93897 (linkchecker: fix panic on directory symlinks)
 - #93898 (tidy: Extend error code check)
 - #93928 (Add missing release notes for #85200)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoupdate miri
Ralf Jung [Sat, 12 Feb 2022 11:46:02 +0000 (12:46 +0100)]
update miri

2 years agoRemove SPAN_DEBUG global
bjorn3 [Fri, 14 Jan 2022 18:34:01 +0000 (19:34 +0100)]
Remove SPAN_DEBUG global

The only difference between the default and rustc_interface set version
is that the default accesses the source map from SESSION_GLOBALS while
the rustc_interface version accesses the source map from the global
TyCtxt. SESSION_GLOBALS is always set while running the compiler while
the global TyCtxt is not always set. If the global TyCtxt is set, it's
source map is identical to the one in SESSION_GLOBALS

2 years agoMove setup_callbacks call to create_compiler_and_run
bjorn3 [Fri, 25 Jun 2021 11:03:39 +0000 (13:03 +0200)]
Move setup_callbacks call to create_compiler_and_run

This ensures that it is called even when run_in_thread_pool_with_globals
is avoided and reduces code duplication between the parallel and
non-parallel version of run_in_thread_pool_with_globals

2 years agoRemove the RustcDefaultCalls struct
bjorn3 [Fri, 25 Jun 2021 10:49:29 +0000 (12:49 +0200)]
Remove the RustcDefaultCalls struct

It is a leftover from before the introduction of rustc_interface

2 years agoRebless
Deadbeef [Thu, 10 Feb 2022 09:22:54 +0000 (20:22 +1100)]
Rebless

2 years agoRollup merge of #93928 - nsunderland1:master, r=Mark-Simulacrum
Matthias Krüger [Sat, 12 Feb 2022 08:26:26 +0000 (09:26 +0100)]
Rollup merge of #93928 - nsunderland1:master, r=Mark-Simulacrum

Add missing release notes for #85200

Fixes #93894

2 years agoRollup merge of #93898 - GuillaumeGomez:error-code-check, r=Mark-Simulacrum
Matthias Krüger [Sat, 12 Feb 2022 08:26:25 +0000 (09:26 +0100)]
Rollup merge of #93898 - GuillaumeGomez:error-code-check, r=Mark-Simulacrum

tidy: Extend error code check

We discovered in https://github.com/rust-lang/rust/pull/93845 that the error code tidy check didn't check everything: if you remove an error code from the listing even if it has an explanation, then it should error.

It also allowed me to put back `E0192` in that listing as well.

r? ```@Mark-Simulacrum```

2 years agoRollup merge of #93897 - schopin-pro:linkchecker-symlink, r=Mark-Simulacrum
Matthias Krüger [Sat, 12 Feb 2022 08:26:24 +0000 (09:26 +0100)]
Rollup merge of #93897 - schopin-pro:linkchecker-symlink, r=Mark-Simulacrum

linkchecker: fix panic on directory symlinks

In Debian and Ubuntu, there are some patches that change the rustc/fonts
directory to a symlink to the system fonts. This triggers a latent bug
in linkchecker, as the DirEntry filetype isn't a dir but later on the
file itself, when opened, is one, triggering an unreachable!() clause.

This patch fixes the situation by using std::fs::metadata, which goes
through symlinks.

I'd have added a test case but `tidy` doesn't seem to like symlinks, and
moreover I'm not sure how Git deals with symlinks on Windows.

Signed-off-by: Simon Chopin <simon.chopin@canonical.com>
2 years agoRollup merge of #93759 - dtolnay:usetree, r=nagisa
Matthias Krüger [Sat, 12 Feb 2022 08:26:23 +0000 (09:26 +0100)]
Rollup merge of #93759 - dtolnay:usetree, r=nagisa

Pretty print ItemKind::Use in rustfmt style

This PR backports the formatting for `use` items from https://github.com/dtolnay/prettyplease into rustc_ast_pretty.

Before:

```rust
use core::{cmp::{Eq, Ord, PartialEq, PartialOrd},
    convert::{AsMut, AsRef, From, Into},
    iter::{DoubleEndedIterator, ExactSizeIterator, Extend, FromIterator,
    IntoIterator, Iterator},
    marker::{Copy as Copy, Send as Send, Sized as Sized, Sync as Sync, Unpin
    as U}, ops::{*, Drop, Fn, FnMut, FnOnce}};
```

After:

```rust
use core::{
    cmp::{Eq, Ord, PartialEq, PartialOrd},
    convert::{AsMut, AsRef, From, Into},
    iter::{
        DoubleEndedIterator, ExactSizeIterator, Extend, FromIterator,
        IntoIterator, Iterator,
    },
    marker::{
        Copy as Copy, Send as Send, Sized as Sized, Sync as Sync, Unpin as U,
    },
    ops::{*, Drop, Fn, FnMut, FnOnce},
};
```

2 years agoRollup merge of #93757 - jackh726:gat-bug-tests, r=nikomatsakis
Matthias Krüger [Sat, 12 Feb 2022 08:26:22 +0000 (09:26 +0100)]
Rollup merge of #93757 - jackh726:gat-bug-tests, r=nikomatsakis

Add some known GAT bugs as tests

In the spirit of rust-lang/compiler-team#476

These tests are marked as "check-fail", but also commented with "this should pass". This many of the open GAT issues that are accepted bugs.

r? ``@nikomatsakis``

2 years agoRollup merge of #93595 - compiler-errors:ice-on-lifetime-arg, r=jackh726
Matthias Krüger [Sat, 12 Feb 2022 08:26:21 +0000 (09:26 +0100)]
Rollup merge of #93595 - compiler-errors:ice-on-lifetime-arg, r=jackh726

fix ICE when parsing lifetime as function argument

I don't really like this, but we basically need to emit an error instead of just delaying an bug, because there are too many places in the AST that aren't covered by my previous PRs...

cc: https://github.com/rust-lang/rust/issues/93282#issuecomment-1028052945

2 years agoRollup merge of #91908 - matthiaskrgr:ices, r=jackh726
Matthias Krüger [Sat, 12 Feb 2022 08:26:20 +0000 (09:26 +0100)]
Rollup merge of #91908 - matthiaskrgr:ices, r=jackh726

Add 2 tests

fixes #91139
fixes #91069

2 years agoReport the selection error when possible
Deadbeef [Fri, 28 Jan 2022 10:57:29 +0000 (21:57 +1100)]
Report the selection error when possible

2 years agoAdapt new change
Deadbeef [Fri, 28 Jan 2022 08:59:06 +0000 (19:59 +1100)]
Adapt new change

2 years agoHandle Fn family trait call errror
Deadbeef [Wed, 29 Dec 2021 09:05:54 +0000 (17:05 +0800)]
Handle Fn family trait call errror

2 years agoRebased and improved errors
Deadbeef [Wed, 29 Dec 2021 08:29:14 +0000 (16:29 +0800)]
Rebased and improved errors

2 years agobless you
Deadbeef [Thu, 9 Dec 2021 17:10:05 +0000 (01:10 +0800)]
bless you

2 years agoImprove error messages even more
Deadbeef [Thu, 9 Dec 2021 14:42:17 +0000 (22:42 +0800)]
Improve error messages even more

2 years agoMore informative error message for E0015
Deadbeef [Wed, 3 Nov 2021 09:34:30 +0000 (17:34 +0800)]
More informative error message for E0015

2 years agoFix line number
Jack Huey [Sat, 12 Feb 2022 05:57:16 +0000 (00:57 -0500)]
Fix line number

Co-authored-by: David Tolnay <dtolnay@gmail.com>
2 years agoAuto merge of #93691 - compiler-errors:mir-tainted-by-errors, r=oli-obk
bors [Sat, 12 Feb 2022 05:19:33 +0000 (05:19 +0000)]
Auto merge of #93691 - compiler-errors:mir-tainted-by-errors, r=oli-obk

Implement `tainted_by_errors` in MIR borrowck, use it to skip CTFE

Putting this up for initial review. The issue that I found is when we're evaluating a const, we're doing borrowck, but doing nothing with the fact that borrowck fails.

This implements a `tainted_by_errors` field for MIR borrowck like we have in infcx, so we can use that information to return an `Err` during const eval if our const fails to borrowck.

This PR needs some cleaning up. I should probably just use `Result` in more places, instead of `.expect`ing in the places I am, but I just wanted it to compile so I could see if it worked!

Fixes #93646

r? `@oli-obk`
feel free to reassign

2 years agofix non-x64 tests
Erik Desjardins [Sat, 12 Feb 2022 05:13:10 +0000 (00:13 -0500)]
fix non-x64 tests

2 years agoAdd note on Windows path behaviour
cyqsimon [Sat, 12 Feb 2022 04:52:42 +0000 (12:52 +0800)]
Add note on Windows path behaviour

2 years agoadd link to format_args! when being mentioned in doc
yuhaixin.hx [Sat, 12 Feb 2022 04:35:30 +0000 (12:35 +0800)]
add link to format_args! when being mentioned in doc

2 years ago`Option::and_then` basic example: show failure
cyqsimon [Sat, 12 Feb 2022 04:23:38 +0000 (12:23 +0800)]
`Option::and_then` basic example: show failure

2 years ago`Result::and_then`: show type conversion
cyqsimon [Sat, 12 Feb 2022 04:19:03 +0000 (12:19 +0800)]
`Result::and_then`: show type conversion

2 years ago`Result::and_then`: improve basic example
cyqsimon [Sat, 12 Feb 2022 04:12:11 +0000 (12:12 +0800)]
`Result::and_then`: improve basic example

2 years agoAdd missing release notes for #85200
nsunderland1 [Sat, 12 Feb 2022 02:06:10 +0000 (18:06 -0800)]
Add missing release notes for #85200

2 years agoAuto merge of #93671 - Kobzol:stable-hash-const, r=the8472
bors [Sat, 12 Feb 2022 02:05:11 +0000 (02:05 +0000)]
Auto merge of #93671 - Kobzol:stable-hash-const, r=the8472

Use const generics in SipHasher128's short_write

This was proposed by `@michaelwoerister` [here](https://github.com/rust-lang/rust/pull/93615#discussion_r799485554).
A few comments:
1) I tried to pass `&[u8; LEN]` instead of `[u8; LEN]`. Locally, it resulted in small icount regressions (about 0.5 %). When passing by value, there were no regressions (and no improvements).
2) I wonder if we should use `to_ne_bytes()` in `SipHasher128` to keep it generic and only use `to_le_bytes()` in `StableHasher`. However, currently `SipHasher128` is only used in `StableHasher` and the `short_write` method was private, so I couldn't use it directly from `StableHasher`. Using `to_le()` in the `StableHasher` was breaking this abstraction boundary before slightly.

```rust
debug_assert!(LEN <= 8);
```
This could be done at compile time, but actually I think that now we can remove this assert altogether.

r? `@the8472`

2 years agoUpdate expr.rs
Michael Goulet [Sat, 12 Feb 2022 01:48:06 +0000 (17:48 -0800)]
Update expr.rs

Revert spurious changes included in PR

2 years agoBless nll tests.
Camille GILLOT [Wed, 29 Dec 2021 08:19:57 +0000 (09:19 +0100)]
Bless nll tests.

2 years agoUpdate error code documentation.
Camille GILLOT [Mon, 27 Dec 2021 17:14:27 +0000 (18:14 +0100)]
Update error code documentation.

2 years agoBless clippy test.
Camille GILLOT [Fri, 28 Jan 2022 17:14:18 +0000 (18:14 +0100)]
Bless clippy test.

2 years agoFilter out anonymous generics in rustdoc.
Camille GILLOT [Sun, 5 Dec 2021 20:33:41 +0000 (21:33 +0100)]
Filter out anonymous generics in rustdoc.

2 years agoInherit lifetimes for async fn instead of duplicating them.
Camille GILLOT [Tue, 30 Nov 2021 20:55:52 +0000 (21:55 +0100)]
Inherit lifetimes for async fn instead of duplicating them.

2 years agoAdd missing E0192 in the error code listing
Guillaume Gomez [Fri, 11 Feb 2022 11:06:55 +0000 (12:06 +0100)]
Add missing E0192 in the error code listing

2 years agoAuto merge of #93921 - matthiaskrgr:rollup-wn3jlxj, r=matthiaskrgr
bors [Fri, 11 Feb 2022 23:01:50 +0000 (23:01 +0000)]
Auto merge of #93921 - matthiaskrgr:rollup-wn3jlxj, r=matthiaskrgr

Rollup of 10 pull requests

Successful merges:

 - #90955 (Rename `FilenameTooLong` to `InvalidFilename` and also use it for Windows' `ERROR_INVALID_NAME`)
 - #91607 (Make `span_extend_to_prev_str()` more robust)
 - #92895 (Remove some unused functionality)
 - #93635 (Add missing platform-specific information on current_dir and set_current_dir)
 - #93660 (rustdoc-json: Add some tests for typealias item)
 - #93782 (Split `pauth` target feature)
 - #93868 (Fix incorrect register conflict detection in asm!)
 - #93888 (Implement `AsFd` for `&T` and `&mut T`.)
 - #93909 (Fix typo: explicitely -> explicitly)
 - #93910 (fix mention of moved function in `rustc_hir` docs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRenumber universes when canonicalizing for Chalk
Matthew Jasper [Wed, 9 Feb 2022 10:18:32 +0000 (10:18 +0000)]
Renumber universes when canonicalizing for Chalk

This is required to avoid creating large numbers of universes from each
Chalk query, while still having enough universe information for lifetime
errors.

2 years agoReverse parameter to placeholder substitution in chalk results
Matthew Jasper [Wed, 9 Feb 2022 10:03:47 +0000 (10:03 +0000)]
Reverse parameter to placeholder substitution in chalk results

2 years agoFix more chalk lowering issues
Matthew Jasper [Wed, 9 Feb 2022 09:50:08 +0000 (09:50 +0000)]
Fix more chalk lowering issues

- Implement lowering for subtype goals
- Use correct lang item for Generator trait
- Use `lower_into` for lowering `ty::Variance`

2 years agoStop using a placeholder for empty regions in Chalk
Matthew Jasper [Mon, 17 Jan 2022 22:06:02 +0000 (22:06 +0000)]
Stop using a placeholder for empty regions in Chalk

2 years agoAdd 2 tests
Matthias Krüger [Tue, 14 Dec 2021 12:14:25 +0000 (13:14 +0100)]
Add 2 tests

fixes #91139
fixes #91069

2 years agoRollup merge of #93910 - rosehuds:master, r=cjgillot
Matthias Krüger [Fri, 11 Feb 2022 20:48:52 +0000 (21:48 +0100)]
Rollup merge of #93910 - rosehuds:master, r=cjgillot

fix mention of moved function in `rustc_hir` docs

The function was moved from `Crate` to `Map` in db9fea508a6d but these docs weren't updated

2 years agoRollup merge of #93909 - saschanaz:patch-2, r=petrochenkov
Matthias Krüger [Fri, 11 Feb 2022 20:48:51 +0000 (21:48 +0100)]
Rollup merge of #93909 - saschanaz:patch-2, r=petrochenkov

Fix typo: explicitely -> explicitly

2 years agoRollup merge of #93888 - sunfishcode:sunfishcode/impl-asfd-for-ref, r=joshtriplett
Matthias Krüger [Fri, 11 Feb 2022 20:48:50 +0000 (21:48 +0100)]
Rollup merge of #93888 - sunfishcode:sunfishcode/impl-asfd-for-ref, r=joshtriplett

Implement `AsFd` for `&T` and `&mut T`.

Add implementations of `AsFd` for `&T` and `&mut T`, so that users can
write code like this:

```rust
pub fn fchown<F: AsFd>(fd: F, uid: Option<u32>, gid: Option<u32>) -> io::Result<()> {
```

with `fd: F` rather than `fd: &F`.

And similar for `AsHandle` and `AsSocket` on Windows.

Also, adjust the `fchown` example to pass the file by reference. The
code can work either way now, but passing by reference is more likely
to be what users will want to do.

This is an alternative to #93869, and is a simpler way to achieve the
same goals: users don't need to pass borrowed-`BorrowedFd` arguments,
and it prevents a pitfall in the case where users write `fd: F` instead
of `fd: &F`.

r? ```@joshtriplett```

2 years agoRollup merge of #93868 - Amanieu:asm_reg_conflict, r=cjgillot
Matthias Krüger [Fri, 11 Feb 2022 20:48:49 +0000 (21:48 +0100)]
Rollup merge of #93868 - Amanieu:asm_reg_conflict, r=cjgillot

Fix incorrect register conflict detection in asm!

This would previously incorrectly reject two subregisters that were
distinct but part of the same larger register, for example `al` and
`ah`.

2 years agoRollup merge of #93782 - adamgemmell:dev/adagem01/split-pauth, r=Amanieu
Matthias Krüger [Fri, 11 Feb 2022 20:48:48 +0000 (21:48 +0100)]
Rollup merge of #93782 - adamgemmell:dev/adagem01/split-pauth, r=Amanieu

Split `pauth` target feature

Per discussion on https://github.com/rust-lang/rust/issues/86941 we'd like to split `pauth` into `paca` and `pacg` in order to better support possible future environments that only have the keys available for address or generic authentication. At the moment LLVM has the one `pauth` target_feature while Linux presents separate `paca` and `pacg` flags for feature detection.

Because the use of [target_feature](https://rust-lang.github.io/rfcs/2045-target-feature.html) will "allow the compiler to generate code under the assumption that this code will only be reached in hosts that support the feature", it does not make sense to simply translate `paca` into the LLVM feature `pauth`, as it will generate code as if `pacg` is available.

To accommodate this we error if only one of the two features is present. If LLVM splits them in the future we can remove this restriction without making a breaking change.

r? ```@Amanieu```

2 years agoRollup merge of #93660 - aDotInTheVoid:rustdoc-type-tests, r=CraftSpider
Matthias Krüger [Fri, 11 Feb 2022 20:48:47 +0000 (21:48 +0100)]
Rollup merge of #93660 - aDotInTheVoid:rustdoc-type-tests, r=CraftSpider

rustdoc-json: Add some tests for typealias item

r? ```@CraftSpider```

Improves https://github.com/rust-lang/rust/issues/81359

The test's arn't pretty, and I think eventually we need a better way of doing repeated tests on a deeply nested path,
without repeating the way to get to that path

```@rustbot``` modify labels: +A-rustdoc-json +T-rustdoc +A-rustdoc +A-testsuite

2 years agoRollup merge of #93635 - GuillaumeGomez:missing-platform-spec-info, r=Amanieu
Matthias Krüger [Fri, 11 Feb 2022 20:48:46 +0000 (21:48 +0100)]
Rollup merge of #93635 - GuillaumeGomez:missing-platform-spec-info, r=Amanieu

Add missing platform-specific information on current_dir and set_current_dir

Fixes #93598.

2 years agoRollup merge of #92895 - bjorn3:simplifications, r=jackh726
Matthias Krüger [Fri, 11 Feb 2022 20:48:44 +0000 (21:48 +0100)]
Rollup merge of #92895 - bjorn3:simplifications, r=jackh726

Remove some unused functionality

* Remove the `alt_std_name` option
* Remove the everybody loops pass
* Make two functions private

2 years agoRollup merge of #91607 - FabianWolff:issue-91560-const-span, r=jackh726
Matthias Krüger [Fri, 11 Feb 2022 20:48:43 +0000 (21:48 +0100)]
Rollup merge of #91607 - FabianWolff:issue-91560-const-span, r=jackh726

Make `span_extend_to_prev_str()` more robust

Fixes #91560. The logic in `span_extend_to_prev_str()` is currently quite brittle and fails if there is extra whitespace or something else in between, and it also should return an `Option` but doesn't currently.

2 years agoRollup merge of #90955 - JohnTitor:os-error-123-as-invalid-input, r=m-ou-se
Matthias Krüger [Fri, 11 Feb 2022 20:48:42 +0000 (21:48 +0100)]
Rollup merge of #90955 - JohnTitor:os-error-123-as-invalid-input, r=m-ou-se

Rename `FilenameTooLong` to `InvalidFilename` and also use it for Windows' `ERROR_INVALID_NAME`

Address https://github.com/rust-lang/rust/issues/90940#issuecomment-970157931
`ERROR_INVALID_NAME` (i.e. "The filename, directory name, or volume label syntax is incorrect") happens if we pass an invalid filename, directory name, or label syntax, so mapping as `InvalidInput` is reasonable to me.

2 years agouse body.tainted_by_error to skip loading MIR
Michael Goulet [Tue, 8 Feb 2022 06:21:23 +0000 (22:21 -0800)]
use body.tainted_by_error to skip loading MIR

2 years agoadd tainted_by_errors to mir::Body
Michael Goulet [Tue, 8 Feb 2022 06:00:15 +0000 (22:00 -0800)]
add tainted_by_errors to mir::Body

2 years agorework borrowck errors so that it's harder to not set tainted
Michael Goulet [Tue, 8 Feb 2022 06:37:32 +0000 (22:37 -0800)]
rework borrowck errors so that it's harder to not set tainted

2 years agoalways cache result from mir_borrowck
Michael Goulet [Sun, 6 Feb 2022 21:53:38 +0000 (13:53 -0800)]
always cache result from mir_borrowck

2 years agofix tests, add new tests checking borrowck CFTE ICE
Michael Goulet [Sun, 6 Feb 2022 04:51:33 +0000 (20:51 -0800)]
fix tests, add new tests checking borrowck CFTE ICE

2 years agoskip const eval if we have an error in borrowck
Michael Goulet [Sun, 6 Feb 2022 20:16:49 +0000 (12:16 -0800)]
skip const eval if we have an error in borrowck

2 years agoimplement tainted_by_errors in mir borrowck
Michael Goulet [Sun, 6 Feb 2022 20:15:39 +0000 (12:15 -0800)]
implement tainted_by_errors in mir borrowck

2 years agoAuto merge of #90271 - adamgemmell:dev/feat-detect-stabilise, r=Amanieu
bors [Fri, 11 Feb 2022 20:41:51 +0000 (20:41 +0000)]
Auto merge of #90271 - adamgemmell:dev/feat-detect-stabilise, r=Amanieu

Stabilise `is_aarch64_feature_detected!` under `simd_aarch64` feature

Initial implementation, looking for feedback on the approach here. https://github.com/rust-lang/rust/issues/86941

One point I noticed was that I haven't seen different "since" versions for the same feature - does this mean that other features can't be added to to the `simd_aarch64` feature once this is in stable? If so it might need a more specific name.

r? `@Amanieu`

2 years agoMake two functions private
bjorn3 [Fri, 25 Jun 2021 09:59:35 +0000 (11:59 +0200)]
Make two functions private

2 years agoRemove the alt_std_name option
bjorn3 [Fri, 14 Jan 2022 13:25:52 +0000 (14:25 +0100)]
Remove the alt_std_name option

This option introduced in #15820 allows a custom crate to be imported in
the place of std, but with the name std. I don't think there is any
value to this. At most it is confusing users of a driver that uses this option. There are no users of
this option on github. If anyone still needs it, they can emulate it
injecting #![no_core] in addition to their own prelude.

2 years agoAuto merge of #93893 - oli-obk:sad_revert, r=oli-obk
bors [Fri, 11 Feb 2022 17:39:34 +0000 (17:39 +0000)]
Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk

Revert lazy TAIT PR

Revert https://github.com/rust-lang/rust/pull/92306 (sorry `@Aaron1011,` will include your changes in the fix PR)
Revert https://github.com/rust-lang/rust/pull/93783
Revert https://github.com/rust-lang/rust/pull/92007

fixes https://github.com/rust-lang/rust/issues/93788
fixes https://github.com/rust-lang/rust/issues/93794
fixes https://github.com/rust-lang/rust/issues/93821
fixes https://github.com/rust-lang/rust/issues/93831
fixes https://github.com/rust-lang/rust/issues/93841

2 years agoFix typo: explicitely->explicitly
Kagami Sascha Rosylight [Fri, 11 Feb 2022 15:23:39 +0000 (16:23 +0100)]
Fix typo: explicitely->explicitly

2 years agofix mention of moved function in `rustc_hir` docs
Rose Hudson [Fri, 11 Feb 2022 15:34:33 +0000 (15:34 +0000)]
fix mention of moved function in `rustc_hir` docs

the function was moved from `Crate` to `Map` in db9fea508a6d but the
docs weren't updated

2 years agoAdd missing platform-specific information on current_dir and set_current_dir
Guillaume Gomez [Thu, 3 Feb 2022 22:19:36 +0000 (23:19 +0100)]
Add missing platform-specific information on current_dir and set_current_dir

2 years agoAuto merge of #93891 - matthiaskrgr:rollup-xadut8w, r=matthiaskrgr
bors [Fri, 11 Feb 2022 15:16:09 +0000 (15:16 +0000)]
Auto merge of #93891 - matthiaskrgr:rollup-xadut8w, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #92242 (Erase regions before calculating layout for packed field capture)
 - #93443 (Add comment on stable_hash_impl for OwnerNodes)
 - #93742 (Drop rustc-docs from complete profile)
 - #93852 (rustdoc: remove support for multi-query search)
 - #93853 (Make all `hir::Map` methods consistently by-value)
 - #93861 (Fix ICE if no trait assoc const eq)
 - #93862 (Split x86_64-apple builder into two)
 - #93864 (Remove ArchiveBuilder::update_symbols)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoCheck that error code explanations are listed in error_codes.rs
Guillaume Gomez [Fri, 11 Feb 2022 11:06:13 +0000 (12:06 +0100)]
Check that error code explanations are listed in error_codes.rs

2 years agolinkchecker: fix panic on directory symlinks
Simon Chopin [Fri, 11 Feb 2022 09:20:32 +0000 (10:20 +0100)]
linkchecker: fix panic on directory symlinks

In Debian and Ubuntu, there are some patches that change the rustc/fonts
directory to a symlink to the system fonts. This triggers a latent bug
in linkchecker, as the DirEntry filetype isn't a dir but later on the
file itself, when opened, is one, triggering an unreachable!() clause.

This patch fixes the situation by using std::fs::metadata, which goes
through symlinks.

I'd have added a test case but `tidy` doesn't seem to like symlinks, and
moreover I'm not sure how Git deals with symlinks on Windows.

Signed-off-by: Simon Chopin <simon.chopin@canonical.com>