Commit Graph

24363 Commits

Author SHA1 Message Date
Martin Nordholts aed54f219e tests/ui/async-await/gat-is-send-across-await.rs: New regression test
The test began passing in `nightly-2025-10-16`. Probably by c50aebba78
because it fixed two "does not live long enough" errors. The test fails
to compile with `nightly-2025-10-15` with such an error:

    $ rustc +nightly-2025-10-15 --edition 2018 tests/ui/async-await/gat-is-send-across-await.rs
    error: `impl G` does not live long enough
      --> tests/ui/async-await/gat-is-send-across-await.rs:16:24
       |
    16 |       let _: &dyn Send = &async move {
       |  ________________________^
    17 | |         let _gat = g.as_gat();
    18 | |         async{}.await
    19 | |     };
       | |_____^
2026-03-21 16:42:02 +01:00
bors bfc05d6b07 Auto merge of #154137 - JonathanBrouwer:rollup-hTMxxjl, r=JonathanBrouwer
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#154103 (coretests: Expand ieee754 parsing and printing tests to f16)
 - rust-lang/rust#152669 (rustc_public: add `vtable_entries()` to `TraitRef`)
 - rust-lang/rust#153776 (Remove redundant `is_dyn_thread_safe` checks)
 - rust-lang/rust#154121 (Fix typos and markdown errors)
 - rust-lang/rust#154126 (refactor(attribute parser): move check_custom_mir to attribute parser)
2026-03-20 14:18:58 +00:00
Jonathan Brouwer c6cfacae68 Rollup merge of #154121 - teor2345:typos-md-03-20, r=jdonszelmann
Fix typos and markdown errors

This PR fixes some typos and markdown errors I found while writing rust-lang/rust#153697.

I've split it out to reduce the size of that PR.
2026-03-20 13:24:26 +01:00
Jonathan Brouwer 65f1783a5f Rollup merge of #152669 - makai410:rpub-vtable, r=celinval
rustc_public: add `vtable_entries()` to `TraitRef`

Resolves: https://github.com/rust-lang/project-stable-mir/issues/103
2026-03-20 13:24:22 +01:00
bors 461e9738a4 Auto merge of #153489 - aerooneqq:two-phase-hir, r=petrochenkov
ty-aware delayed AST -> HIR lowering



This PR implements a prototype of ty-aware delayed AST -> HIR lowering. Part of rust-lang/rust#118212.

r? @petrochenkov

# Motivation

When lowering delegation in perfect scenario we would like to access the ty-level information, in particular, queries like `generics_of`, `type_of`, `fn_sig` for proper HIR generation with less hacks. For example, we do not want to generate more lifetimes than needed, because without ty-level queries we do not know which delegee's lifetimes are late-bound. Next, consider recursive delegations, for their proper support without ty we would have to either duplicate generics inheritance code in AST -> HIR lowering or create stubs for parts of the HIR and materialize them later. We already use those queries when interacting with external crates, however when dealing with compilation of a local crate we should use resolver for similar purposes. Finally, access to ty-level queries is expected to help supporting delegation to inherent impls, as we can not resolve such calls during AST -> HIR stage.

# Benefits

We eliminate almost all code that uses resolver in delegation lowering:
- Attributes inheritance is done without copying attributes from AST at resolve stage
- Fn signatures are obtained from `tcx.fn_sig`
- Param counts are also obtained from `tcx.fn_sig`
- `is_method` function now uses `tcx.associated_item` instead of resolver
- Generics are now inherited through `get_external_generics` that uses `tcx.generics_of`. Generics for recursive delegations should also work
- `DelegationIds` that stored paths for recursive delegations is removed, we now use only `delegee_id`
- Structs that were used for storing delegation-related information in resolver are almost fully removed
- `ast_index` is no more used

# Next steps
- Remove creating generic params through AST cloning, proper const types propagation
- Inherent impls

# High level design overview

## Queries
We store ids of delayed items to lower in `Crate` struct. During first stage of lowering, owners that correspond to delayed items are filled with `MaybeOwner::Phantom`. 

Next, we define two new queries: `lower_delayed_owner`, `delayed_owner` and a function `force_delayed_owners_lowering`.

The first query is used when lowering known (which is in `delayed_ids`) delayed owner. 

The second is fed with children that were obtained during lowering of a delayed owner (note that the result of lowering of a single `LocalDefId` is not a single `MaybeOwner`, its a list of `(LocalDefId, MaybeOwner)` where the first `MaybeOwner` corresponds to delayed `LocalDefId` and others to children that were obtained during lowering (i.e. generic params)). By default `delayed_owner` returns `MaybeOwner::Phantom`. As we do not want to predict the whole list of children which will be obtained after lowering of a single delayed item, we need to store those children somewhere. There are several options:
- Make the return type of `lower_delayed_owner` to be `FxIndexMap<LocalDefId, MaybeOwner>` and search children here. Search will be either linear or we can introduce a map somewhere which will track parent-child relations between a single delayed `LocalDefId` and its children. 
- Try to make query that will lower all delayed items in a loop and return a complete map of all delayed `LocalDefIds` and their children. In this case there will be problems with delayed items that require information about other delayed items.

By using proposed queries we handle the second concern, and in case of acyclic dependencies between delayed ids it automatically works, moreover we use queries as cache for delayed `MaybeOwners`. The only invariant here is that queries which are invoked during delayed AST -> HIR lowering of some `LocalDefId` should not in any way access children of other, yet unlowered, delayed `LocalDefId`, they should firstly materialize it.

The `force_delayed_owners_lowering` forces lowering of all delayed items and now integrated in `hir_crate_items` query. 

## Resolver for lowering

> ~Currently the `resolver_for_lowering` is stolen in `lower_to_hir` function, however we want to prolong its life until all delayed `LocalDefIds` are materialized. For this purpose we borrow `resolver_for_lowering` in `lower_to_hir` and drop it after forcing materialization of all delayed `LocalDefId` in `rustc_interface::run_required_analyses`.~

We split resolver for lowering into two parts: the first part is a readonly part that came to us from resolve, the second part is a mutable part that can be used to add or overwrite values in the readonly part. Such splitted resolver is used during delayed lowering, as we can't steal it.

## AST index

Lowering uses an AST index. It is created in `lower_to_hir` function and it references parts of AST. We want to avoid reindexing AST on every delayed `LocalDefId` lowering, however now it is not clear how to properly do it. As delayed HIR lowering is used only for delegation unstable feature it should not affect other use-cases of the compiler. But it will be reworked sooner or later.
2026-03-20 10:56:01 +00:00
aerooneqq 5c441e6ce6 ty-aware delayed AST -> HIR lowering 2026-03-20 12:31:48 +03:00
bors 86c839ffb3 Auto merge of #154123 - Zalathar:rollup-MUEvgV7, r=Zalathar
Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#152909 (sess: `-Zbranch-protection` is a target modifier)
 - rust-lang/rust#153556 (`impl` restriction lowering)
 - rust-lang/rust#154048 (Don't emit rustdoc `missing_doc_code_examples` lint on impl items)
 - rust-lang/rust#150935 (Introduce #[diagnostic::on_move(message)])
 - rust-lang/rust#152973 (remove -Csoft-float)
 - rust-lang/rust#153862 (Rename `cycle_check` to `find_cycle`)
 - rust-lang/rust#153992 (bootstrap: Optionally print a backtrace if a command fails)
 - rust-lang/rust#154019 (two smaller feature cleanups)
 - rust-lang/rust#154059 (tests: Activate `must_not_suspend` test for `MutexGuard` dropped before `await`)
 - rust-lang/rust#154075 (Rewrite `query_ensure_result`.)
 - rust-lang/rust#154082 (Updates derive_where and removes workaround)
 - rust-lang/rust#154084 (Preserve braces around `self` in use tree pretty printing)
 - rust-lang/rust#154086 (Insert space after float literal ending with `.` in pretty printer)
 - rust-lang/rust#154087 (Fix whitespace after fragment specifiers in macro pretty printing)
 - rust-lang/rust#154109 (tests: Add regression test for async closures involving HRTBs)
2026-03-20 07:22:03 +00:00
Stuart Cook ffe94f0bcb Rollup merge of #154109 - Enselic:unifying-function-types-involving-hrtb, r=jackh726
tests: Add regression test for async closures involving HRTBs

I suspect the original code from rust-lang/rust#59337 had several problems. The last problem fixed 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.)

So one of the following commits made the code build:

<details>

<summary>git log d44e3b95cb9d4..6cc4843512d613f  --no-merges --oneline</summary>

4def37386c manually bless an aarch64 test
04bc624ea0 rebless after rebase
77f8c3caea detect consts that reference extern statics
9c0623fe8f validation: descend from consts into statics
4e77e368eb unstably allow constants to refer to statics and read from immutable statics
a2479a4ae7 Remove unnecessary `min_specialization` after bootstrap
7b73e4fd44 Allow restricted trait impls in macros with `min_specialization`
e6f5af9671 Remove unused fn
fde695a2d1 Add a helpful suggestion
d7263d7aad Change wording
973bbfbd23 No more associated type bounds in dyn trait
cf1096eb72 Remove unnecessary `#![feature(min_specialization)]`
3d4a9f5047 Turn the "no saved object file in work product" ICE into a translatable fatal error
bb60ded24b Loosen an assertion to account for stashed errors.
69a5264a52 Move some tests
4ef1790b4e tidy
e59d9b171e Avoid a collection and iteration on empty passes
8b6b9c5efc ast_lowering: Fix regression in `use ::{}` imports.
83f3bc4271 Update jobserver-rs to 0.1.28
14e0dab96b Unify item relative path computation in one function
f3c24833c5 Add regression test for non local items link generation
f0d002b890 Correctly generate path for non-local items in source code pages
c94bbb24db Clarify that atomic and regular integers can differ in alignment
7057188c54 make it recursive
7a63d3f16a Add tests for untested capabilities
548929dc5e Don't unnecessarily lower associated type bounds to impl trait
22d582a38d For a rigid projection, recursively look at the self type's item bounds
540be28f6c sort suggestions for object diagnostic
9322882ade Add a couple more tests
3bb384aad6 Prefer AsyncFn* over Fn* for coroutine-closures
aa6f45eb79 Use `ensure` when the result of the query is not needed beyond its `Result`ness
8ff1994ec0 Fix whitespace issues that tidy caught
f0c6f5a7fe Add documentation on `str::starts_with`
63cc3c7b8f test `llvm_out` behaviour
7fb4512ee8 fix `llvm_out` to use the correct LLVM root
b8c93f1223 Coroutine closures implement regular Fn traits, when possible
08af64e96b Regular closures now built-in impls for AsyncFn*
0dd40786b5 Harmonize blanket implementations for AsyncFn* traits
f3d32f2f0c Flatten confirmation logic
9a819ab8f7 static mut: allow reference to arbitrary types, not just slices and arrays

</details>

This was probably fixed by 3bb384aad6 (https://github.com/rust-lang/rust/pull/120712). That PR does not have a big tests diff, so I assume the test we add does not exist elsewhere. It's hard to know for sure.

Closes rust-lang/rust#59337 since we add the test from that issue. In that issue there is a [proposal](https://github.com/rust-lang/rust/issues/59337#issuecomment-826441716) for two minimized versions, but they both fail to compile with `nightly-2024-02-11`, so those reproducers are for different problem(s).

### Tracking Issue
- https://github.com/rust-lang/rust/issues/62290
2026-03-20 15:33:10 +11:00
Stuart Cook a00818dfb4 Rollup merge of #154087 - aytey:fix-fragment-specifier-whitespace, 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 (3b1b0ef4d 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`.
2026-03-20 15:33:09 +11:00
Stuart Cook a98232dd93 Rollup merge of #154086 - aytey:fix-float-range-spacing, r=Kivooeo
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 (3b1b0ef4d 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).
2026-03-20 15:33:09 +11:00
Stuart Cook 870e43eae4 Rollup merge of #154084 - aytey:fix-use-self-braces, r=Kivooeo
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 (3b1b0ef4d 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.
2026-03-20 15:33:08 +11:00
Stuart Cook a194bea98d Rollup merge of #154059 - Enselic:dropped-mutex-guard, r=Kivooeo
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 e4133ba9b1a150..13e6f24b9adda67 --no-merges --oneline </summary>

bffb3467e1 Make test more robust to opts.
44ac8dcc71 Remove GeneratorWitness and rename GeneratorWitnessMIR.
855a75b6d6 Remove useless wrapper.
baa64b0e77 Remove dead error code.
6aa1268900 Bless clippy.
d989e14cf2 Bless mir-opt
211d2ed07b Bless tests.
286502c9ed Enable drop_tracking_mir by default.
a626caaad9 Revert duplication of tests.
ff03204365 Fold lifetimes before substitution.
9450b75986 Do not construct def_path_str for MustNotSuspend.
58ef3a0ec9 diagnostics: simpler 83556 handling by bailing out
79d685325c Check types live across yields in generators too
c21867f9f6 Check that closure's by-value captures are sized
d3dea30cb4 Point at cause of expectation of `break` value when possible
4ed4913e67 Merge `ExternProviders` into the general `Providers` struct
2ba911c832 Have a single struct for queries and hook
9090ed8119 Fix test on targets with crt-static default
5db9a5ee38 Update cargo
9defc971f1 Add tracing instrumentation, just like queries automatically add it
2157f31731 Add a way to decouple the implementation and the declaration of a TyCtxt method.
d5ec9af09d Add test to guard against VecDeque optimization regression
3799af3337 diagnostics: avoid mismatch between variance index and hir generic
34c248d31f compiletest: load supports-xray from target spec
64e27cb4d9 compiletest: load supported sanitizers from target spec
bc7bb3c8e7 compiletest: use builder pattern to construct Config in tests

</details>

of which 286502c9ed (https://github.com/rust-lang/rust/pull/107421) seems most likely. I can't find an existing test except the "inactive" one, so let's simply activate it.

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

Tracking issue:
- rust-lang/rust#83310
2026-03-20 15:33:07 +11:00
Stuart Cook 734cca0053 Rollup merge of #150935 - rperier:provide_diagnostic_on_move_for_smart_pointers, r=JonathanBrouwer
Introduce #[diagnostic::on_move(message)]

cc rust-lang/rust#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 !
2026-03-20 15:33:05 +11:00
Stuart Cook 319df85a09 Rollup merge of #154048 - GuillaumeGomez:missing_doc_code_examples-improvement, r=lolbinarycat
Don't emit rustdoc `missing_doc_code_examples` lint on impl items

@lolbinarycat realized in [this comment](https://github.com/rust-lang/rust/pull/153964#discussion_r2953956702) 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
2026-03-20 15:33:05 +11:00
Stuart Cook 85b8c32e7c Rollup merge of #153556 - CoCo-Japan-pan:impl-restriction-lowering, 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
2026-03-20 15:33:04 +11:00
Stuart Cook 845fd53500 Rollup merge of #152909 - davidtwco:branch-protection-target-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.
2026-03-20 15:33:04 +11:00
bors 76be1cc4ee Auto merge of #152913 - Unique-Usman:ua/constnottype, r=estebank
rustc_resolve: improve const generic errors
2026-03-20 04:12:22 +00:00
teor 65335b65fe Fix markdown warnings in ui/README.md 2026-03-20 11:22:54 +10:00
Martin Nordholts caad6ee240 tests: Add regression test for async closures involving HRTBs
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 3bb384aad6.
2026-03-19 19:25:34 +01:00
bors bcf3d36c99 Auto merge of #154092 - JonathanBrouwer:rollup-GKNFJe0, r=JonathanBrouwer
Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#152870 (Do not enable split debuginfo for windows-gnu)
 - rust-lang/rust#153333 (Fix bootstrap rust build failure for vxworks)
 - rust-lang/rust#153681 (ci: add runners for vanilla LLVM 22)
 - rust-lang/rust#153727 (When single impl can satisfy inference error, suggest type)
 - rust-lang/rust#153824 (Add `Wake` diagnostic item for `alloc::task::Wake`)
 - rust-lang/rust#154077 (Optimize 128-bit integer formatting)
 - rust-lang/rust#154078 (`define_callbacks` tweaks)
 - rust-lang/rust#151905 (Split the `dec2flt::RawFloat` trait for easier reuse)
 - rust-lang/rust#153170 (Add is_disconnected functions to mpsc and mpmc channels)
 - rust-lang/rust#153308 (Add hygiene annotations for tokens in `macro_rules!` bodies)
 - rust-lang/rust#153557 (fix inference variables leaking into HIR const literal lowering logic)
 - rust-lang/rust#153804 (Derive Macro Eq: link to more detailed documentation)
 - rust-lang/rust#153913 (Fix some suggestions of the `for-loops-over-fallibles` lint)
 - rust-lang/rust#153974 (Point at return type when it is the source of the type expectation)
 - rust-lang/rust#153987 (mGCA: Lower const generic args to infer when needed)
 - rust-lang/rust#154018 (simplify and remove `tests/ui/kindck` and related tests)
 - rust-lang/rust#154036 (borrowck/type_check: remove helper left-over from unsized locals)
 - rust-lang/rust#154038 (merge `regions-outlives-nominal-type-*` tests into one file)
 - rust-lang/rust#154041 (bootstrap: Allow `--bless`ing changes to editor settings files)
2026-03-19 18:03:58 +00:00
Jonathan Brouwer bd9ffabd3f Rollup merge of #154038 - cyrgani:regiontests, r=Kivooeo
merge `regions-outlives-nominal-type-*` tests into one file

This is easily done since each of the individual files was already wrapped in a `mod`. Also, this removes the unneeded `rustc_attrs` usage from the tests.
2026-03-19 13:42:41 +01:00
Jonathan Brouwer 94386a3eca Rollup merge of #154018 - cyrgani:kindck-tests, r=jieyouxu
simplify and remove `tests/ui/kindck` and related tests

kindck does not exist anymore since a long time now. This PR merges and deletes several redundant tests in that directory, reformats the rest and moves it to `ui/traits`.
2026-03-19 13:42:40 +01:00
Jonathan Brouwer dfba606b52 Rollup merge of #153987 - reddevilmidzy:mgca-ast, r=BoxyUwU
mGCA: Lower const generic args to infer when needed

close: rust-lang/rust#153198

r? BoxyUwU
2026-03-19 13:42:39 +01:00
Jonathan Brouwer db7db6238a Rollup merge of #153974 - estebank:issue-43608, r=nnethercote
Point at return type when it is the source of the type expectation

When calling an fn that returns a return type as a returned expression, point at the return type to explain that it affects the expected type.

```
error[E0308]: mismatched types
    --> f56.rs:5:15
     |
   3 | fn main() {
     |          - the call expression's return type is influenced by this return type
   4 |     let a = 0;
   5 |     ptr::read(&a)
     |     --------- ^^ expected `*const ()`, found `&{integer}`
     |     |
     |     arguments to this function are incorrect
     |
     = note: expected raw pointer `*const ()`
                  found reference `&{integer}`
note: function defined here
    --> library/core/src/ptr/mod.rs:1681:21
     |
1681 | pub const unsafe fn read<T>(src: *const T) -> T {
     |                     ^^^^
```

Fix rust-lang/rust#43608.
2026-03-19 13:42:38 +01:00
Jonathan Brouwer 0c78b9aa3a Rollup merge of #153913 - JohnTitor:issue-148814, r=Kivooeo
Fix some suggestions of the `for-loops-over-fallibles` lint

Fix https://github.com/rust-lang/rust/issues/148114
Fix rust-lang/rust#147973
Also address https://github.com/rust-lang/rust-clippy/issues/16133 which is another case of it
2026-03-19 13:42:37 +01:00
Jonathan Brouwer a3898aaeb3 Rollup merge of #153557 - Human9000-bit:issue-153525, r=BoxyUwU
fix inference variables leaking into HIR const literal lowering logic

Inference variables could leak into further const lowering logic

It ICEs when query system tries to cache `lit_to_const()` after its execution and panics, because inference variables are not hashable for some reason

Fixes rust-lang/rust#153524
Fixes rust-lang/rust#153525
2026-03-19 13:42:35 +01:00
Jonathan Brouwer e103550588 Rollup merge of #153308 - aytey:macro_meta_hygiene, r=jdonszelmann
Add hygiene annotations for tokens in `macro_rules!` bodies

`-Zunpretty=expanded,hygiene` was not printing syntax context annotations for identifiers and lifetimes inside `macro_rules!` bodies. These tokens are printed via `print_tt()` → `token_to_string_ext()`, which converts tokens to strings without calling `ann_post()`. This meant that macro-generated `macro_rules!` definitions with hygienic metavar parameters (e.g. multiple `$marg` distinguished only by hygiene) were printed with no way to tell them apart.

This was fixed by adding a match on `token.kind` in `print_tt()` to call `ann_post()` for `Ident`, `NtIdent`, `Lifetime`, and `NtLifetime` tokens, matching how `print_ident()` and `print_lifetime()` already handle AST-level identifiers and lifetimes.
2026-03-19 13:42:34 +01:00
bors 1f7f8ea072 Auto merge of #153869 - ShoyuVanilla:issue-153816, r=lcnr
Do not shallow resolve to root var while fudging



Fixes https://github.com/rust-lang/rust/issues/153816 and fixes https://github.com/rust-lang/rust/issues/153849

In https://github.com/rust-lang/rust/pull/151380, I thought that whether shallow resolve to root var or not wouldn't affect the actual type inferencing, but it isn't true for the fudge, in which we discard all newly created relationships between unresolved inference variables 😅

r? lcnr
2026-03-19 12:14:32 +00:00
Andrew V. Teylu e9740a4be5 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.

Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
2026-03-19 10:42:46 +00:00
Andrew V. Teylu c77768590d 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.

Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
2026-03-19 10:35:43 +00:00
Andrew V. Teylu 082cdf7c48 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.

Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
2026-03-19 10:34:45 +00:00
CoCo-Japan-pan 4a60dae793 Add UI tests for path resolution errors of impl restrictions 2026-03-19 19:05:31 +09:00
Usman Akinyemi f60b6499d8 rustc_resolve: improve const generic errors
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
2026-03-19 11:49:30 +05:30
Esteban Küber ca2139d326 Point at return type when it is the source of the type expectation
When calling an fn that returns a return type as a returned expression, point at the return type to explain that it affects the expected type.

```
error[E0308]: mismatched types
    --> f56.rs:5:15
     |
   3 | fn main() {
     |          - the call expression's return type is influenced by this return type
   4 |     let a = 0;
   5 |     ptr::read(&a)
     |     --------- ^^ expected `*const ()`, found `&{integer}`
     |     |
     |     arguments to this function are incorrect
     |
     = note: expected raw pointer `*const ()`
                  found reference `&{integer}`
note: function defined here
    --> library/core/src/ptr/mod.rs:1681:21
     |
1681 | pub const unsafe fn read<T>(src: *const T) -> T {
     |                     ^^^^
```
2026-03-18 23:42:20 +00:00
Martin Nordholts 45b22efe06 tests: Activate must_not_suspend test for MutexGuard dropped before await
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
       |
2026-03-18 21:36:11 +01:00
Esteban Küber 49bb371ca7 When single impl can satisfy inference error, suggest type
When encountering an inference error where a return type must be known, like when calling `Iterator::sum::<T>()` without specifying `T`, look for all `T` that would satisfy `Sum<S>`. If only one, suggest it.

```
error[E0283]: type annotations needed
  --> $DIR/cannot-infer-iterator-sum-return-type.rs:4:9
   |
LL |     let sum = v
   |         ^^^
...
LL |         .sum(); // `sum::<T>` needs `T` to be specified
   |          --- type must be known at this point
   |
   = note: cannot satisfy `_: Sum<i32>`
help: the trait `Sum` is implemented for `i32`
  --> $SRC_DIR/core/src/iter/traits/accum.rs:LL:COL
  ::: $SRC_DIR/core/src/iter/traits/accum.rs:LL:COL
   |
   = note: in this macro invocation
note: required by a bound in `std::iter::Iterator::sum`
  --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
   = note: this error originates in the macro `integer_sum_product` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider giving `sum` an explicit type, where the type for type parameter `S` is specified
   |
LL |     let sum: i32 = v
   |            +++++
```
2026-03-18 18:16:47 +00:00
Guillaume Gomez 6d3b7809cf Add more tests for rustdoc missing_doc_code_examples lint 2026-03-18 17:28:55 +01:00
Shoyu Vanilla b77739ad81 Do not shallow resolve to root var while fudging 2026-03-19 00:26:19 +09:00
bors 53d60bb1c5 Auto merge of #154039 - Zalathar:rollup-Emyd5AO, r=Zalathar
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#153580 (Handle statics and TLS in raw-dylib for ELF)
 - rust-lang/rust#154020 (Moved tests/ui/issues/issue-23891.rs to tests/ui/macros/)
 - rust-lang/rust#154028 (Rename trait `IntoQueryParam` to `IntoQueryKey`)
2026-03-18 11:10:07 +00:00
Stuart Cook 3cfde0efba Rollup merge of #154020 - aryannrd:move-issue-23891, r=JohnTitor
Moved tests/ui/issues/issue-23891.rs to tests/ui/macros/
2026-03-18 21:26:33 +11:00
Stuart Cook c0172a38cd Rollup merge of #153580 - mati865:elf-raw-dylib-static-and-tls, r=bjorn3
Handle statics and TLS in raw-dylib for ELF

Follow-up to https://github.com/rust-lang/rust/pull/153090
2026-03-18 21:26:32 +11:00
cyrgani 6b0fecf582 merge regions-outlives-nominal-type-* tests into one file 2026-03-18 09:37:35 +00:00
Stuart Cook 04e7f2f72e Rollup merge of #153677 - ConradIrwin:sanitary-string-panics, r=scottmcm
Remove string content from panics

String content can be useful for debugging panics, particularly when you are working on a small codebase where you can infer more about the path taken through your program based on the content of the string.

In production deployments that upload crashes for centralized debugging, string content poses a risk to user privacy. The string can accidentally contain information that the user is not expecting to share with the development team.

On balance it seems like the risks outweigh the benefits. It is easy to add a `dbg!()` statement to gather more information in development; but comparatively tricky to ensure panics are sanitized by every rust app that monitors their production deployments.

Ref https://internals.rust-lang.org/t/stop-including-string-content-in-index-panics/24067

r? @scottmcm
2026-03-18 18:37:35 +11:00
Stuart Cook 44c87292ac Rollup merge of #153778 - bjorn3:driver_cleanups, r=TaKO8Ki
Couple of driver interface improvements

* Pass Session to `make_codegen_backend` callback. This simplifies some code in miri.
* Move env/file_depinfo from ParseSess to Session. There is no reason it has to be in ParseSess rather than Session.
* Rename hash_untracked_state to track_state to indicate that it isn't just used for hashing state, but also for adding env vars and files to be tracked through the dep info file.
2026-03-18 15:07:31 +11:00
bors 91775dbec9 Auto merge of #154013 - JonathanBrouwer:rollup-J4887ML, r=JonathanBrouwer
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#152998 (std: make `OsString::truncate` a no-op when `len > current_len`)
 - rust-lang/rust#153682 (Tweak E0599 note)
 - rust-lang/rust#153795 (Point turbofish inference errors at the uninferred generic arg)
 - rust-lang/rust#153994 (move `tests/ui/invalid` tests to new folders)
 - rust-lang/rust#154006 (attrs: Ignore ExprKind::Err when converting path attr expr to lit)
 - rust-lang/rust#154012 (unstable impl of `From<{i64, u64}> for f128`)
2026-03-17 23:25:27 +00:00
Aryan Dubey fb885759e0 Added test description and a link to github page for the relevant issue to the test 2026-03-17 18:24:54 -04:00
Aryan Dubey a9838dd1ea Moved issue-23981 to tests/ui/macros 2026-03-17 18:16:09 -04:00
cyrgani eda328c6cf delete incorrect test 2026-03-17 22:08:51 +00:00
cyrgani 62b9fa15e7 move tests from ui/kindck to ui/traits 2026-03-17 22:02:05 +00:00
cyrgani caeda1869a reformat and update remaining ui/kindck tests 2026-03-17 21:49:58 +00:00