Rollup merge of #148561 - chenyukang:yukang-fix-148488, r=lqd

Fix ICE from async closure variance

Fixes rust-lang/rust#148488

The fix is also a change from rust-lang/rust#148556
This commit is contained in:
Matthias Krüger
2025-11-06 12:30:00 +01:00
committed by GitHub
3 changed files with 39 additions and 0 deletions
@@ -698,6 +698,7 @@ fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
}
Closure(..)
| CoroutineClosure(..)
| FnDef(..)
| Infer(..)
| Coroutine(..)
@@ -0,0 +1,12 @@
//@ edition: 2024
struct T<'g>();
//~^ ERROR lifetime parameter `'g` is never used
fn ord<a>() -> _ {
//~^ WARN type parameter `a` should have an upper camel case name
//~| ERROR the placeholder `_` is not allowed within types on item signatures for return types
async || {}
}
fn main() {}
@@ -0,0 +1,26 @@
warning: type parameter `a` should have an upper camel case name
--> $DIR/ice-async-closure-variance-issue-148488.rs:6:8
|
LL | fn ord<a>() -> _ {
| ^ help: convert the identifier to upper camel case: `A`
|
= note: `#[warn(non_camel_case_types)]` (part of `#[warn(nonstandard_style)]`) on by default
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
--> $DIR/ice-async-closure-variance-issue-148488.rs:6:16
|
LL | fn ord<a>() -> _ {
| ^ not allowed in type signatures
error[E0392]: lifetime parameter `'g` is never used
--> $DIR/ice-async-closure-variance-issue-148488.rs:3:10
|
LL | struct T<'g>();
| ^^ unused lifetime parameter
|
= help: consider removing `'g`, referring to it in a field, or using a marker such as `PhantomData`
error: aborting due to 2 previous errors; 1 warning emitted
Some errors have detailed explanations: E0121, E0392.
For more information about an error, try `rustc --explain E0121`.