Skip to content

Rollup of 15 pull requests#154123

Merged
rust-bors[bot] merged 33 commits intorust-lang:mainfrom
Zalathar:rollup-MUEvgV7
Mar 20, 2026
Merged

Rollup of 15 pull requests#154123
rust-bors[bot] merged 33 commits intorust-lang:mainfrom
Zalathar:rollup-MUEvgV7

Conversation

@Zalathar
Copy link
Member

Successful merges:

r? @ghost

Create a similar rollup

davidtwco and others added 30 commits March 10, 2026 12:37
`-Zbranch-protection` only makes sense if the entire crate graph has
the option set, otherwise the security properties that branch protection
provides won't be effective. This flag is unstable so I don't think this
warrants an MCP.
This might be helpful for smart pointers to explains why they aren't Copy
and what to do instead or just to let the user know that .clone() is very
cheap and can be called without a performance penalty.
…wait

The test pass in `nightly-2023-09-24` but fail in `nightly-2023-09-23`:

    $ rustc +nightly-2023-09-23 --edition 2018 tests/ui/lint/must_not_suspend/mutex-guard-dropped-before-await.rs
    error: `MutexGuard` held across a suspend point, but should not be
      --> tests/ui/lint/must_not_suspend/mutex-guard-dropped-before-await.rs:13:9
       |
    13 |     let lock = foo.lock().unwrap();
       |         ^^^^
    ...
    18 |     bar().await;
       |           ----- the value is held across this suspend point
       |
It currently uses chaining which is concise but hard to read. There are
up to four implicit matches occurring after the call to
`execute_query_fn`.
- The first `map` on `Option<Erased<Result<T, ErrorGuaranteed>>>`.
- The second `map` on `Option<Result<T, ErrorGuaranteed>>`.
- The third `map` on `Result<T, ErrorGuaranteed>`.
- The `unwrap_or` on `Option<Result<(), ErrorGuaranteed>>`.

This commit rewrites it to use at most two matches.
- An explicit match on `Option<Erased<Result<T, ErrorGuaranteed>>>`.
- An explicit match on `Result<T, ErrorGuaranteed>`.

This is easier to read. It's also more efficient, though the code isn't
hot enough for that to matter.
The AST pretty printer strips braces from single-item `use` sub-groups,
simplifying `use foo::{Bar}` to `use foo::Bar`. However, when the single
item is `self`, this produces `use foo::self` which is not valid Rust
(E0429) — the grammar requires `use foo::{self}`.

This affects both `stringify!` and `rustc -Zunpretty=expanded`, causing
`cargo expand` output to be unparseable when a crate uses `use
path::{self}` imports (a common pattern in the ecosystem).

The fix checks whether the single nested item's path starts with `self`
before stripping braces. If so, the braces are preserved.

Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
When a macro-generating-macro captures fragment specifier tokens (like
`$x:ident`) as `tt` metavariables and replays them before a keyword
(like `where`), the pretty printer concatenates them into an invalid
fragment specifier (e.g. `$x:identwhere` instead of `$x:ident where`).

This happens because `tt` captures preserve the original token spacing.
When the fragment specifier name (e.g. `ident`) was originally the last
token before a closing delimiter, it retains `JointHidden` spacing. The
`print_tts` function only checks `space_between` for `Spacing::Alone`
tokens, so `JointHidden` tokens skip the space check entirely, causing
adjacent identifier-like tokens to merge.

The fix adds a check in `print_tts` to insert a space between adjacent
identifier-like tokens (identifiers and keywords) regardless of the
original spacing, preventing them from being concatenated into invalid
tokens.

This is similar to the existing `space_between` mechanism that prevents
token merging for `Spacing::Alone` tokens, extended to also handle
`Joint`/`JointHidden` cases where two identifier-like tokens would merge.

Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
The pretty printer was collapsing unsuffixed float literals (like `0.`)
with adjacent dot tokens, producing ambiguous or invalid output:

- `0. ..45.` (range) became `0...45.`
- `0. ..=360.` (inclusive range) became `0...=360.`
- `0. .to_string()` (method call) became `0..to_string()`

The fix inserts a space after an unsuffixed float literal ending with
`.` when it appears as the start expression of a range operator or the
receiver of a method call or field access, preventing the trailing dot
from merging with the following `.`, `..`, or `..=` token. This is
skipped when the expression is already parenthesized, since the closing
`)` naturally provides separation.

Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
I suspect the original code had several issues. The last one that made
the code compile entered `nightly-2024-02-11`. The code fails to build
with `nightly-2024-02-10`:

    $ rustc +nightly-2024-02-10 --edition 2018 tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs
    error[E0277]: expected a `FnOnce(&u8)` closure, found `{coroutine-closure@tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9: 31:30}`
      --> tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9
       |
    31 |     foo(async move | f: &u8 | { *f });
       |     --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(&u8)` closure, found `{coroutine-closure@tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs:31:9: 31:30}`
       |     |
       |     required by a bound introduced by this call
       |

(Note that you must add `#![feature(async_closure)]` to test with such
old nightlies, since they are from before stabilization of async
closures.)

This was probably fixed by 3bb384a.
…-modifier, r=jackh726

sess: `-Zbranch-protection` is a target modifier

`-Zbranch-protection` only makes sense if the entire crate graph has the option set, otherwise the security properties that branch protection provides won't be effective - hence a target modifier. This flag is unstable so I don't think this warrants an MCP.
…wering, r=petrochenkov

`impl` restriction lowering

This PR is linked to a [GSoC proposal](https://github.com/rust-lang/google-summer-of-code?tab=readme-ov-file#implementing-impl-and-mut-restrictions) and is part of the progress toward implementing `impl` restrictions proposed in [RFC 3323](https://rust-lang.github.io/rfcs/3323-restrictions.html).
This PR implements path resolution for `impl` restrictions. The resolution is performed in `rustc_resolve/src/late.rs` using `smart_resolve_path`.
This PR also checks whether the restricted module or crate is an ancestor. If it is not, it emits a restriction-specific counterpart to visibility’s `AncestorOnly` error.

r? @Urgau
cc @jhpratt
…amples-improvement, r=lolbinarycat

Don't emit rustdoc `missing_doc_code_examples` lint on impl items

@lolbinarycat realized in [this comment](rust-lang#153964 (comment)) that we weren't testing some cases for the `missing_doc_code_examples` lint. Turns out that it was not handling this case well. =D

So in short: `missing_doc_code_examples` lint should not be emitted on impl items and this PR fixes that.

r? @lolbinarycat
…_for_smart_pointers, r=JonathanBrouwer

Introduce #[diagnostic::on_move(message)]

cc rust-lang#149862

This is a first proposal. I have deliberately kept it simpler than `diagnostic::on_unimplemented`.

Few questions/remarks:

- Do I need to move the OnMoveDirective logic into a dedicated module perhaps ? let's say into compiler/rustc_borrowck/src/diagnostics/on_move.rs
- No problems to depend on crates like `rustc_ast` from the borrowck ?
- Notes are not supported yet. While message and label are very static , in the sense that they are emitted in the same way from the same place in the borrowck, it is not the case for the notes. It would make the code more complex. But, I can add support for notes if it does make sense.

Suggestions are welcomed !
…uwer

remove -Csoft-float

This fixes rust-lang#129893 by removing the offending flag.

The flag has been added in pre-1.0 times (rust-lang#9617) without much discussion, probably with the intent to mirror `-msoft-float` in C compilers. It never properly mirrored clang though because it only affected the LLVM float ABI setting, not the "soft-float" target feature (the clang flag sets both). It is also blatantly unsound because it affects how float arguments are passed, making it UB to invoke parts of the standard library.

The flag got deprecated with Rust 1.83 (released November 2024), and in the year since then, nobody spoke up in rust-lang#129893 to have it preserved. I think it is time to remove it. I can totally imagine us bringing back a similar flag, properly registered as a target modifier to preserve soundness, but that should come with a coherent design that works for more than one architecture (the flag only does anything on ARM).

Blocked on approval of rust-lang/compiler-team#971.
Fixes rust-lang#154106
Rename `cycle_check` to `find_cycle`

This renames `cycle_check` to `find_cycle` as that fits a bit better.
… r=jieyouxu,kobzol

bootstrap: Optionally print a backtrace if a command fails

I found this quite useful for debugging why a command was failing eagerly (it turns out that `.delay_failure()` is ignored if `fail_fast` is enabled).
two smaller feature cleanups

Remove an unneeded feature gate for a private macro and sort the used features correctly by whether they are language or library features.
…ooeo

tests: Activate `must_not_suspend` test for `MutexGuard` dropped before `await`

After bisect it turns out that the test passes in `nightly-2023-09-24` but fails in `nightly-2023-09-23`:

    $ rustc +nightly-2023-09-23 --edition 2018 tests/ui/lint/must_not_suspend/mutex-guard-dropped-before-await.rs
    error: `MutexGuard` held across a suspend point, but should not be
      --> tests/ui/lint/must_not_suspend/mutex-guard-dropped-before-await.rs:13:9
       |
    13 |     let lock = foo.lock().unwrap();
       |         ^^^^
    ...
    18 |     bar().await;
       |           ----- the value is held across this suspend point
       |

That leaves us with

<details>
<summary>git log e4133ba..13e6f24 --no-merges --oneline </summary>

bffb346 Make test more robust to opts.
44ac8dc Remove GeneratorWitness and rename GeneratorWitnessMIR.
855a75b Remove useless wrapper.
baa64b0 Remove dead error code.
6aa1268 Bless clippy.
d989e14 Bless mir-opt
211d2ed Bless tests.
286502c Enable drop_tracking_mir by default.
a626caa Revert duplication of tests.
ff03204 Fold lifetimes before substitution.
9450b75 Do not construct def_path_str for MustNotSuspend.
58ef3a0 diagnostics: simpler 83556 handling by bailing out
79d6853 Check types live across yields in generators too
c21867f Check that closure's by-value captures are sized
d3dea30 Point at cause of expectation of `break` value when possible
4ed4913 Merge `ExternProviders` into the general `Providers` struct
2ba911c Have a single struct for queries and hook
9090ed8 Fix test on targets with crt-static default
5db9a5e Update cargo
9defc97 Add tracing instrumentation, just like queries automatically add it
2157f31 Add a way to decouple the implementation and the declaration of a TyCtxt method.
d5ec9af Add test to guard against VecDeque optimization regression
3799af3 diagnostics: avoid mismatch between variance index and hir generic
34c248d compiletest: load supports-xray from target spec
64e27cb compiletest: load supported sanitizers from target spec
bc7bb3c compiletest: use builder pattern to construct Config in tests

</details>

of which 286502c (rust-lang#107421) seems most likely. I can't find an existing test except the "inactive" one, so let's simply activate it.

Closes rust-lang#89562 which is where the activated test comes from. The test was originally added in rust-lang#89826.

Tracking issue:
- rust-lang#83310
…esult, r=Zalathar

Rewrite `query_ensure_result`.

It currently uses chaining which is concise but hard to read. There are up to four implicit matches occurring after the call to `execute_query_fn`.
- The first `map` on `Option<Erased<Result<T, ErrorGuaranteed>>>`.
- The second `map` on `Option<Result<T, ErrorGuaranteed>>`.
- The third `map` on `Result<T, ErrorGuaranteed>`.
- The `unwrap_or` on `Option<Result<(), ErrorGuaranteed>>`.

This commit rewrites it to use at most two matches.
- An explicit match on `Option<Erased<Result<T, ErrorGuaranteed>>>`.
- An explicit match on `Result<T, ErrorGuaranteed>`.

This is easier to read. It's also more efficient, though the code isn't hot enough for that to matter.

r? @Zalathar
Updates derive_where and removes workaround

Updates dependency on `derive-where` that fixes issue ModProg/derive-where#136 and removes the following workaround:

```
// FIXME(derive-where#136): Need to use separate `derive_where` for
// `Copy` and `Ord` to prevent the emitted `Clone` and `PartialOrd`
// impls from incorrectly relying on `T: Copy` and `T: Ord`.
```

r? lcnr
Preserve braces around `self` in use tree pretty printing

The AST pretty printer strips braces from single-item `use` sub-groups, simplifying `use foo::{Bar}` to `use foo::Bar`. However, when the single item is `self`, this produces `use foo::self` which is not valid Rust (E0429) — the grammar requires `use foo::{self}`.

This affects both `stringify!` and `rustc -Zunpretty=expanded`, causing `cargo expand` output to be unparseable when a crate uses `use path::{self}` imports (a common pattern in the ecosystem).

The fix checks whether the single nested item's path starts with `self` before stripping braces. If so, the braces are preserved.

## Example

**before** (`rustc 1.96.0-nightly (3b1b0ef 2026-03-11)`):

```rust
#![feature(prelude_import)]
//@ pp-exact
//@ edition:2021

#![allow(unused_imports)]
extern crate std;
#[prelude_import]
use std::prelude::rust_2021::*;

// Braces around `self` must be preserved, because `use foo::self` is not valid Rust.
use std::io::self;
use std::fmt::{self, Debug};

fn main() {}
```

**after** (this branch):

```rust
#![feature(prelude_import)]
//@ pp-exact
//@ edition:2021

#![allow(unused_imports)]
extern crate std;
#[prelude_import]
use std::prelude::rust_2021::*;

// Braces around `self` must be preserved, because `use foo::self` is not valid Rust.
use std::io::{self};
use std::fmt::{self, Debug};

fn main() {}
```

Notice the `use std::io::self` (invalid, E0429) in the before becomes `use std::io::{self}` in the after.
@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Mar 20, 2026
@Zalathar
Copy link
Member Author

Rollup of everything.

@bors r+ rollup=never p=5

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 20, 2026

📌 Commit ffe94f0 has been approved by Zalathar

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 20, 2026
@Zalathar
Copy link
Member Author

@bors try jobs=dist-x86_64-msvc

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 20, 2026
Rollup of 15 pull requests


try-job: dist-x86_64-msvc
@rust-bors

This comment has been minimized.

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 20, 2026

☀️ Try build successful (CI)
Build commit: bc19af2 (bc19af28f109e4072838e03cb09e658e06d027df, parent: bcf3d36c997dd9b5db4bb7f40cb91dd4cf46a305)

@rust-bors rust-bors bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 20, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 20, 2026

☀️ Test successful - CI
Approved by: Zalathar
Duration: 3h 32m 34s
Pushing 86c839f to main...

@rust-bors rust-bors bot merged commit 86c839f into rust-lang:main Mar 20, 2026
13 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 20, 2026
@github-actions
Copy link
Contributor

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 76be1cc (parent) -> 86c839f (this PR)

Test differences

Show 174 test diffs

Stage 1

  • [pretty] tests/pretty/float-trailing-dot.rs: [missing] -> pass (J1)
  • [pretty] tests/pretty/macro-fragment-specifier-whitespace.rs: [missing] -> pass (J1)
  • [pretty] tests/pretty/use-self-braces.rs: [missing] -> pass (J1)
  • [ui] tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs: [missing] -> pass (J1)
  • [ui] tests/ui/diagnostic_namespace/on_move/error_is_shown_in_downstream_crates.rs: [missing] -> pass (J1)
  • [ui] tests/ui/diagnostic_namespace/on_move/on_move_simple.rs: [missing] -> pass (J1)
  • [ui] tests/ui/diagnostic_namespace/on_move/on_move_with_format.rs: [missing] -> pass (J1)
  • [ui] tests/ui/diagnostic_namespace/on_move/report_warning_on_duplicated_options.rs: [missing] -> pass (J1)
  • [ui] tests/ui/diagnostic_namespace/on_move/report_warning_on_invalid_formats.rs: [missing] -> pass (J1)
  • [ui] tests/ui/diagnostic_namespace/on_move/report_warning_on_invalid_meta_item_syntax.rs: [missing] -> pass (J1)
  • [ui] tests/ui/diagnostic_namespace/on_move/report_warning_on_malformed_options_without_delimiters.rs: [missing] -> pass (J1)
  • [ui] tests/ui/diagnostic_namespace/on_move/report_warning_on_malformed_options_without_literals.rs: [missing] -> pass (J1)
  • [ui] tests/ui/diagnostic_namespace/on_move/report_warning_on_missing_options.rs: [missing] -> pass (J1)
  • [ui] tests/ui/diagnostic_namespace/on_move/report_warning_on_non_adt.rs: [missing] -> pass (J1)
  • [ui] tests/ui/diagnostic_namespace/on_move/report_warning_on_unknown_options.rs: [missing] -> pass (J1)
  • [ui] tests/ui/feature-gates/feature-gate-diagnostic-on-move.rs: [missing] -> pass (J1)
  • [ui] tests/ui/impl-restriction/restriction_resolution_errors.rs: [missing] -> pass (J1)
  • [ui] tests/ui/lint/must_not_suspend/issue-89562.rs: pass -> [missing] (J1)
  • [ui] tests/ui/lint/must_not_suspend/mutex-guard-dropped-before-await.rs: [missing] -> pass (J1)

Stage 2

  • [ui] tests/ui/async-await/async-closures/unifying-function-types-involving-hrtb.rs: [missing] -> pass (J0)
  • [ui] tests/ui/diagnostic_namespace/on_move/error_is_shown_in_downstream_crates.rs: [missing] -> pass (J0)
  • [ui] tests/ui/diagnostic_namespace/on_move/on_move_simple.rs: [missing] -> pass (J0)
  • [ui] tests/ui/diagnostic_namespace/on_move/on_move_with_format.rs: [missing] -> pass (J0)
  • [ui] tests/ui/diagnostic_namespace/on_move/report_warning_on_duplicated_options.rs: [missing] -> pass (J0)
  • [ui] tests/ui/diagnostic_namespace/on_move/report_warning_on_invalid_formats.rs: [missing] -> pass (J0)
  • [ui] tests/ui/diagnostic_namespace/on_move/report_warning_on_invalid_meta_item_syntax.rs: [missing] -> pass (J0)
  • [ui] tests/ui/diagnostic_namespace/on_move/report_warning_on_malformed_options_without_delimiters.rs: [missing] -> pass (J0)
  • [ui] tests/ui/diagnostic_namespace/on_move/report_warning_on_malformed_options_without_literals.rs: [missing] -> pass (J0)
  • [ui] tests/ui/diagnostic_namespace/on_move/report_warning_on_missing_options.rs: [missing] -> pass (J0)
  • [ui] tests/ui/diagnostic_namespace/on_move/report_warning_on_non_adt.rs: [missing] -> pass (J0)
  • [ui] tests/ui/diagnostic_namespace/on_move/report_warning_on_unknown_options.rs: [missing] -> pass (J0)
  • [ui] tests/ui/feature-gates/feature-gate-diagnostic-on-move.rs: [missing] -> pass (J0)
  • [ui] tests/ui/impl-restriction/restriction_resolution_errors.rs: [missing] -> pass (J0)
  • [ui] tests/ui/lint/must_not_suspend/issue-89562.rs: pass -> [missing] (J0)
  • [ui] tests/ui/lint/must_not_suspend/mutex-guard-dropped-before-await.rs: [missing] -> pass (J0)
  • [pretty] tests/pretty/float-trailing-dot.rs: [missing] -> pass (J2)
  • [pretty] tests/pretty/macro-fragment-specifier-whitespace.rs: [missing] -> pass (J2)
  • [pretty] tests/pretty/use-self-braces.rs: [missing] -> pass (J2)

Additionally, 136 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 86c839ffb36d0e21405dee5ab38e3f85c5b63699 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. aarch64-apple: 2h 33m -> 3h 27m (+34.9%)
  2. x86_64-gnu-llvm-22-2: 1h 39m -> 1h 28m (-11.0%)
  3. dist-aarch64-apple: 1h 44m -> 1h 55m (+10.8%)
  4. aarch64-msvc-2: 2h -> 1h 47m (-10.7%)
  5. x86_64-msvc-ext1: 2h 16m -> 2h 3m (-9.3%)
  6. x86_64-gnu-llvm-22-3: 1h 58m -> 1h 49m (-8.3%)
  7. x86_64-gnu: 2h 20m -> 2h 8m (-8.0%)
  8. dist-arm-linux-gnueabi: 1h 21m -> 1h 26m (+7.0%)
  9. dist-powerpc-linux: 1h 26m -> 1h 32m (+6.8%)
  10. i686-gnu-1: 2h 12m -> 2h 22m (+6.8%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (86c839f): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (secondary 4.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.2% [4.2%, 4.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (primary 2.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.1% [2.1%, 2.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.1% [2.1%, 2.1%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 481.595s -> 491.123s (1.98%)
Artifact size: 396.86 MiB -> 396.86 MiB (-0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) A-run-make Area: port run-make Makefiles to rmake.rs A-tidy Area: The tidy tool merged-by-bors This PR was explicitly merged by bors. rollup A PR which is a rollup T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.