-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Unhelpful error on implicit 'static lifetime for dyn Trait #85170
Copy link
Copy link
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsT-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.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsT-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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Given the following code:
The current output is:
I initially thought, that the error refers to the reference.
At least I don't see the lifetime to the connection to the
dyn Traitmissing a lifetime, therefore the selected lifetime is'static. The fix is to add another lifetime:Ideally an output would contain something mentioning the lifetime of the trait and not of the
&mut-reference.