Closed
Description
UPDATE: This is fixed by the MIR-based borrow checker and just needs a test. See the mentoring instructions below.
Currently, the borrow checker thinks that the RHS of +=
is evaluated before the LHS. trans thinks that the LHS is evaluated before the RHS. The disagreement leads to bad results.
fn main() {
let x = Box::new(0);
let mut y = 0;
*{ drop(x); &mut y } += *x;
assert_eq!(y, 0);
}
Metadata
Metadata
Assignees
Labels
Area: Non-lexical lifetimes (NLL)Area: The borrow checkerCategory: This is a bug.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessMedium priorityRelevant to the language team, which will review and decide on the PR/issue.Bugs fixed, but only when NLL is enabled.