-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Insufficiently clear explanation of E0310 #54753
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 / regionsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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.
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 / regionsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The following program (Playground):
errors with
From reading the explanation of
E0310, which only mentions the situation in whichTis used behind a static reference, e.g.,foo: &'static T, I really had no idea what was going on. It seems that other people have had similar issues with this (e.g. https://stackoverflow.com/questions/40053550/the-compiler-suggests-i-add-a-static-lifetime-because-the-parameter-type-may-no ).The explanation of E0310 should be improved to make it more clear why
T: 'staticis necessary, and what alternatives are there.What confused me most is that
Twas not used in any reference type of the example above, but it was only used behind a reference in the example of the error message explanation.