Guarantee 8 bytes of alignment in Thread::into_raw
When using `AtomicPtr` for synchronization it's incredibly useful when you've got a couple bits you can stuff metadata in. By guaranteeing that `Thread`'s `Inner` struct is aligned to 8 bytes everyone can use the bottom 3 bits to signal other things, such as a critical section, etc.
This guarantee is thus very useful and costs us nothing.
Fix unused_parens false positive
Resolvesrust-lang/rust#143653.
The "no bounds exception" was indiscriminately set to `OneBound` for referents and pointees. However, if the reference or pointer type itself appears in no-bounds position, any constraints it has must be propagated.
```rust
// unused parens: not in no-bounds position
fn foo(_: Box<(dyn Send)>) {}
// unused parens: in no-bounds position, but one-bound exception applies
fn bar(_: Box<dyn Fn(&u32) -> &(dyn Send)>) {}
// *NOT* unused parens: in no-bounds position, but no exceptions to be made
fn baz(_: Box<dyn Fn(&u32) -> &(dyn Send) + Send>) {}
```
Upgrade the `fortanix-sgx-abi` dependency
0.6.1 removes the `compiler-builtins` dependency, part of RUST-142265. The breaking change from 0.5 to 0.6 is for an update to the `insecure_time` API [1].
I validated that `./x c library --target x86_64-fortanix-unknown-sgx` completes successfully with this change.
Link: a34e9767f3 [1]
rustdoc: add ways of collapsing all impl blocks
either shift+click the Summary button,
or use the `_` key.
this collapses everything,
including (inherent) impl blocks.
no need for a special "expand all impl blocks"
method, as impl blocks are expanded during regular "expand all".
doing "expand all" -> "collapse all" will always
result in only impl blocks being expaned.
not sure the best way to add a GUI test.
fixes https://github.com/rust-lang/rust/issues/134429
Do not run per-module late lints if they can be all skipped
We run ~70 late lints for all dependencies even if they use `--cap-lints=allow`, which seems wasteful. It looks like these lints are super fast (unlike early lints), but still.
r? `@ghost`
Rollup of 12 pull requests
Successful merges:
- rust-lang/rust#142569 (Suggest clone in user-write-code instead of inside macro)
- rust-lang/rust#143401 (tests: Don't check for self-printed output in std-backtrace.rs test)
- rust-lang/rust#143424 (clippy fix: rely on autoderef)
- rust-lang/rust#143970 (Update core::mem::copy documentation)
- rust-lang/rust#143979 (Test fixes for Arm64EC Windows)
- rust-lang/rust#144200 (Tweak output for non-`Clone` values moved into closures)
- rust-lang/rust#144209 (Don't emit two `assume`s in transmutes when one is a subset of the other)
- rust-lang/rust#144314 (Hint that choose_pivot returns index in bounds)
- rust-lang/rust#144340 (UI test suite clarity changes: Rename `tests/ui/SUMMARY.md` and update rustc dev guide on `error-pattern`)
- rust-lang/rust#144368 (resolve: Remove `Scope::CrateRoot`)
- rust-lang/rust#144390 (Remove dead code and extend test coverage and diagnostics around it)
- rust-lang/rust#144392 (rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`)
r? `@ghost`
`@rustbot` modify labels: rollup
rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`
Part of rust-lang/rust#119174 .
I think we should be good now to sync this change in rustc_public.
Remove dead code and extend test coverage and diagnostics around it
I was staring a bit at the `dont_niche_optimize_enum` variable and figured out that part of it is dead code (at least today it is). I changed the diagnostic and test around the code that makes that part dead code, so everything that makes removing that code sound is visible in this PR
resolve: Remove `Scope::CrateRoot`
Use `Scope::Module` with the crate root module inside instead, which should be identical.
This is a simplification by itself, but it will be even larger simplification if something like https://github.com/rust-lang/rust/pull/144131 is implemented, because `Scope::CrateRoot` is also a module with two actual scopes in it (for globs and non-globs).
I also did some renamings for consistency:
- `ScopeSet::AbsolutePath` -> `ScopeSet::ModuleAndExternPrelude`
- `ModuleOrUniformRoot::CrateRootAndExternPrelude` -> `ModuleOrUniformRoot::ModuleAndExternPrelude`
- `is_absolute_path` -> `module_and_extern_prelude`
UI test suite clarity changes: Rename `tests/ui/SUMMARY.md` and update rustc dev guide on `error-pattern`
To match convention, rename `tests/ui/SUMMARY.md` to `tests/ui/README.md`.
Also, remove misleading lines in the rustc development guide about `error-pattern` being "not recommended", when it really is just a last resort which *should* be used in the niche situations where it is useful.
r? ````@jieyouxu````
Hint that choose_pivot returns index in bounds
Instead of using `unsafe` in multiple places, one `hint::assert_unchecked` allows use of safe code instead.
Part of #rust-lang/rust#144326
Don't emit two `assume`s in transmutes when one is a subset of the other
For example, transmuting between `bool` and `Ordering` doesn't need two `assume`s because one range is a superset of the other.
Multiple are still used for things like `char` <-> `NonZero<u32>`, which overlap but where neither fully contains the other.
Tweak output for non-`Clone` values moved into closures
When we encounter a non-`Clone` value being moved into a closure, try to find the corresponding type of the binding being moved, if it is a `let`-binding or a function parameter. If any of those cases, we point at them with the note explaining that the type is not `Copy`, instead of giving that label to the place where it is captured. When it is a `let`-binding with no explicit type, we point at the initializer (if it fits in a single line).
```
error[E0507]: cannot move out of `foo`, a captured variable in an `Fn` closure
--> f111.rs:14:25
|
13 | fn do_stuff(foo: Option<Foo>) {
| --- ----------- move occurs because `foo` has type `Option<Foo>`, which does not implement the `Copy` trait
| |
| captured outer variable
14 | require_fn_trait(|| async {
| -- ^^^^^ `foo` is moved here
| |
| captured by this `Fn` closure
15 | if foo.map_or(false, |f| f.foo()) {
| --- variable moved due to use in coroutine
```
instead of
```
error[E0507]: cannot move out of `foo`, a captured variable in an `Fn` closure
--> f111.rs:14:25
|
13 | fn do_stuff(foo: Option<Foo>) {
| --- captured outer variable
14 | require_fn_trait(|| async {
| -- ^^^^^ `foo` is moved here
| |
| captured by this `Fn` closure
15 | if foo.map_or(false, |f| f.foo()) {
| ---
| |
| variable moved due to use in coroutine
| move occurs because `foo` has type `Option<Foo>`, which does not implement the `Copy` trait
```
Test fixes for Arm64EC Windows
* `tests/ui/cfg/conditional-compile-arch.rs` needs an Arm64EC case.
* `tests/ui/runtime/backtrace-debuginfo.rs` should skip Arm64EC as it suffers from the same truncated backtraces as Arm64 Windows.
* `tests/ui/linkage-attr/incompatible-flavor.rs` is a general issue: it assumes that the Rust compiler is always built with the x86 target enabled in the backend, but I only enabled AArch64 when building locally to speed up the LLVM compilation.
tests: Don't check for self-printed output in std-backtrace.rs test
The `Display` implementation for `Backtrace` used to print
stack backtrace:
but that print was since removed. See https://github.com/rust-lang/backtrace-rs/pull/286 and https://github.com/rust-lang/rust/pull/69042. To make the existing test pass, the print was added to the test instead. But it doesn't make sense to check for something that the test itself does since that will not detect any regressions in the implementation of `Backtrace`.
What the test _should_ check is that "stack backtrace:" is _not_ printed in `Display` of `Backtrace`. So do that instead.
This is one small steps towards resolving https://github.com/rust-lang/rust/issues/71706. The next steps after this step involves extending and hardening that test further.
MIR-build: No longer emit assumes in enum-as casting
This just uses the `valid_range` from the backend, so it's duplicating the range metadata that now we include on parameters and loads, and thus no longer seems to be useful -- notably there's no codegen test failures from removing it.
(Because it's using data from the same source as the backend annotations, it doesn't do anything to mitigate things like rust-lang/rust#144388 where the range in the layout is more permissive than the actual possible discriminants. A variant of this that actually checked the discriminants more specifically might be useful, so could potentially be added in future, but I don't think the *current* checks are actually providing value.)
r? mir
Randomly turns out that this
Fixes https://github.com/rust-lang/rust/issues/121097
Rollup of 15 pull requests
Successful merges:
- rust-lang/rust#143374 (Unquerify extern_mod_stmt_cnum.)
- rust-lang/rust#143838 (std: net: uefi: Add support to query connection data)
- rust-lang/rust#144014 (don't link to the nightly version of the Edition Guide in stable lints)
- rust-lang/rust#144094 (Ensure we codegen the main fn)
- rust-lang/rust#144218 (Use serde for target spec json deserialize)
- rust-lang/rust#144221 (generate elf symbol version in raw-dylib)
- rust-lang/rust#144240 (Add more test case to check if the false note related to sealed trait suppressed)
- rust-lang/rust#144247 (coretests/num: use ldexp instead of hard-coding a power of 2)
- rust-lang/rust#144276 (Use less HIR in check_private_in_public.)
- rust-lang/rust#144278 (add Rev::into_inner)
- rust-lang/rust#144317 (pass build.npm from bootstrap to tidy and use it for npm install)
- rust-lang/rust#144320 (rustdoc: avoid allocating a temp String for aliases in search index)
- rust-lang/rust#144334 (rustc_resolve: get rid of unused rustdoc::span_of_fragments_with_expansion)
- rust-lang/rust#144335 (Don't suggest assoc ty bound on non-angle-bracketed problematic assoc ty binding)
- rust-lang/rust#144358 (Stop using the old `validate_attr` logic for stability attributes)
r? `@ghost`
`@rustbot` modify labels: rollup
Stop using the old `validate_attr` logic for stability attributes
I think this was accidentally missed when implementing the stability attributes?
r? `````@oli-obk`````
cc `````@jdonszelmann`````
rustc_resolve: get rid of unused rustdoc::span_of_fragments_with_expansion
This function can cause false negatives if used incorrectly (usually "do any of the doc fragments come from a macro" is the wrong question to ask), and thus it is unused.
r? `````@GuillaumeGomez`````
rustdoc: avoid allocating a temp String for aliases in search index
Here's the optimization I talked about in https://github.com/rust-lang/rust/pull/143988#discussion_r2208524163
I got around the Serialize issue using the newtype pattern. The wrapper type could be factored out into a helper that would work with anything that impls `AsRef<&str>`, but I'm not sure if that would be helpful anywhere else.
r? ``````@GuillaumeGomez``````
Add more test case to check if the false note related to sealed trait suppressed
Closesrust-lang/rust#143121
I started to fix the issue but I found that this one has already been addressed in this PR (https://github.com/rust-lang/rust/pull/143431). I added an additional test to prove the reported thing has been resolved just in case.
I think we can discard this pull request if there's no need to add such kind of tests👍🏻