-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
fmease
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.