Skip to content

Commit

Permalink
re-add the call to super_statement in EraseRegions
Browse files Browse the repository at this point in the history
The move gathering code is sensitive to type-equality - that is rather
un-robust and I plan to fix it eventually, but that's a more invasive
change. And we want to fix the visitor anyway.

Fixes rust-lang#42903.
  • Loading branch information
arielb1 committed Jun 28, 2017
1 parent f590a44 commit 71abfa7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/librustc_mir/transform/erase_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ impl<'a, 'tcx> MutVisitor<'tcx> for EraseRegionsVisitor<'a, 'tcx> {
}

fn visit_statement(&mut self,
_block: BasicBlock,
block: BasicBlock,
statement: &mut Statement<'tcx>,
_location: Location) {
location: Location) {
if let StatementKind::EndRegion(_) = statement.kind {
statement.kind = StatementKind::Nop;
}
self.super_statement(block, statement, location);
}
}

Expand Down
15 changes: 15 additions & 0 deletions src/test/run-pass/dynamic-drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ fn struct_dynamic_drop(a: &Allocator, c0: bool, c1: bool, c: bool) {
}
}

fn field_assignment(a: &Allocator, c0: bool) {
let mut x = (TwoPtrs(a.alloc(), a.alloc()), a.alloc());

x.1 = a.alloc();
x.1 = a.alloc();

let f = (x.0).0;
if c0 {
(x.0).0 = f;
}
}

fn assignment2(a: &Allocator, c0: bool, c1: bool) {
let mut _v = a.alloc();
let mut _w = a.alloc();
Expand Down Expand Up @@ -207,5 +219,8 @@ fn main() {
run_test(|a| struct_dynamic_drop(a, true, true, false));
run_test(|a| struct_dynamic_drop(a, true, true, true));

run_test(|a| field_assignment(a, false));
run_test(|a| field_assignment(a, true));

run_test_nopanic(|a| union1(a));
}

0 comments on commit 71abfa7

Please sign in to comment.