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.)
This commit is contained in:
parent
c3eccc694c
commit
25aa86da17
1 changed files with 6 additions and 4 deletions
|
|
@ -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];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue