@@ -107,15 +107,14 @@ struct BreakableScope<'tcx> {
107
107
region_scope : region:: Scope ,
108
108
/// Where the body of the loop begins. `None` if block
109
109
continue_block : Option < BasicBlock > ,
110
- /// Block to branch into when the loop or block terminates (either by being `break`-en out
111
- /// from, or by having its condition to become false)
110
+ /// Block to branch into when the loop or block terminates (either by being
111
+ /// `break`-en out from, or by having its condition to become false)
112
112
break_block : BasicBlock ,
113
- /// The destination of the loop/block expression itself (i.e., where to put the result of a
114
- /// `break` expression)
113
+ /// The destination of the loop/block expression itself (i.e., where to put
114
+ /// the result of a `break` expression)
115
115
break_destination : Place < ' tcx > ,
116
116
}
117
117
118
-
119
118
#[ derive( Debug ) ]
120
119
struct DropData {
121
120
/// span where drop obligation was incurred (typically where place was declared)
@@ -131,7 +130,6 @@ struct DropData {
131
130
cached_block : CachedBlock ,
132
131
}
133
132
134
-
135
133
/// The target of an expression that breaks out of a scope
136
134
#[ derive( Clone , Copy , Debug ) ]
137
135
pub enum BreakableTarget {
@@ -526,25 +524,27 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
526
524
// to left reading the cached results but never created anything.
527
525
528
526
// Find the last cached block
529
- debug ! ( "diverge_cleanup_gen(self.scopes = {:?})" , self . scopes) ;
530
- let cached_cleanup = self . scopes . last_cached_unwind ( generator_drop) ;
531
- let ( mut target, first_uncached) = cached_cleanup
532
- . unwrap_or_else ( || ( self . resume_block ( ) , 0 ) ) ;
533
-
534
- let scopes = self . scopes . diverge_blocks ( first_uncached, generator_drop) ;
535
- for ( source_scope, drops, cached_unwind) in scopes {
536
- target = build_diverge_scope (
537
- & mut self . cfg ,
538
- source_scope,
539
- drops,
540
- target,
541
- generator_drop,
542
- self . is_generator ,
543
- ) ;
544
- * cached_unwind = Some ( target) ;
545
- }
546
-
547
- target
527
+ debug ! ( "diverge_cleanup_gen(self.scopes = {:#?})" , self . scopes) ;
528
+ let resume_block = self . resume_block ( ) ;
529
+ let cfg = & mut self . cfg ;
530
+ let is_generator = self . is_generator ;
531
+
532
+ self . scopes . for_each_diverge_block (
533
+ generator_drop,
534
+ resume_block,
535
+ |source_scope, drops, cached_unwind, mut target| {
536
+ target = build_diverge_scope (
537
+ cfg,
538
+ source_scope,
539
+ drops,
540
+ target,
541
+ generator_drop,
542
+ is_generator,
543
+ ) ;
544
+ * cached_unwind = Some ( target) ;
545
+ target
546
+ }
547
+ )
548
548
}
549
549
550
550
/// Utility function for *non*-scope code to build their own drops
0 commit comments