bors [Sun, 10 Oct 2021 19:05:13 +0000 (19:05 +0000)]
Auto merge of #89739 - matthiaskrgr:rollup-kskwqy5, r=matthiaskrgr
Rollup of 11 pull requests
Successful merges:
- #88374 (Fix documentation in Cell)
- #88713 (Improve docs for int_log)
- #89428 (Feature gate the non_exhaustive_omitted_patterns lint)
- #89438 (docs: `std::hash::Hash` should ensure prefix-free data)
- #89520 (Don't rebuild GUI test crates every time you run test src/test/rustdoc-gui)
- #89705 (Cfg hide no_global_oom_handling and no_fp_fmt_parse)
- #89713 (Fix ABNF of inline asm options)
- #89718 (Add #[must_use] to is_condition tests)
- #89719 (Add #[must_use] to char escape methods)
- #89720 (Add #[must_use] to math and bit manipulation methods)
- #89735 (Stabilize proc_macro::is_available)
Matthias Krüger [Sun, 10 Oct 2021 16:22:21 +0000 (18:22 +0200)]
Rollup merge of #89705 - nbdd0121:doc, r=GuillaumeGomez
Cfg hide no_global_oom_handling and no_fp_fmt_parse
These are unstable sysroot customisation cfg options that only projects building their own sysroot will use (e.g. Rust-for-linux). Most users shouldn't care. `no_global_oom_handling` can be especially annoying since it's applied on many commonly used alloc crate methods (e.g. `Box::new`, `Vec::push`).
Matthias Krüger [Sun, 10 Oct 2021 16:22:18 +0000 (18:22 +0200)]
Rollup merge of #88713 - falk-hueffner:int-log10-documentation-fixes, r=scottmcm
Improve docs for int_log
* Clarify rounding.
* Avoid "wrapping" wording.
* Omit wrong claim on 0 only being returned in error cases.
* Typo fix for one_less_than_next_power_of_two.
bors [Sun, 10 Oct 2021 15:59:28 +0000 (15:59 +0000)]
Auto merge of #89633 - rhysd:issue-65230, r=petrochenkov
Show detailed expected/found types in error message when trait paths are the same
Fixes #65230.
### Issue solved by this PR
```rust
trait T {
type U;
fn f(&self) -> Self::U;
}
struct X<'a>(&'a mut i32);
impl<'a> T for X<'a> {
type U = &'a i32;
fn f(&self) -> Self::U {
self.0
}
}
fn main() {}
```
Compiler generates the following note:
```
note: ...so that the types are compatible
--> test.rs:10:28
|
10 | fn f(&self) -> Self::U {
| ____________________________^
11 | | self.0
12 | | }
| |_____^
= note: expected `T`
found `T`
```
This note is not useful since the expected type and the found type are the same.
### How this PR solve the issue
When the expected type and the found type are exactly the same in string representation, the note falls back to the detailed string representation of trait ref:
```
note: ...so that the types are compatible
--> test.rs:10:28
|
10 | fn f(&self) -> Self::U {
| ____________________________^
11 | | self.0
12 | | }
| |_____^
= note: expected `<X<'a> as T>`
found `<X<'_> as T>`
```
So that a user can notice what was different between the expected one and the found one.
bors [Sun, 10 Oct 2021 08:16:22 +0000 (08:16 +0000)]
Auto merge of #88952 - skrap:add-armv7-uclibc, r=nagisa
Add new tier-3 target: armv7-unknown-linux-uclibceabihf
This change adds a new tier-3 target: armv7-unknown-linux-uclibceabihf
This target is primarily used in embedded linux devices where system resources are slim and glibc is deemed too heavyweight. Cross compilation C toolchains are available [here](https://toolchains.bootlin.com/) or via [buildroot](https://buildroot.org).
The change is based largely on a previous PR #79380 with a few minor modifications. The author of that PR was unable to push the PR forward, and graciously allowed me to take it over.
Per the [target tier 3 policy](https://github.com/rust-lang/rfcs/blob/master/text/2803-target-tier-policy.md), I volunteer to be the "target maintainer".
This is my first PR to Rust itself, so I apologize if I've missed things!
bors [Sun, 10 Oct 2021 01:46:11 +0000 (01:46 +0000)]
Auto merge of #89661 - rusticstuff:libisl_mirror_take_two, r=Mark-Simulacrum
CI: Use mirror for libisl downloads for more docker dist builds
http://isl.gforge.inria.fr fell from the net a couple of days ago. It hosts libisl source tarballs required by crosstool-ng, which we use for our docker dist cross-compilation builds. Some of the affected builds were already fixed in #89599.
This PR sets a mirror URL for the other builds requiring libisl-0.14. They use an older version of crosstool-ng (1.22.0), which has only one mirror setting for all downloads.
Guillaume Gomez [Sat, 9 Oct 2021 15:08:40 +0000 (17:08 +0200)]
Rollup merge of #89614 - cuviper:unicode-14, r=joshtriplett
Update to Unicode 14.0
The Unicode Standard [announced Version 14.0](https://home.unicode.org/announcing-the-unicode-standard-version-14-0/) on September 14, 2021, and this pull request updates the generated tables in `core` accordingly.
This did require a little prep-work in `unicode-table-generator`. First, #81358 had modified the generated file instead of the tool, so that change is now reflected in the tool as well. Next, I found that the "Alphabetic" property in version 14 was panicking when generating a bitset, "cannot pack 264 into 8 bits". We've been using the skiplist for that anyway, so I changed this to fail gracefully. Finally, I confirmed that the tool still created the exact same tables for 13 before moving to 14.
let _array = core::array::from_fn::<_, _, 2>(|idx| Foo(idx));
```
Different from `FromIterator`, it is guaranteed that the array will be fully filled and no error regarding uninitialized state will be throw. In certain scenarios, however, the creation of an **element** can fail and that is why the `try_from_fn` function is also provided.
bors [Sat, 9 Oct 2021 13:13:07 +0000 (13:13 +0000)]
Auto merge of #89343 - Mark-Simulacrum:no-args-queries, r=cjgillot
Refactor fingerprint reconstruction
This PR replaces can_reconstruct_query_key with fingerprint_style, which returns the style of the fingerprint for that query. This allows us to avoid trying to extract a DefId (or equivalent) from keys which *are* reconstructible because they're () but not as DefIds.
This is done with the goal of fixing -Zdump-dep-graph, which seems to have broken a while ago (I didn't try to bisect). Currently even on a `fn main() {}` file it'll ICE (you need to also pass -Zquery-dep-graph for it to work at all), and this patch indirectly fixes the cause of that ICE. This also adds a test for it continuing to work.
bors [Sat, 9 Oct 2021 10:00:54 +0000 (10:00 +0000)]
Auto merge of #89698 - matthiaskrgr:rollup-gna54x6, r=matthiaskrgr
Rollup of 10 pull requests
Successful merges:
- #88707 (String.split_terminator: Add an example when using a slice of chars)
- #89605 (Fix stabilization version for `bindings_after_at`)
- #89634 (rustc_driver: Enable the `WARN` log level by default)
- #89641 (make #[target_feature] work with `asm` register classes)
- #89678 (Fix minor std::thread documentation typo)
- #89684 (Fix asm docs typo)
- #89687 (Move `read2_abbreviated` function into read2.rs)
- #89693 (Add #[must_use] to stdin/stdout/stderr locks)
- #89694 (Add #[must_use] to string/char transformation methods)
- #89697 (Fix min LLVM version for bpf-types test)
Matthias Krüger [Sat, 9 Oct 2021 09:55:59 +0000 (11:55 +0200)]
Rollup merge of #89634 - hawkw:eliza/enable-err-warn, r=oli-obk
rustc_driver: Enable the `WARN` log level by default
This commit changes the `tracing_subscriber` initialization in
`rustc_driver` so that the `WARN` verbosity level is enabled by default
when the `RUSTC_LOG` env variable is empty. If the `RUSTC_LOG` env
variable is set, the filter string in the environment variable is
honored, instead.
bors [Sat, 9 Oct 2021 05:24:47 +0000 (05:24 +0000)]
Auto merge of #89582 - jkugelman:optimize-file-read-to-end, r=joshtriplett
Optimize File::read_to_end and read_to_string
Reading a file into an empty vector or string buffer can incur unnecessary `read` syscalls and memory re-allocations as the buffer "warms up" and grows to its final size. This is perhaps a necessary evil with generic readers, but files can be read in smarter by checking the file size and reserving that much capacity.
`std::fs::read` and `std::fs::read_to_string` already perform this optimization: they open the file, reads its metadata, and call `with_capacity` with the file size. This ensures that the buffer does not need to be resized and an initial string of small `read` syscalls.
However, if a user opens the `File` themselves and calls `file.read_to_end` or `file.read_to_string` they do not get this optimization.
```rust
let mut buf = Vec::new();
file.read_to_end(&mut buf)?;
```
I searched through this project's codebase and even here are a *lot* of examples of this. They're found all over in unit tests, which isn't a big deal, but there are also several real instances in the compiler and in Cargo. I've documented the ones I found in a comment here:
Most telling, the documentation for both the `Read` trait and the `Read::read_to_end` method both show this exact pattern as examples of how to use readers. What this says to me is that this shouldn't be solved by simply fixing the instances of it in this codebase. If it's here it's certain to be prevalent in the wider Rust ecosystem.
To that end, this commit adds specializations of `read_to_end` and `read_to_string` directly on `File`. This way it's no longer a minor footgun to start with an empty buffer when reading a file in.
A nice side effect of this change is that code that accesses a `File` as `impl Read` or `dyn Read` will benefit. For example, this code from `compiler/rustc_serialize/src/json.rs`:
- I also added specializations to `BufReader` to delegate to `self.inner`'s methods. That way it can call `File`'s optimized implementations if the inner reader is a file.
- The private `std::io::append_to_string` function is now marked `unsafe`.
- `File::read_to_string` being more efficient means that the performance note for `io::read_to_string` can be softened. I've added `@camelid's` suggested wording from https://github.com/rust-lang/rust/issues/80218#issuecomment-936806502.
Devin Ragotzy [Fri, 1 Oct 2021 14:21:56 +0000 (10:21 -0400)]
Add feature gate to non_exhaustive_omitted_patterns lint
Actually add the feature to the lints ui test
Add tracking issue to the feature declaration
Rename feature gate to non_exhaustive_omitted_patterns_lint
Add more omitted_patterns lint feature gate
bors [Fri, 8 Oct 2021 21:13:27 +0000 (21:13 +0000)]
Auto merge of #89683 - GuillaumeGomez:rollup-q2mjd9m, r=GuillaumeGomez
Rollup of 6 pull requests
Successful merges:
- #86506 (Don't normalize xform_ret_ty during method candidate assembly )
- #89538 (Make rustdoc not highlight `->` and `=>` as operators)
- #89649 (clippy::complexity fixes)
- #89668 (Cfg hide more conditions for core and alloc)
- #89669 (Remove special-casing of never primitive in rustdoc-json-types)
- #89672 (Remove unwrap_or! macro)
Guillaume Gomez [Fri, 8 Oct 2021 20:30:39 +0000 (22:30 +0200)]
Rollup merge of #89538 - notriddle:notriddle/arrow-highlight, r=GuillaumeGomez
Make rustdoc not highlight `->` and `=>` as operators
It was marking them up as `<span class="op">=</span><span class="op">></span>`,
which is bloaty and wrong (at least, I think `<=` and `=>` should probably be different colors, since they're so different and yet made from the same symbols).
Normalizing the return type of a method candidate together with the expected receiver type of the method can lead to valid method candidates being rejected during probing. Specifically in the example of the fixed issue we have a `self_ty` of the form `&A<&[Coef]>` whereas the `impl_ty` of the method would be `&A<_>`, if we normalize the projection in the return type we unify the inference variable with `Cont`, which will lead us to reject the candidate in the sup type check in `consider_probe`. Since we don't actually need the normalized return type during candidate assembly, we postpone the normalization until we consider candidates in `consider_probe`.
bors [Fri, 8 Oct 2021 18:12:50 +0000 (18:12 +0000)]
Auto merge of #89666 - rusticstuff:disable_new_llvm_pass_manager_on_s390x_take_two, r=nagisa
Default to disabling the new pass manager for the s390x arch targets.
This hack disables the new LLVM pass manager by default for s390x arch targets until the performance issues are fixed (see #89609). The command line option `-Z new-llvm-pass-manager=(yes|no)` continues to take precedence over this default.
bors [Fri, 8 Oct 2021 11:44:45 +0000 (11:44 +0000)]
Auto merge of #89576 - tom7980:issue-89275-fix, r=estebank
Prevent error reporting from outputting a recursion error if it finds an ambiguous trait impl during suggestions
Closes #89275
This fixes the compiler reporting a recursion error during another already in progress error by trying to make a conversion method suggestion and encounters ambiguous trait implementations that can convert a the original type into a type that can then be recursively converted into itself via another method in the trait.
Updated OverflowError struct to be an enum so I could differentiate between passes - it's no longer a ZST but I don't think that should be a problem as they only generate when there's an error in compiling code anyway
bors [Fri, 8 Oct 2021 06:16:31 +0000 (06:16 +0000)]
Auto merge of #89659 - workingjubilee:rollup-0vggc69, r=workingjubilee
Rollup of 8 pull requests
Successful merges:
- #87918 (Enable AutoFDO.)
- #88137 (On macOS, make strip="symbols" not pass any options to strip)
- #88772 (Fixed confusing wording on Result::map_or_else.)
- #89025 (Implement `#[link_ordinal(n)]`)
- #89082 (Implement #85440 (Random test ordering))
- #89288 (Wrapper for `-Z gcc-ld=lld` to invoke rust-lld with the correct flavor)
- #89476 (Correct decoding of foreign expansions during incr. comp.)
- #89622 (Use correct edition for panic in [debug_]assert!().)
Jubilee [Fri, 8 Oct 2021 03:26:13 +0000 (20:26 -0700)]
Rollup merge of #89288 - rusticstuff:lld_wrapper, r=Mark-Simulacrum
Wrapper for `-Z gcc-ld=lld` to invoke rust-lld with the correct flavor
This PR adds an `lld-wrapper` tool which is installed as `ld` and `ld64` in `lib\rustlib\<host_target>\bin\gcc-ld` directory and whose sole purpose is to invoke `rust-lld` in the parent directory with the correct flavor. Lld decides which flavor to use from either the first two commandline arguments or from the name of the executable (`ld` for GNU/ld flavor, `ld64` for Darwin/Macos/ld64 flavor and so on). Symbolic links could not be used as they are not supported by rustup and on Windows.
The wrapper replaces full copies of rust-lld which added some significant bloat. On UNIXish operating systems it exec rust-lld, on Windows it spawns it as a child process.
Fixes #88869.
r? ```@Mark-Simulacrum```
cc ```@nagisa``` ```@petrochenkov``` ```@1000teslas```
Jubilee [Fri, 8 Oct 2021 03:26:12 +0000 (20:26 -0700)]
Rollup merge of #89082 - smoelius:master, r=kennytm
Implement #85440 (Random test ordering)
This PR adds `--shuffle` and `--shuffle-seed` options to `libtest`. The options are similar to the [`-shuffle` option](https://github.com/golang/go/blob/c894b442d1e5e150ad33fa3ce13dbfab1c037b3a/src/testing/testing.go#L1482-L1499) that was recently added to Go.
Here are the relevant parts of the help message:
```
--shuffle Run tests in random order
--shuffle-seed SEED
Run tests in random order; seed the random number
generator with SEED
...
By default, the tests are run in alphabetical order. Use --shuffle or set
RUST_TEST_SHUFFLE to run the tests in random order. Pass the generated
"shuffle seed" to --shuffle-seed (or set RUST_TEST_SHUFFLE_SEED) to run the
tests in the same order again. Note that --shuffle and --shuffle-seed do not
affect whether the tests are run in parallel.
```
Is an RFC needed for this?
Jubilee [Fri, 8 Oct 2021 03:26:11 +0000 (20:26 -0700)]
Rollup merge of #89025 - ricobbe:raw-dylib-link-ordinal, r=michaelwoerister
Implement `#[link_ordinal(n)]`
Allows the use of `#[link_ordinal(n)]` with `#[link(kind = "raw-dylib")]`, allowing Rust to link against DLLs that export symbols by ordinal rather than by name. As long as the ordinal matches, the name of the function in Rust is not required to match the name of the corresponding function in the exporting DLL.
Jubilee [Fri, 8 Oct 2021 03:26:09 +0000 (20:26 -0700)]
Rollup merge of #87918 - mikebenfield:pr-afdo, r=nikic
Enable AutoFDO.
This largely involves implementing the options debug-info-for-profiling
and profile-sample-use and forwarding them on to LLVM.
AutoFDO can be used on x86-64 Linux like this:
rustc -O -Clink-arg='Wl,--no-rosegment' -Cdebug-info-for-profiling main.rs -o main
perf record -b ./main
create_llvm_prof --binary=main --out=code.prof
rustc -O -Cprofile-sample-use=code.prof main.rs -o main2
Now `main2` will have feedback directed optimization applied to it.
The create_llvm_prof tool can be obtained from this github repository:
https://github.com/google/autofdo
The option -Clink-arg='Wl,--no-rosegment' is necessary to avoid lld
putting an extra RO segment before the executable code, which would make
the binary silently incompatible with create_llvm_prof.
John Kugelman [Tue, 5 Oct 2021 23:50:28 +0000 (19:50 -0400)]
Optimize File::read_to_end and read_to_string
Reading a file into an empty vector or string buffer can incur
unnecessary `read` syscalls and memory re-allocations as the buffer
"warms up" and grows to its final size. This is perhaps a necessary evil
with generic readers, but files can be read in smarter by checking the
file size and reserving that much capacity.
`std::fs::read` and `read_to_string` already perform this optimization:
they open the file, reads its metadata, and call `with_capacity` with
the file size. This ensures that the buffer does not need to be resized
and an initial string of small `read` syscalls.
However, if a user opens the `File` themselves and calls
`file.read_to_end` or `file.read_to_string` they do not get this
optimization.
```rust
let mut buf = Vec::new();
file.read_to_end(&mut buf)?;
```
I searched through this project's codebase and even here are a *lot* of
examples of this. They're found all over in unit tests, which isn't a
big deal, but there are also several real instances in the compiler and
in Cargo. I've documented the ones I found in a comment here:
Most telling, the `Read` trait and the `read_to_end` method both show
this exact pattern as examples of how to use readers. What this says to
me is that this shouldn't be solved by simply fixing the instances of it
in this codebase. If it's here it's certain to be prevalent in the wider
Rust ecosystem.
To that end, this commit adds specializations of `read_to_end` and
`read_to_string` directly on `File`. This way it's no longer a minor
footgun to start with an empty buffer when reading a file in.
A nice side effect of this change is that code that accesses a `File` as
a bare `Read` constraint or via a `dyn Read` trait object will benefit.
For example, this code from `compiler/rustc_serialize/src/json.rs`:
- I also added specializations to `BufReader` to delegate to
`self.inner`'s methods. That way it can call `File`'s optimized
implementations if the inner reader is a file.
- The private `std::io::append_to_string` function is now marked
`unsafe`.
- `File::read_to_string` being more efficient means that the performance
note for `io::read_to_string` can be softened. I've added @camelid's
suggested wording from: