Skip to content

Commit 1447daa

Browse files
committed
remove the span field from diverge_cleanup
1 parent 91aff57 commit 1447daa

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

src/librustc_mir/build/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
8686
let tcx = this.hir.tcx();
8787

8888
// Enter the remainder scope, i.e. the bindings' destruction scope.
89-
this.push_scope(remainder_scope);
89+
this.push_scope((remainder_scope, source_info));
9090
let_extent_stack.push(remainder_scope);
9191

9292
// Declare the bindings, which may create a visibility scope.

src/librustc_mir/build/expr/into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
237237
.collect();
238238

239239
let success = this.cfg.start_new_block();
240-
let cleanup = this.diverge_cleanup(expr_span);
240+
let cleanup = this.diverge_cleanup();
241241
this.cfg.terminate(block, source_info, TerminatorKind::Call {
242242
func: fun,
243243
args: args,

src/librustc_mir/build/matches/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
306306
let bool_ty = self.hir.bool_ty();
307307
let eq_result = self.temp(bool_ty, test.span);
308308
let eq_block = self.cfg.start_new_block();
309-
let cleanup = self.diverge_cleanup(test.span);
309+
let cleanup = self.diverge_cleanup();
310310
self.cfg.terminate(block, source_info, TerminatorKind::Call {
311311
func: Operand::Constant(box Constant {
312312
span: test.span,

src/librustc_mir/build/scope.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ pub struct Scope<'tcx> {
107107
/// the extent of this scope within source code.
108108
extent: CodeExtent,
109109

110+
/// the span of that extent
111+
extent_span: Span,
112+
110113
/// Whether there's anything to do for the cleanup path, that is,
111114
/// when unwinding through this scope. This includes destructors,
112115
/// but not StorageDead statements, which don't get emitted at all
@@ -116,7 +119,7 @@ pub struct Scope<'tcx> {
116119
/// * pollutting the cleanup MIR with StorageDead creates
117120
/// landing pads even though there's no actual destructors
118121
/// * freeing up stack space has no effect during unwinding
119-
pub(super) needs_cleanup: bool,
122+
needs_cleanup: bool,
120123

121124
/// set of lvalues to drop when exiting this scope. This starts
122125
/// out empty but grows as variables are declared during the
@@ -282,7 +285,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
282285
where F: FnOnce(&mut Builder<'a, 'gcx, 'tcx>) -> BlockAnd<R>
283286
{
284287
debug!("in_opt_scope(opt_extent={:?}, block={:?})", opt_extent, block);
285-
if let Some(extent) = opt_extent { self.push_scope(extent.0); }
288+
if let Some(extent) = opt_extent { self.push_scope(extent); }
286289
let rv = unpack!(block = f(self));
287290
if let Some(extent) = opt_extent {
288291
unpack!(block = self.pop_scope(extent, block));
@@ -301,7 +304,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
301304
where F: FnOnce(&mut Builder<'a, 'gcx, 'tcx>) -> BlockAnd<R>
302305
{
303306
debug!("in_scope(extent={:?}, block={:?})", extent, block);
304-
self.push_scope(extent.0);
307+
self.push_scope(extent);
305308
let rv = unpack!(block = f(self));
306309
unpack!(block = self.pop_scope(extent, block));
307310
debug!("in_scope: exiting extent={:?} block={:?}", extent, block);
@@ -312,12 +315,13 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
312315
/// scope and call `pop_scope` afterwards. Note that these two
313316
/// calls must be paired; using `in_scope` as a convenience
314317
/// wrapper maybe preferable.
315-
pub fn push_scope(&mut self, extent: CodeExtent) {
318+
pub fn push_scope(&mut self, extent: (CodeExtent, SourceInfo)) {
316319
debug!("push_scope({:?})", extent);
317320
let vis_scope = self.visibility_scope;
318321
self.scopes.push(Scope {
319322
visibility_scope: vis_scope,
320-
extent: extent,
323+
extent: extent.0,
324+
extent_span: extent.1.span,
321325
needs_cleanup: false,
322326
drops: vec![],
323327
free: None,
@@ -335,7 +339,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
335339
debug!("pop_scope({:?}, {:?})", extent, block);
336340
// We need to have `cached_block`s available for all the drops, so we call diverge_cleanup
337341
// to make sure all the `cached_block`s are filled in.
338-
self.diverge_cleanup(extent.1.span);
342+
self.diverge_cleanup();
339343
let scope = self.scopes.pop().unwrap();
340344
assert_eq!(scope.extent, extent.0);
341345
unpack!(block = build_scope_drops(&mut self.cfg,
@@ -618,7 +622,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
618622
/// This path terminates in Resume. Returns the start of the path.
619623
/// See module comment for more details. None indicates there’s no
620624
/// cleanup to do at this point.
621-
pub fn diverge_cleanup(&mut self, span: Span) -> Option<BasicBlock> {
625+
pub fn diverge_cleanup(&mut self) -> Option<BasicBlock> {
622626
if !self.scopes.iter().any(|scope| scope.needs_cleanup) {
623627
return None;
624628
}
@@ -652,7 +656,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
652656
};
653657

654658
for scope in scopes.iter_mut() {
655-
target = build_diverge_scope(hir.tcx(), cfg, &unit_temp, span, scope, target);
659+
target = build_diverge_scope(
660+
hir.tcx(), cfg, &unit_temp, scope.extent_span, scope, target);
656661
}
657662
Some(target)
658663
}
@@ -668,7 +673,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
668673
}
669674
let source_info = self.source_info(span);
670675
let next_target = self.cfg.start_new_block();
671-
let diverge_target = self.diverge_cleanup(span);
676+
let diverge_target = self.diverge_cleanup();
672677
self.cfg.terminate(block, source_info,
673678
TerminatorKind::Drop {
674679
location: location,
@@ -686,7 +691,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
686691
value: Operand<'tcx>) -> BlockAnd<()> {
687692
let source_info = self.source_info(span);
688693
let next_target = self.cfg.start_new_block();
689-
let diverge_target = self.diverge_cleanup(span);
694+
let diverge_target = self.diverge_cleanup();
690695
self.cfg.terminate(block, source_info,
691696
TerminatorKind::DropAndReplace {
692697
location: location,
@@ -709,7 +714,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
709714
let source_info = self.source_info(span);
710715

711716
let success_block = self.cfg.start_new_block();
712-
let cleanup = self.diverge_cleanup(span);
717+
let cleanup = self.diverge_cleanup();
713718

714719
self.cfg.terminate(block, source_info,
715720
TerminatorKind::Assert {

0 commit comments

Comments
 (0)