Borrow checker thinks variable lives longer than it actually lives #112087
Labels
A-borrow-checker
Area: The borrow checker
C-bug
Category: This is a bug.
fixed-by-polonius
Compiling with `-Zpolonius` fixes this issue.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
The borrow checker thinks that in the following code the variable
v
lives at least as long as*opt = None;
which is certainly not correct and is also fixed when swapping the two conditions on lines 2 and 3 . To test, here's a link to the rust playground.I tried this code:
I expected to see this happen: no compile error
Instead, this happened: compile error E0506
Meta
Bug also exists in beta and nightly
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: