-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Closed
Labels
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.
Description
It looks like that when a local variable is initialized in a loop and dropped in the same loop, the stack local drop flag for that local isn't reinitialized to "not dropped" when the loop runs after the first time.
Concretely, this test passes on stable and fails on nightly right now:
struct A<'a>(&'a mut i32);
impl<'a> Drop for A<'a> {
fn drop(&mut self) {
*self.0 += 1;
}
}
fn main() {
let mut cnt = 0;
for i in 0..2 {
let a = A(&mut cnt);
if i == 1 {
break
}
drop(a);
}
assert_eq!(cnt, 2);
}
cc @pnkfelix
Metadata
Metadata
Assignees
Labels
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.