bors [Mon, 11 Oct 2021 17:12:14 +0000 (17:12 +0000)]
Auto merge of #83908 - Flying-Toast:master, r=davidtwco
Add enum_intrinsics_non_enums lint
There is a clippy lint to prevent calling [`mem::discriminant`](https://doc.rust-lang.org/std/mem/fn.discriminant.html) with a non-enum type. I think the lint is worthy of being included in rustc, given that `discriminant::<T>()` where `T` is a non-enum has an unspecified return value, and there are no valid use cases where you'd actually want this.
I've also made the lint check [variant_count](https://doc.rust-lang.org/core/mem/fn.variant_count.html) (#73662).
Guillaume Gomez [Mon, 11 Oct 2021 12:11:44 +0000 (14:11 +0200)]
Rollup merge of #89743 - matthewjasper:env-log-fix, r=jyn514
Fix RUSTC_LOG handling
Rustc was incorrectly reading the value of `RUSTC_LOG` as the environment vairable with the logging configuration, rather than the logging configuration itself.
Guillaume Gomez [Mon, 11 Oct 2021 12:11:42 +0000 (14:11 +0200)]
Rollup merge of #89726 - jkugelman:must-use-alloc-constructors, r=joshtriplett
Add #[must_use] to alloc constructors
Added `#[must_use]`. to the various forms of `new`, `pin`, and `with_capacity` in the `alloc` crate. No extra explanations given as I couldn't think of anything useful to add.
I figure this deserves extra scrutiny compared to the other PRs I've done so far. In particular:
* The 4 `pin`/`pin_in` methods I touched. Are there legitimate use cases for pinning and not using the result? Pinning's a difficult concept I'm not very comfortable with.
* `Box`'s constructors. Do people ever create boxes just for the side effects... allocating or zeroing out memory?
Guillaume Gomez [Mon, 11 Oct 2021 12:11:41 +0000 (14:11 +0200)]
Rollup merge of #89655 - tlyu:find-non-merge-commits, r=jyn514
bootstrap: don't use `--merges` to look for commit hashes for downloading artifacts
Shallow clones (and possibly worktrees, though I can't seem to reproduce the problem there) can cause `git rev-list --merges` to falsely return no results, even if a merge commit is present. Stop using the `--merges` option when looking for commit hashes that have build artifacts. `--first-parent` and `--author=bors@rust-lang.org` should be sufficient.
Also exit with an error if the configuration asks for artifacts to be downloaded and we can't determine an appropriate commit hash to use to download artifacts.
bors [Mon, 11 Oct 2021 04:31:47 +0000 (04:31 +0000)]
Auto merge of #89597 - michaelwoerister:improve-vtable-debuginfo, r=wesleywiser
Create more accurate debuginfo for vtables.
Before this PR all vtables would have the same name (`"vtable"`) in debuginfo. Now they get an unambiguous name that identifies the implementing type and the trait that is being implemented.
This is only one of several possible improvements:
- This PR describes vtables as arrays of `*const u8` pointers. It would nice to describe them as structs where function pointer is represented by a field with a name indicative of the method it maps to. However, this requires coming up with a naming scheme that avoids clashes between methods with the same name (which is possible if the vtable contains multiple traits).
- The PR does not update the debuginfo we generate for the vtable-pointer field in a fat `dyn` pointer. Right now there does not seem to be an easy way of getting ahold of a vtable-layout without also knowing the concrete self-type of a trait object.
Matthias Krüger [Sun, 10 Oct 2021 22:34:38 +0000 (00:34 +0200)]
Rollup merge of #89691 - Nicholas-Baron:debugger_commands, r=Mark-Simulacrum
Move `DebuggerCommands` and `check_debugger_output` to a separate module
Work towards #89475.
As part of this move, the public functions were changed to return `Result`. This is so that the error handling that initially took `&self: TestCx` can still use that `TestCx`.
bors [Sun, 10 Oct 2021 22:25:49 +0000 (22:25 +0000)]
Auto merge of #89541 - workingjubilee:abbrev-shufvec-t, r=Mark-Simulacrum
Cleanup src/test/ui/{simd,simd-intrinsic}
Initial motivation was to simplify a huge macro expansion using a tuple, since we can just use an array in `#[repr(simd)]` now for the same result. But also, several tests were going unnoticed during development of SIMD intrinsics because people kept looking in the wrong directory, and many are basically run-pass vs. build-fail versions of the same tests, so let's keep them close together and simplify their names, so they're easier to sift through.
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)
Matthew Jasper [Sun, 10 Oct 2021 18:59:36 +0000 (19:59 +0100)]
Fix RUSTC_LOG handling
Rustc was incorrectly reading the value of `RUSTC_LOG` as the
environment vairable with the logging configuration, rather than the
logging configuration itself.
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.