-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Confusing error messages when invariant type is involved #26804
Copy link
Copy link
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-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.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-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.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.
Reproducer
Original now malfunctioning reproducer from 2015
Playpen: http://is.gd/f1SPdn
Compiler Output
Original compiler output from 2015
This is confusing, since the compiler seems to demand that
sis valid in the line before it is declared (the only difference between the regions is that the first one includes thefn main() {). It is never mentioned that this is caused bySbeing invariant on'a, which disallows rustc to enlarge the lifetime to include the whole block.I think rustc should give a better error is this case (maybe something like
note: cannot extend lifetime of `s` since its type `S` is invariant with respect to `'a`).