diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2017-08-22 15:54:57 +0200 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2017-09-13 12:55:03 +0200 |
| commit | 25aa86da17a0a96767eb1bf30198973d5f2fd702 (patch) | |
| tree | da1a18058e80b7d6c8bab7dccf7f38ec6cf94fc3 | |
| parent | c3eccc694c4721c0bfaf3dcddd572e36c62e8fa1 (diff) | |
| download | rust-25aa86da17a0a96767eb1bf30198973d5f2fd702.tar.gz rust-25aa86da17a0a96767eb1bf30198973d5f2fd702.zip | |
Fix issue #43481: emit the EndRegion *before* StorageDeads for a scope.
(The idea is that the StorageDead marks the point where the memory can be deallocated, and the EndRegion is marking where borrows of that memory can no longer legally exist.)
| -rw-r--r-- | src/librustc_mir/build/scope.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index c08620c1e41..bac884b4d01 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -352,6 +352,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } let scope = self.scopes.pop().unwrap(); assert_eq!(scope.region_scope, region_scope.0); + + self.cfg.push_end_region(self.hir.tcx(), block, region_scope.1, scope.region_scope); unpack!(block = build_scope_drops(&mut self.cfg, &scope, &self.scopes, @@ -359,7 +361,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { self.arg_count, false)); - self.cfg.push_end_region(self.hir.tcx(), block, region_scope.1, scope.region_scope); block.unit() } @@ -406,15 +407,16 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { scope.cached_exits.insert((target, region_scope.0), b); b }; + + // End all regions for scopes out of which we are breaking. + self.cfg.push_end_region(self.hir.tcx(), block, region_scope.1, scope.region_scope); + unpack!(block = build_scope_drops(&mut self.cfg, scope, rest, block, self.arg_count, false)); - - // End all regions for scopes out of which we are breaking. - self.cfg.push_end_region(self.hir.tcx(), block, region_scope.1, scope.region_scope); } } let scope = &self.scopes[len - scope_count]; |
