Open
Description
Code
fn a(_: dyn Trait + 'r#fn) {
}
trait Trait {}
Current output
error[E0261]: use of undeclared lifetime name `'fn`
--> src/lib.rs:1:21
|
1 | fn a(_: dyn Trait + 'r#fn) {
| ^^^^^ undeclared lifetime
|
help: consider introducing lifetime `'fn` here
|
1 | fn a<'fn>(_: dyn Trait + 'r#fn) {
| +++++
Desired output
error[E0261]: use of undeclared lifetime name `'r#fn`
--> src/lib.rs:1:21
|
1 | fn a(_: dyn Trait + 'r#fn) {
| ^^^^^ undeclared lifetime
|
help: consider introducing lifetime `'r#fn` here
|
1 | fn a<'r#fn>(_: dyn Trait + 'r#fn) {
| +++++++
Rationale and extra context
'fn
, as the diagnostic currently suggests, is not a valid lifetime.
it is my understanding that for non-reserved lifetimes, something like 'r#a
is supposed to be equivalent to 'a
, and that the diagnostic would be correct, were it not for the fact that in this case the r#
is mandatory or else it's a syntax error.
Rust Version
rustc 1.90.0-nightly (bdaba05a9 2025-06-27)
binary: rustc
commit-hash: bdaba05a953eb5abeba0011cdda2560d157aed2e
commit-date: 2025-06-27
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7