@@ -107,15 +107,14 @@ struct BreakableScope<'tcx> {
107107 region_scope : region:: Scope ,
108108 /// Where the body of the loop begins. `None` if block
109109 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)
112112 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)
115115 break_destination : Place < ' tcx > ,
116116}
117117
118-
119118#[ derive( Debug ) ]
120119struct DropData {
121120 /// span where drop obligation was incurred (typically where place was declared)
@@ -131,7 +130,6 @@ struct DropData {
131130 cached_block : CachedBlock ,
132131}
133132
134-
135133/// The target of an expression that breaks out of a scope
136134#[ derive( Clone , Copy , Debug ) ]
137135pub enum BreakableTarget {
@@ -526,25 +524,27 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
526524 // to left reading the cached results but never created anything.
527525
528526 // 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+ )
548548 }
549549
550550 /// Utility function for *non*-scope code to build their own drops
0 commit comments