Commit Graph

321431 Commits

Author SHA1 Message Date
bors e52f547ed4 Auto merge of #154160 - JonathanBrouwer:rollup-4jbkEbt, r=JonathanBrouwer
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#154154 (Emit fewer errors for incorrect rtn and `=` -> `:` typos in bindings)
 - rust-lang/rust#154155 (tests/ui/async-await/drop-option-future.rs: New regression test)
 - rust-lang/rust#146961 (Allow passing `expr` metavariable as `cfg` predicate)
 - rust-lang/rust#154118 (don't suggest non-deriveable traits for unions)
 - rust-lang/rust#154120 (Start migrating `DecorateDiagCompat::Builtin` items to `DecorateDiagCompat::Dynamic`)
 - rust-lang/rust#154156 (Moving issue-52049 to borrowck)
2026-03-21 07:20:47 +00:00
bors 44e662074f Auto merge of #154148 - weihanglo:update-cargo, r=weihanglo
Update cargo submodule

14 commits in cbb9bb8bd0fb272b1be0d63a010701ecb3d1d6d3..e84cb639edfea2c42efd563b72a9be0cc5de6523
2026-03-13 14:34:16 +0000 to 2026-03-21 01:27:07 +0000
- Fix symlink_and_directory when running in a long target dir name (rust-lang/cargo#16775)
- cargo clean: Validate that target_dir is not a file  (rust-lang/cargo#16765)
- fix: fetching non-standard git refspecs on non-github repos (rust-lang/cargo#16768)
- Update tar to 0.4.45 (rust-lang/cargo#16771)
- chore: Remove edition_lint_opts from Lint (rust-lang/cargo#16762)
- refactor: split out several smaller changes to prepare for async http (rust-lang/cargo#16763)
- fix(compile): Make build.warnings ignore non-local deps (rust-lang/cargo#16760)
- fix: detect circular publish dependency cycle in workspace publish (rust-lang/cargo#16722)
- refactor(shell): Pull out term integration into `anstyle-progress` (rust-lang/cargo#16757)
- test: reproduce rustfix panic on overlapping suggestions (rust-lang/cargo#16705)
- fix: Avoid panic for package specs with an empty fragment (rust-lang/cargo#16754)
- refactor(registry): avoid dynamic dispatch for Registry trait (rust-lang/cargo#16752)
- refactor(shell): Pull out hyperlink logic into anstyle-hyperlink (rust-lang/cargo#16749)
- refactor(install): Remove dead code (rust-lang/cargo#16718)
2026-03-21 04:11:42 +00:00
Weihang Lo 01ea06bfd3 Update cargo submodule 2026-03-20 23:05:00 -04:00
Jonathan Brouwer 6d2a545c09 Rollup merge of #154156 - aryannrd:move-issue-52049-to-borrowck, r=Kivooeo
Moving issue-52049 to borrowck
2026-03-21 00:42:49 +01:00
Jonathan Brouwer 84cb74ad9a Rollup merge of #154120 - GuillaumeGomez:migrate-diag, r=JonathanBrouwer
Start migrating `DecorateDiagCompat::Builtin` items to `DecorateDiagCompat::Dynamic`

Part of https://github.com/rust-lang/rust/issues/153099.

End goal being to completely remove the two steps currently required by `DecorateDiagCompat::Builtin` and remove duplicated types.

r? @JonathanBrouwer
2026-03-21 00:42:48 +01:00
Jonathan Brouwer 70d1c586ce Rollup merge of #154118 - malezjaa:dont-suggest-some-traits-for-unions, r=JonathanBrouwer
don't suggest non-deriveable traits for unions

Fixes rust-lang/rust#137587

Before, the compiler suggested adding `#[derive(Debug)]` (other traits too) for unions,
which is misleading because some traits can't be automatically derived.

Only traits that are still suggested are Copy and Clone.

I noticed the error label changed after removing the suggestion. I hope this isn't a big deal, but let me know if that's an issue.

original example:
```rs
union Union {
    member: usize,
}

impl PartialEq<u8> for Union {
    fn eq(&self, rhs: &u8) -> bool {
        unsafe { self.member == (*rhs).into() }
    }
}

fn main() {
    assert_eq!(Union { member: 0 }, 0);
}
```

before:
```
error[E0277]: `Union` doesn't implement `Debug`
  --> src\main.rs:13:5
   |
13 |     assert_eq!(Union { member: 0 }, 0);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `Union`
   |
   = note: add `#[derive(Debug)]` to `Union` or manually `impl Debug for Union`
   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider annotating `Union` with `#[derive(Debug)]`
   |
 2 + #[derive(Debug)]
 3 | union Union {
   |
```

after (the message doesn't suggest adding #[derive(Debug)] to unions)
```
error[E0277]: `Union` doesn't implement `Debug`
  --> src\main.rs:13:5
   |
13 |     assert_eq!(Union { member: 0 }, 0);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
   |
help: the trait `Debug` is not implemented for `Union`
  --> src\main.rs:2:1
   |
 2 | union Union {
   | ^^^^^^^^^^^
   = note: manually `impl Debug for Union`
```
2026-03-21 00:42:48 +01:00
Jonathan Brouwer b9f8e25f6e Rollup merge of #146961 - Jules-Bertholet:expr-cfg, r=JonathanBrouwer
Allow passing `expr` metavariable as `cfg` predicate

This PR allows expanding `expr` metavariables inside the configuration predicates of `cfg` and `cfg_attr` invocations.
For example, the following code will now compile:

```rust
macro_rules! mac {
    ($e:expr) => {
        #[cfg_attr($e, inline)]
        #[cfg($e)]
        fn func() {}

        #[cfg(not($e))]
        fn func() {
            panic!()
        }
    }
}

mac!(any(unix, feature = "foo"));
```

There is currently no `macro_rules` fragment specifier that can represent all valid `cfg` predicates. `meta` comes closest, but excludes `true` and `false`. By fixing that, this change makes it easier to write declarative macros that parse `cfg` or `cfg_attr` invocations, for example https://github.com/rust-lang/rust/pull/146281/.

@rustbot label T-lang needs-fcp A-attributes A-cfg A-macros
2026-03-21 00:42:47 +01:00
Jonathan Brouwer 6a7aaf97b5 Rollup merge of #154155 - Enselic:async-test, r=mati865
tests/ui/async-await/drop-option-future.rs: New regression test

The test began compiling with `nightly-2022-11-25`. I bisected it further, and the commit that made it compile was 9f36f988ad (rust-lang/rust#104321). The test fails to compile with `nightly-2022-11-24`:

    $ rustc +nightly-2022-11-24 --edition 2018 tests/ui/async-await/drop-option-future.rs
    error[E0597]: `value` does not live long enough
      --> tests/ui/async-await/drop-option-future.rs:12:22
       |
    12 |     f = Some(async { value });
       |                    --^^^^^--
       |                    | |
       |                    | borrowed value does not live long enough
       |                    value captured here by generator
    13 |     core::mem::drop(f);
    14 | }
       | -
       | |
       | `value` dropped here while still borrowed
       | borrow might be used here, when `f` is dropped and runs the destructor for type `Option<impl Future<Output = i32>>`

The fix 9f36f988ad does not appear to affect or include a regression test for the rust-lang/rust#98077 case, so let's add that test.

Closes rust-lang/rust#98077 since we add the test from that issue.
2026-03-21 00:42:47 +01:00
Jonathan Brouwer edf808b524 Rollup merge of #154154 - estebank:issue-134087, r=mati865
Emit fewer errors for incorrect rtn and `=` -> `:` typos in bindings

Make all existing `:` -> `=` typo suggestions verbose and tweak the suggested code.

Stash parse errors when pasing rtn that doesn't use `(..)`.

Emit single error on `Foo::bar(qux)` that looks like rtn in incorrect position and suggest `Foo::bar(..)`.
```
error: return type notation not allowed in this position yet
  --> $DIR/let-binding-init-expr-as-ty.rs:18:10
   |
LL | struct K(S::new(()));
   |          ^^^^^^^^^^
   |
help: furthermore, argument types not allowed with return type notation
   |
LL - struct K(S::new(()));
LL + struct K(S::new(..));
   |
```
On incorrect rtn in let binding type for an existing inherent associated function, suggest `:` -> `=` to turn the "type" into a call expression. (Fix rust-lang/rust#134087)
```
error: expected type, found associated function call
  --> $DIR/let-binding-init-expr-as-ty.rs:29:12
   |
LL |     let x: S::new(());
   |            ^^^^^^^^^^
   |
help: use `=` if you meant to assign
   |
LL -     let x: S::new(());
LL +     let x = S::new(());
   |
```
2026-03-21 00:42:46 +01:00
Jules Bertholet ab36d506d2 Address review comments 2026-03-20 18:48:38 -04:00
malezjaa 27212bb09d Don't suggest non-deriveable traits for unions.
Don't suggest non-deriveable traits for unions. This also adds enum, struct and union markers to rustc_on_unimplemented
2026-03-20 23:39:28 +01:00
bors 9e0a42c7ab Auto merge of #154151 - JonathanBrouwer:rollup-qLQ5uET, r=JonathanBrouwer
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#153828 (Guard patterns: lowering to THIR)
 - rust-lang/rust#154015 (refactor - moving `check_stability` check to `parse_stability`)
 - rust-lang/rust#154119 (llvm: Update `reliable_f128` configuration for LLVM22 on Sparc)
 - rust-lang/rust#154138 (vec::Drain::fill: avoid reference to uninitialized memory)
 - rust-lang/rust#154143 (test copy_specializes_from_vecdeque: reduce iteration count for Miri)
2026-03-20 21:32:02 +00:00
Aryan Dubey 1eeba934ae Added the issue link and a test description for non-promotable-static-ref.rs 2026-03-20 16:55:28 -04:00
Aryan Dubey a3409fecfa Move issue-52049 to tests/ui/borrowck 2026-03-20 16:49:33 -04:00
Martin Nordholts e897b4ea51 tests/ui/async-await/drop-option-future.rs: New regression test
The test began compiling with `nightly-2022-11-25`, and more
specifically 9f36f988ad. The test fails to compile with
`nightly-2022-11-24`:

    $ rustc +nightly-2022-11-24 --edition 2018 tests/ui/async-await/drop-option-future.rs
    error[E0597]: `value` does not live long enough
      --> tests/ui/async-await/drop-option-future.rs:12:22
       |
    12 |     f = Some(async { value });
       |                    --^^^^^--
       |                    | |
       |                    | borrowed value does not live long enough
       |                    value captured here by generator
    13 |     core::mem::drop(f);
    14 | }
       | -
       | |
       | `value` dropped here while still borrowed
       | borrow might be used here, when `f` is dropped and runs the destructor for type `Option<impl Future<Output = i32>>`

The fix 9f36f988ad does not appear to affect or include a
regression test for our issue, so let's add that test.
2026-03-20 21:09:32 +01:00
Esteban Küber 3b27a36601 Suggest appropriate spaces around = in let binding parse error 2026-03-20 19:45:29 +00:00
Esteban Küber d48e699b6c Emit fewer errors for incorrect rtn and = -> : typos in bindings
Stash parse errors when pasing rtn that doesn't use `(..)`.
Emit single error on `Foo::bar(qux)` that looks like rtn in incorrect position and suggest `Foo::bar(..)`.
```
error: return type notation not allowed in this position yet
  --> $DIR/let-binding-init-expr-as-ty.rs:18:10
   |
LL | struct K(S::new(()));
   |          ^^^^^^^^^^
   |
help: furthermore, argument types not allowed with return type notation
   |
LL - struct K(S::new(()));
LL + struct K(S::new(..));
   |
```
On incorrect rtn in let binding type for an existing inherent associated function, suggest `:` -> `=` to turn the "type" into a call expression.
```
error: expected type, found associated function call
  --> $DIR/let-binding-init-expr-as-ty.rs:29:12
   |
LL |     let x: S::new(());
   |            ^^^^^^^^^^
   |
help: use `=` if you meant to assign
   |
LL -     let x: S::new(());
LL +     let x = S::new(());
   |
```
2026-03-20 19:33:05 +00:00
Esteban Küber 244322f0be Make : -> = typo suggestion verbose 2026-03-20 19:07:28 +00:00
Jonathan Brouwer 80faf6f746 Rollup merge of #154143 - RalfJung:miri-test, r=joboet
test copy_specializes_from_vecdeque: reduce iteration count for Miri

This test currently takes >20s and that doesn't really seem worth it.
2026-03-20 19:36:22 +01:00
Jonathan Brouwer c745d58502 Rollup merge of #154138 - RalfJung:vec-slice-uninit, r=joboet
vec::Drain::fill: avoid reference to uninitialized memory

`range_slice` points to memory that is not initialized (e.g. it might be dropped `Box`/`String`). Let's avoid that and instead use an index-based loop.
2026-03-20 19:36:22 +01:00
Jonathan Brouwer 8f79cbc307 Rollup merge of #154119 - tgross35:f128-sparc, r=cuviper
llvm: Update `reliable_f128` configuration for LLVM22 on Sparc

LLVM22 should have resolved issues with the `f128` ABI, meaning we can now set `cfg(target_has_reliable_f128)` on the platform.

Link: https://github.com/llvm/llvm-project/commit/3e16aef2a650a8c2da4ebd5c58c6a9e261361828
2026-03-20 19:36:21 +01:00
Jonathan Brouwer 7ba136f71b Rollup merge of #154015 - josetorrs:refactor-parse-stability, r=JonathanBrouwer
refactor - moving `check_stability` check to `parse_stability`

This PR is part of issue https://github.com/rust-lang/rust/issues/153101 and by extension this https://github.com/rust-lang/rust/issues/131229 as well

r? @JonathanBrouwer
2026-03-20 19:36:21 +01:00
Jonathan Brouwer d8b5b46b3f Rollup merge of #153828 - Human9000-bit:guard-patterns-thir, r=Nadrieril
Guard patterns: lowering to THIR

This pr implements lowering of guard patterns to THIR

r? @Nadrieril

cc @max-niederman

Tracking issue: rust-lang/rust#129967
2026-03-20 19:36:20 +01:00
bors ac7f9ec7da Auto merge of #151746 - jdonszelmann:eagerly-normalize-in-generalize, r=lcnr
Eagerly normalize in generalize

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/151746)*

r? @lcnr 

cc: https://github.com/rust-lang/trait-system-refactor-initiative/issues/262
2026-03-20 18:22:43 +00:00
Jose Torres 3ea7d1ece7 fixing seperate empty arm and doc comment 2026-03-20 14:03:14 -04:00
Jose 4e446d55a4 restore code comment 2026-03-20 14:03:14 -04:00
Jose c614e3d216 linting, moving error to session diagnostics 2026-03-20 14:03:12 -04:00
Jose ed6a6fddb4 refactoring stability check 2026-03-20 14:01:13 -04:00
Guillaume Gomez 0e3e647e2e Remove BuiltinDiag usage in rustc_parse 2026-03-20 17:43:18 +01:00
Guillaume Gomez bb689c41aa Create new ParseSess::dyn_buffer_lint method 2026-03-20 17:25:50 +01:00
Guillaume Gomez 9c591c6508 Start migrating DecorateDiagCompat::Builtin items to DecorateDiagCompat::Dynamic 2026-03-20 17:25:12 +01:00
Ralf Jung 9dfdb6b4bc test copy_specializes_from_vecdeque: reduce iteration count for Miri 2026-03-20 15:55:56 +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
Jana Dönszelmann d665c0b371 address review 2026-03-20 14:02:24 +01:00
Jonathan Brouwer e106b584bd Rollup merge of #154126 - JayanAXHF:refactor/custom_mir_parser, r=JonathanBrouwer
refactor(attribute parser): move check_custom_mir to attribute parser

Part of rust-lang/rust#153101

r? @JonathanBrouwer
2026-03-20 13:24:27 +01: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 8a30071e7c Rollup merge of #153776 - zetanumbers:curry-howard-dyn-thread-safe, r=JonathanBrouwer
Remove redundant `is_dyn_thread_safe` checks

Refactor uses of `FromDyn` to reduce number of redundant `is_dyn_thread_safe` checks by replacing `FromDyn::from` with `check_dyn_thread_safe` in tandem with existing `FromDyn::derive` so that the users would avoid redundancy in the future.

PR is split up into multiple commits for an easier review.
2026-03-20 13:24:24 +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
Jonathan Brouwer c82d8db4a8 Rollup merge of #154103 - tgross35:float-test-mod, r=folkertdev
coretests: Expand ieee754 parsing and printing tests to f16

Use `float_test!` to cover all types, with a note about f128 missing the traits. Also includes some minor reorganization.
2026-03-20 13:24:21 +01:00
Ralf Jung 43eb70ac97 vec::Drain::fill: avoid reference to uninitialized memory 2026-03-20 13:24:11 +01:00
JayanAXHF 5aeb2a6c45 refactor(attribute parser): move check_custom_mir to attribute parser 2026-03-20 17:28:01 +05:30
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 ff9a99d8d8 Rollup merge of #154082 - spirali:fix-derive-where, r=lqd
Updates derive_where and removes workaround

Updates dependency on `derive-where` that fixes issue https://github.com/ModProg/derive-where/issues/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
2026-03-20 15:33:08 +11:00
Stuart Cook 3cabafea67 Rollup merge of #154075 - nnethercote:rewrite-query_ensure_result, 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
2026-03-20 15:33:08 +11:00