-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Rollup of 12 pull requests #144440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rollup of 12 pull requests #144440
Conversation
Signed-off-by: xizheyin <[email protected]>
Signed-off-by: xizheyin <[email protected]>
The `Display` implementation for `Backtrace` used to print stack backtrace: but that print was later removed. To make the existing test pass, the print was added to the existing test. 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`. Fully remove the checks.
When encountering a non-`Copy` value that is moved into a closure which is coming directly from a fn parameter, point at the parameter's type when mentioning it is not `Copy`. Before: ``` 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 ``` After: ``` 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 ```
Account not only for `fn` parameters when moving non-`Copy` values into closure, but also for let bindings. ``` error[E0507]: cannot move out of `bar`, a captured variable in an `FnMut` closure --> $DIR/borrowck-move-by-capture.rs:9:29 | LL | let bar: Box<_> = Box::new(3); | --- ------ move occurs because `bar` has type `Box<isize>`, which does not implement the `Copy` trait | | | captured outer variable LL | let _g = to_fn_mut(|| { | -- captured by this `FnMut` closure LL | let _h = to_fn_once(move || -> isize { *bar }); | ^^^^^^^^^^^^^^^^ ---- variable moved due to use in closure | | | `bar` is moved here | help: consider cloning the value before moving it into the closure | LL ~ let value = bar.clone(); LL ~ let _h = to_fn_once(move || -> isize { value }); | ``` ``` error[E0507]: cannot move out of `y`, a captured variable in an `Fn` closure --> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:12:9 | LL | let y = vec![format!("World")]; | - ---------------------- move occurs because `y` has type `Vec<String>`, which does not implement the `Copy` trait | | | captured outer variable LL | call(|| { | -- captured by this `Fn` closure LL | y.into_iter(); | ^ ----------- `y` moved due to this method call | | | `y` is moved here | note: `into_iter` takes ownership of the receiver `self`, which moves `y` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | <Vec<String> as Clone>::clone(&y).into_iter(); | +++++++++++++++++++++++++++++++ + help: consider cloning the value if the performance cost is acceptable | LL | y.clone().into_iter(); | ++++++++ ```
``` error[E0507]: cannot move out of `f`, a captured variable in an `FnMut` closure --> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13 | LL | let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| { | ----- captured outer variable ... LL | f(Box::new(|a| { | --- captured by this `FnMut` closure LL | LL | foo(f); | ^ move occurs because `f` has type `{closure@$DIR/borrowck-call-is-borrow-issue-12224.rs:52:17: 52:58}`, which does not implement the `Copy` trait ``` instead of ``` error[E0507]: cannot move out of `f`, a captured variable in an `FnMut` closure --> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13 | LL | let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| { | _________-----___- | | | | | captured outer variable LL | | let _ = s.len(); LL | | }; | |_____- move occurs because `f` has type `{closure@$DIR/borrowck-call-is-borrow-issue-12224.rs:52:17: 52:58}`, which does not implement the `Copy` trait LL | f(Box::new(|a| { | --- captured by this `FnMut` closure LL | LL | foo(f); | ^ `f` is moved here ```
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.
We lost the following comment during refactorings: The current code for niche-filling relies on variant indices instead of actual discriminants, so enums with explicit discriminants (RFC 2363) would misbehave.
Use `Scope::Module` with the crate root module inside instead, which should be identical.
Suggest clone in user-write-code instead of inside macro Fixes rust-lang#139253 Inspired by rust-lang#142543 r? ````@fmease````
…n-display, r=davidtwco 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 rust-lang/backtrace-rs#286 and rust-lang#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 rust-lang#71706. The next steps after this step involves extending and hardening that test further.
clippy fix: rely on autoderef Changes instances of `&**self` to `self`.
… r=scottmcm Update core::mem::copy documentation Update the documentation of `core::mem::copy` to include a `const` on the definition of the function.
…nkov 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.
…lcnr 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 ```
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.
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#144326
…eyouxu 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````
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 rust-lang#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`
…parrowLii 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
rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine` Part of rust-lang#119174 . I think we should be good now to sync this change in rustc_public.
@bors r+ rollup=never p=5 |
☀️ Test successful - checks-actions |
📌 Perf builds for each rolled up PR:
previous master: b56aaec52b In the case of a perf regression, run the following command for each PR you suspect might be the cause: |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing b56aaec (parent) -> a955f1c (this PR) Test differencesShow 33 test diffsStage 1
Stage 2
Additionally, 30 doctest diffs were found. These are ignored, as they are noisy. Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard a955f1cd09a027363729ceed919952d09f76f28e --output-dir test-dashboard And then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
Finished benchmarking commit (a955f1c): comparison URL. Overall result: ❌✅ regressions and improvements - no action needed@rustbot label: -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -2.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -2.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%, secondary 0.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 469.891s -> 467.355s (-0.54%) |
Successful merges:
Clone
values moved into closures #144200 (Tweak output for non-Clone
values moved into closures)assume
s in transmutes when one is a subset of the other #144209 (Don't emit twoassume
s in transmutes when one is a subset of the other)tests/ui/SUMMARY.md
and update rustc dev guide onerror-pattern
#144340 (UI test suite clarity changes: Renametests/ui/SUMMARY.md
and update rustc dev guide onerror-pattern
)Scope::CrateRoot
#144368 (resolve: RemoveScope::CrateRoot
)RigidTy/AggregateKind::Coroutine
#144392 (rustc_public: Remove movability fromRigidTy/AggregateKind::Coroutine
)r? @ghost
@rustbot modify labels: rollup
Create a similar rollup