Rollup of 9 pull requests#154102
Closed
JonathanBrouwer wants to merge 20 commits intorust-lang:mainfrom
Closed
Conversation
…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`.
Contributor
Author
|
@bors r+ rollup=never p=5 |
Contributor
Contributor
Author
|
Trying commonly failed jobs |
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
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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)
Contributor
Author
|
@bors yield |
Contributor
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #154092. |
Contributor
This comment has been minimized.
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)
Contributor
|
💔 Test for 185535d failed: CI. Failed job:
|
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Contributor
Author
|
@bors retry |
Contributor
|
This pull request was unapproved due to being closed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Successful merges:
implrestriction lowering #153556 (implrestriction lowering)must_not_suspendtest forMutexGuarddropped beforeawait#154059 (tests: Activatemust_not_suspendtest forMutexGuarddropped beforeawait)query_ensure_result. #154075 (Rewritequery_ensure_result.)selfin use tree pretty printing #154084 (Preserve braces aroundselfin use tree pretty printing).in pretty printer #154086 (Insert space after float literal ending with.in pretty printer)r? @ghost
Create a similar rollup