]> git.lizzy.rs Git - rust.git/commitdiff
avoid infinite loop in MIR lowering
authorNiko Matsakis <niko@alum.mit.edu>
Mon, 24 Sep 2018 21:53:28 +0000 (17:53 -0400)
committerKeith Yeung <kungfukeith11@gmail.com>
Sat, 29 Sep 2018 17:34:35 +0000 (10:34 -0700)
src/librustc_mir/build/expr/into.rs

index c05719ce95a63c3c1671b08a624f82c1c7dac122..9ea3805fdc65210dbae7a0f87ede997f4afe9992 100644 (file)
@@ -345,7 +345,11 @@ pub fn into_expr(
             }
 
             // Avoid creating a temporary
-            ExprKind::VarRef { .. } | ExprKind::SelfRef | ExprKind::StaticRef { .. } => {
+            ExprKind::VarRef { .. } |
+            ExprKind::SelfRef |
+            ExprKind::StaticRef { .. } |
+            ExprKind::PlaceTypeAscription { .. } |
+            ExprKind::ValueTypeAscription { .. } => {
                 debug_assert!(Category::of(&expr.kind) == Some(Category::Place));
 
                 let place = unpack!(block = this.as_place(block, expr));
@@ -391,11 +395,16 @@ pub fn into_expr(
             | ExprKind::Adt { .. }
             | ExprKind::Closure { .. }
             | ExprKind::Literal { .. }
-            | ExprKind::Yield { .. }
-            | ExprKind::PlaceTypeAscription { .. }
-            | ExprKind::ValueTypeAscription { .. } => {
+            | ExprKind::Yield { .. } => {
                 debug_assert!(match Category::of(&expr.kind).unwrap() {
+                    // should be handled above
                     Category::Rvalue(RvalueFunc::Into) => false,
+
+                    // must be handled above or else we get an
+                    // infinite loop in the builder; see
+                    // e.g. `ExprKind::VarRef` above
+                    Category::Place => false,
+
                     _ => true,
                 });