@@ -107,6 +107,9 @@ pub struct Scope<'tcx> {
107
107
/// the extent of this scope within source code.
108
108
extent : CodeExtent ,
109
109
110
+ /// the span of that extent
111
+ extent_span : Span ,
112
+
110
113
/// Whether there's anything to do for the cleanup path, that is,
111
114
/// when unwinding through this scope. This includes destructors,
112
115
/// but not StorageDead statements, which don't get emitted at all
@@ -116,7 +119,7 @@ pub struct Scope<'tcx> {
116
119
/// * pollutting the cleanup MIR with StorageDead creates
117
120
/// landing pads even though there's no actual destructors
118
121
/// * freeing up stack space has no effect during unwinding
119
- pub ( super ) needs_cleanup : bool ,
122
+ needs_cleanup : bool ,
120
123
121
124
/// set of lvalues to drop when exiting this scope. This starts
122
125
/// out empty but grows as variables are declared during the
@@ -282,7 +285,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
282
285
where F : FnOnce ( & mut Builder < ' a , ' gcx , ' tcx > ) -> BlockAnd < R >
283
286
{
284
287
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) ; }
286
289
let rv = unpack ! ( block = f( self ) ) ;
287
290
if let Some ( extent) = opt_extent {
288
291
unpack ! ( block = self . pop_scope( extent, block) ) ;
@@ -301,7 +304,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
301
304
where F : FnOnce ( & mut Builder < ' a , ' gcx , ' tcx > ) -> BlockAnd < R >
302
305
{
303
306
debug ! ( "in_scope(extent={:?}, block={:?})" , extent, block) ;
304
- self . push_scope ( extent. 0 ) ;
307
+ self . push_scope ( extent) ;
305
308
let rv = unpack ! ( block = f( self ) ) ;
306
309
unpack ! ( block = self . pop_scope( extent, block) ) ;
307
310
debug ! ( "in_scope: exiting extent={:?} block={:?}" , extent, block) ;
@@ -312,12 +315,13 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
312
315
/// scope and call `pop_scope` afterwards. Note that these two
313
316
/// calls must be paired; using `in_scope` as a convenience
314
317
/// wrapper maybe preferable.
315
- pub fn push_scope ( & mut self , extent : CodeExtent ) {
318
+ pub fn push_scope ( & mut self , extent : ( CodeExtent , SourceInfo ) ) {
316
319
debug ! ( "push_scope({:?})" , extent) ;
317
320
let vis_scope = self . visibility_scope ;
318
321
self . scopes . push ( Scope {
319
322
visibility_scope : vis_scope,
320
- extent : extent,
323
+ extent : extent. 0 ,
324
+ extent_span : extent. 1 . span ,
321
325
needs_cleanup : false ,
322
326
drops : vec ! [ ] ,
323
327
free : None ,
@@ -335,7 +339,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
335
339
debug ! ( "pop_scope({:?}, {:?})" , extent, block) ;
336
340
// We need to have `cached_block`s available for all the drops, so we call diverge_cleanup
337
341
// to make sure all the `cached_block`s are filled in.
338
- self . diverge_cleanup ( extent . 1 . span ) ;
342
+ self . diverge_cleanup ( ) ;
339
343
let scope = self . scopes . pop ( ) . unwrap ( ) ;
340
344
assert_eq ! ( scope. extent, extent. 0 ) ;
341
345
unpack ! ( block = build_scope_drops( & mut self . cfg,
@@ -618,7 +622,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
618
622
/// This path terminates in Resume. Returns the start of the path.
619
623
/// See module comment for more details. None indicates there’s no
620
624
/// 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 > {
622
626
if !self . scopes . iter ( ) . any ( |scope| scope. needs_cleanup ) {
623
627
return None ;
624
628
}
@@ -652,7 +656,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
652
656
} ;
653
657
654
658
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) ;
656
661
}
657
662
Some ( target)
658
663
}
@@ -668,7 +673,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
668
673
}
669
674
let source_info = self . source_info ( span) ;
670
675
let next_target = self . cfg . start_new_block ( ) ;
671
- let diverge_target = self . diverge_cleanup ( span ) ;
676
+ let diverge_target = self . diverge_cleanup ( ) ;
672
677
self . cfg . terminate ( block, source_info,
673
678
TerminatorKind :: Drop {
674
679
location : location,
@@ -686,7 +691,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
686
691
value : Operand < ' tcx > ) -> BlockAnd < ( ) > {
687
692
let source_info = self . source_info ( span) ;
688
693
let next_target = self . cfg . start_new_block ( ) ;
689
- let diverge_target = self . diverge_cleanup ( span ) ;
694
+ let diverge_target = self . diverge_cleanup ( ) ;
690
695
self . cfg . terminate ( block, source_info,
691
696
TerminatorKind :: DropAndReplace {
692
697
location : location,
@@ -709,7 +714,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
709
714
let source_info = self . source_info ( span) ;
710
715
711
716
let success_block = self . cfg . start_new_block ( ) ;
712
- let cleanup = self . diverge_cleanup ( span ) ;
717
+ let cleanup = self . diverge_cleanup ( ) ;
713
718
714
719
self . cfg . terminate ( block, source_info,
715
720
TerminatorKind :: Assert {
0 commit comments