-
-
Notifications
You must be signed in to change notification settings - Fork 15k
NLL migrate mode erroneously downgrades error with nested closures, yielding use-after-free #58776
Copy link
Copy link
Closed
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessNLL-soundWorking towards the "invalid code does not compile" goalWorking towards the "invalid code does not compile" goalP-highHigh priorityHigh priorityT-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-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessNLL-soundWorking towards the "invalid code does not compile" goalWorking towards the "invalid code does not compile" goalP-highHigh priorityHigh priorityT-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 code compiles with the 2018 edition on stable, beta and nightly, and produces this error:
Code:
And indeed there's a use-after-free here.
Interestingly, in the 2015 edition this is correctly detected as incorrect, though the error is not quite what I would have expected:
I would have expected a complaint at the re-assignment of
greeting.(I found this while modifying an example by @stjepang and failing to reproduce some code that gets a migration warning on 2018...)