Skip to content

Rollup of 9 pull requests#154102

Closed
JonathanBrouwer wants to merge 20 commits intorust-lang:mainfrom
JonathanBrouwer:rollup-IJPWkxR
Closed

Rollup of 9 pull requests#154102
JonathanBrouwer wants to merge 20 commits intorust-lang:mainfrom
JonathanBrouwer:rollup-IJPWkxR

Conversation

@JonathanBrouwer
Copy link
Contributor

Successful merges:

r? @ghost

Create a similar rollup

cyrgani and others added 20 commits March 17, 2026 09:27
…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>
…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
… 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.
…ivooeo

Insert space after float literal ending with `.` in pretty printer

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.

## Example

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

```rust
#![feature(prelude_import)]
#![no_std]
extern crate std;
#[prelude_import]
use ::std::prelude::rust_2015::*;
//@ pp-exact

fn main() {
    let _ = 0...45.;
    let _ = 0...=360.;
    let _ = 0...;
    let _ = 0..to_string();
}
```

**after** (this branch):

```rust
#![feature(prelude_import)]
#![no_std]
extern crate std;
#[prelude_import]
use ::std::prelude::rust_2015::*;
//@ pp-exact

fn main() {
    let _ = 0. ..45.;
    let _ = 0. ..=360.;
    let _ = 0. ..;
    let _ = 0. .to_string();
}
```

Notice `0...45.` (ambiguous — looks like deprecated `...` inclusive range) becomes `0. ..45.` (clear: float `0.` followed by range `..`). Similarly `0..to_string()` (parsed as range) becomes `0. .to_string()` (method call on float).
…space, r=Kivooeo

Fix whitespace after fragment specifiers in macro pretty printing

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.

## Example

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

```rust
#![feature(prelude_import)]
#![no_std]
extern crate std;
#[prelude_import]
use ::std::prelude::rust_2015::*;
//@ pretty-mode:expanded
//@ pp-exact:macro-fragment-specifier-whitespace.pp

// Test that fragment specifier names in macro definitions are properly
// separated from the following keyword/identifier token when pretty-printed.
// This is a regression test for a bug where `$x:ident` followed by `where`
// was pretty-printed as `$x:identwhere` (an invalid fragment specifier).

macro_rules! outer {
    ($d:tt $($params:tt)*) =>
    {
        #[macro_export] macro_rules! inner
        { ($($params)* where $d($rest:tt)*) => {}; }
    };
}
#[macro_export]
macro_rules! inner { ($x:identwhere $ ($rest : tt)*) => {}; }

fn main() {}
```

**after** (this branch):

```rust
#![feature(prelude_import)]
#![no_std]
extern crate std;
#[prelude_import]
use ::std::prelude::rust_2015::*;
//@ pretty-mode:expanded
//@ pp-exact:macro-fragment-specifier-whitespace.pp

// Test that fragment specifier names in macro definitions are properly
// separated from the following keyword/identifier token when pretty-printed.
// This is a regression test for a bug where `$x:ident` followed by `where`
// was pretty-printed as `$x:identwhere` (an invalid fragment specifier).

macro_rules! outer {
    ($d:tt $($params:tt)*) =>
    {
        #[macro_export] macro_rules! inner
        { ($($params)* where $d($rest:tt)*) => {}; }
    };
}
#[macro_export]
macro_rules! inner { ($x:ident where $ ($rest : tt)*) => {}; }

fn main() {}
```

Notice the `$x:identwhere` in the before — an invalid fragment specifier that causes a hard parse error. The after correctly separates it as `$x:ident where`.
@rust-bors rust-bors bot added the rollup A PR which is a rollup label Mar 19, 2026
@rustbot rustbot added A-tidy Area: The tidy tool S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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. labels Mar 19, 2026
@JonathanBrouwer
Copy link
Contributor Author

@bors r+ rollup=never p=5

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 19, 2026

📌 Commit 6f3b14a has been approved by JonathanBrouwer

It is now in the queue for this repository.

@JonathanBrouwer
Copy link
Contributor Author

Trying commonly failed jobs
@bors try jobs=test-various,x86_64-gnu-aux,x86_64-gnu-llvm-21-3,x86_64-msvc-1,aarch64-apple,x86_64-mingw-1

@rust-bors rust-bors bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 19, 2026
@rust-bors rust-bors bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 19, 2026
rust-bors bot pushed a commit that referenced this pull request Mar 19, 2026
Rollup of 9 pull requests


try-job: test-various
try-job: x86_64-gnu-aux
try-job: x86_64-gnu-llvm-21-3
try-job: x86_64-msvc-1
try-job: aarch64-apple
try-job: x86_64-mingw-1
@rust-bors

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 19, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #153556 (`impl` restriction lowering)
 - #153992 (bootstrap: Optionally print a backtrace if a command fails)
 - #154019 (two smaller feature cleanups)
 - #154059 (tests: Activate `must_not_suspend` test for `MutexGuard` dropped before `await`)
 - #154075 (Rewrite `query_ensure_result`.)
 - #154082 (Updates derive_where and removes workaround)
 - #154084 (Preserve braces around `self` in use tree pretty printing)
 - #154086 (Insert space after float literal ending with `.` in pretty printer)
 - #154087 (Fix whitespace after fragment specifiers in macro pretty printing)
@JonathanBrouwer
Copy link
Contributor Author

@bors yield

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 19, 2026

Auto build was cancelled. Cancelled workflows:

The next pull request likely to be tested is #154092.

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 19, 2026

☀️ Try build successful (CI)
Build commit: ff095ca (ff095cab03d3e4a84507a419248108303c7bedaf, parent: 1f7f8ea0721a3b1eb73e6c6d25cccb371434b320)

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 19, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #153556 (`impl` restriction lowering)
 - #153992 (bootstrap: Optionally print a backtrace if a command fails)
 - #154019 (two smaller feature cleanups)
 - #154059 (tests: Activate `must_not_suspend` test for `MutexGuard` dropped before `await`)
 - #154075 (Rewrite `query_ensure_result`.)
 - #154082 (Updates derive_where and removes workaround)
 - #154084 (Preserve braces around `self` in use tree pretty printing)
 - #154086 (Insert space after float literal ending with `.` in pretty printer)
 - #154087 (Fix whitespace after fragment specifiers in macro pretty printing)
@rust-bors rust-bors bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 19, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 19, 2026

💔 Test for 185535d failed: CI. Failed job:

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] rustc_hash test:false 0.041
[RUSTC-TIMING] similar test:false 1.264
   Compiling tidy v0.1.0 (/checkout/src/tools/tidy)

Session terminated, killing shell...::group::Clock drift check
  local time: Thu Mar 19 21:25:00 UTC 2026
##[error]The runner has received a shutdown signal. This can happen when the runner service is stopped, or a manually started runner is canceled.
  network time: Thu, 19 Mar 2026 21:25:00 GMT
##[endgroup]
 ...killed.

@JonathanBrouwer
Copy link
Contributor Author

@bors retry
Yet another certified github moment

@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 19, 2026
@rust-bors rust-bors bot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 19, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 19, 2026

This pull request was unapproved due to being closed.

@rust-bors rust-bors bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tidy Area: The tidy tool rollup A PR which is a rollup S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants