Open
Description
Code
trait Trait<'a> {}
fn foo<T: Trait<'static>() {}
Current output
error: `Fn` traits cannot take lifetime parameters
--> src/lib.rs:3:16
|
3 | fn foo<T: Trait<'static>() {}
| ^^^^^^^^^
|
help: consider using a higher-ranked trait bound instead
|
3 - fn foo<T: Trait<'static>() {}
3 + fn foo<T: for<'static> Trait() {}
|
error: expected one of `+`, `,`, `->`, `=`, or `>`, found `{`
--> src/lib.rs:3:28
|
3 | fn foo<T: Trait<'static>() {}
| ^ expected one of `+`, `,`, `->`, `=`, or `>`
|
help: you might have meant to end the type parameters here
|
3 | fn foo<T: Trait<'static>()> {}
| +
error: could not compile `playground` (lib) due to 2 previous errors
Desired output
Rationale and extra context
The first error is confusing and unhelpful. Maybe only suggest it when the trait is named Fn
/FnMut
/FnOnce
?
Also, the second error suggests adding the >
in the wrong place.
Other cases
Rust Version
Reproducible on the playground with rustc 1.89.0-nightly (2025-05-22 2eef47813f25df637026)
Anything else?
No response