Can't return reference to passed-in referent that is assigned in a loop #97901
Labels
A-borrow-checker
Area: The borrow checker
A-control-flow
Area: Control flow
A-NLL
Area: Non-lexical lifetimes (NLL)
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.
I tried this code:
I expected to see this happen: it compiles and runs
Instead, this happened: it fails to compile with the error:
It's worth noting that the code builds fine if the
break
is unconditional.Even though the reproduction is somewhat different, this feels related to #92984
Meta
Happens on 1.61.0 stable, beta, and nightly.
Nightly Rust version from playground:
Hard mode
If you're looking for test cases, may also be worth including this one, which "launders" the lifetime through a
for<'a>
:The text was updated successfully, but these errors were encountered: