Fix off-by-one when emitting StorageDead for vars

This commit is contained in:
Jonas Schievink 2016-09-26 22:16:35 +02:00
parent 393db2d830
commit e75feea696
2 changed files with 2 additions and 3 deletions

View file

@ -462,7 +462,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
} else {
// Only temps and vars need their storage dead.
match *lvalue {
Lvalue::Local(index) if index.index() > self.arg_count + 1 => DropKind::Storage,
Lvalue::Local(index) if index.index() > self.arg_count => DropKind::Storage,
_ => return
}
};

View file

@ -18,8 +18,6 @@ fn main() {
let c = 1;
}
// TODO The StorageDead for local1 (a) after local6's (c) is missing!
// END RUST SOURCE
// START rustc.node4.TypeckMir.before.mir
// bb0: {
@ -39,6 +37,7 @@ fn main() {
// local6 = const 1i32; // scope 1 at storage_ranges.rs:16:13: 16:14
// local0 = (); // scope 3 at storage_ranges.rs:11:11: 17:2
// StorageDead(local6); // scope 1 at storage_ranges.rs:16:9: 16:10
// StorageDead(local1); // scope 0 at storage_ranges.rs:14:9: 14:10
// goto -> bb1; // scope 0 at storage_ranges.rs:11:1: 17:2
// }
//