]> git.lizzy.rs Git - rust.git/commitdiff
Fix merge of scope.rs
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Fri, 11 Aug 2017 02:24:25 +0000 (04:24 +0200)
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Fri, 11 Aug 2017 02:24:25 +0000 (04:24 +0200)
src/librustc_mir/build/scope.rs

index 2033131c0650ec194851add69d87a5dd005874d3..cb7b13f1e614c54cea349e2eec89cd80957b79d3 100644 (file)
@@ -875,15 +875,13 @@ fn build_scope_drops<'tcx>(cfg: &mut CFG<'tcx>,
                 // for us to diverge into in case the drop panics.
                 let on_diverge = iter.peek().iter().filter_map(|dd| {
                     match dd.kind {
-                        DropKind::Value {
-                            cached_block: CachedBlock {
-                                unwind: None,
-                                generator_drop: None,
+                        DropKind::Value { cached_block } => {
+                            let result = cached_block.get(generator_drop);
+                            if result.is_none() {
+                                span_bug!(drop_data.span, "cached block not present?")
                             }
-                        } => {
-                            span_bug!(drop_data.span, "cached block not present?")
-                        }
-                        DropKind::Value { cached_block } => cached_block.get(generator_drop),
+                            result
+                        },
                         DropKind::Storage => None
                     }
                 }).next();
@@ -903,6 +901,11 @@ fn build_scope_drops<'tcx>(cfg: &mut CFG<'tcx>,
             DropKind::Storage => {}
         }
 
+        // We do not need to emit StorageDead for generator drops
+        if generator_drop {
+            continue
+        }
+
         // Drop the storage for both value and storage drops.
         // Only temps and vars need their storage dead.
         match drop_data.location {