You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
multiple spurious errors when T: 'static is required in async fn #115376
asyncfntest<T>(_:&u8){let _:&'staticT;//~^ ERROR the parameter type `T` may not live long enough//~| ERROR the parameter type `T` may not live long enough}
Two errors are emitted: one requires T: 'static, as expected, and the other requires T: 'a where 'a is the anonymous lifetime.
This affects lifetime constraints that originate in async fn, async blocks, and closures.
An error is emitted for each lifetime that appears in the function because 'static is an upper bound for all lifetimes.
error[E0310]: the parameter type `T` may not live long enough
--> src/lib.rs:2:12
|
2 | let _:&'static T;
| ^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
help:consider adding an explicit lifetime bound...
|
1 | async fn test<T:'static>(_:&u8){
| +++++++++
error[E0311]: the parameter type `T` may not live long enough
--> src/lib.rs:2:12
|
2 | let _:&'static T;
| ^^^^^^^^^^
|
note: the parameter type `T` must be valid for the anonymous lifetime defined here...
--> src/lib.rs:1:21
|
1 | async fn test<T>(_:&u8){
| ^^^
note: ...so that the type `T` will meet its required lifetime bounds
--> src/lib.rs:2:12
|
2 | let _:&'static T;
| ^^^^^^^^^^
help: consider adding an explicit lifetime bound...
|
1 | async fn test<'a,T:'a>(_:&'a u8){
| +++ ++++ ++
Triage: To avoid any misunderstanding, would you mind elaborating on what output you expect to see, and not only what you actually see? Thanks!
Here is the current output:
$ rustc +nightly-2026-03-01 --crate-type lib /home/martin/src/lib.rs --edition 2021error[E0310]: the parameter type `T` may not live long enough --> /home/martin/src/lib.rs:2:12 |2 | let _: &'static T; | ^^^^^^^^^^ | | | the parameter type `T` must be valid for the static lifetime... | ...so that the type `T` will meet its required lifetime bounds |help: consider adding an explicit lifetime bound |1 | async fn test<T: 'static>(_: &u8) { | +++++++++error[E0311]: the parameter type `T` may not live long enough --> /home/martin/src/lib.rs:2:12 |1 | async fn test<T>(_: &u8) { | --- the parameter type `T` must be valid for the anonymous lifetime defined here...2 | let _: &'static T; | ^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds |help: consider adding an explicit lifetime bound |1 | async fn test<'a, T: 'a>(_: &'a u8) { | +++ ++++ ++error: aborting due to 2 previous errorsSome errors have detailed explanations: E0310, E0311.For more information about an error, try `rustc --explain E0310`.
Activity
Enselic commentedon Mar 25, 2026
Triage: To avoid any misunderstanding, would you mind elaborating on what output you expect to see, and not only what you actually see? Thanks!
Here is the current output:
Rollup merge of rust-lang#158153 - pbkx:issue-115376-async-spurious-s…
Rollup merge of rust-lang#158153 - pbkx:issue-115376-async-spurious-s…
Rollup merge of rust-lang#158153 - pbkx:issue-115376-async-spurious-s…
Unrolled build for #158153 in rollup 162434