diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2018-09-24 17:53:28 -0400 |
|---|---|---|
| committer | Keith Yeung <kungfukeith11@gmail.com> | 2018-09-29 10:34:35 -0700 |
| commit | 4a293a3990a0c1bf170d31d1d9bcbc79cef8a5b8 (patch) | |
| tree | e4973bd00db16d5289793cd3b7ec3621bdc32ca9 | |
| parent | fba9d14779552c665c5431f0c993c0780c00adca (diff) | |
| download | rust-4a293a3990a0c1bf170d31d1d9bcbc79cef8a5b8.tar.gz rust-4a293a3990a0c1bf170d31d1d9bcbc79cef8a5b8.zip | |
avoid infinite loop in MIR lowering
| -rw-r--r-- | src/librustc_mir/build/expr/into.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index c05719ce95a..9ea3805fdc6 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -345,7 +345,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } // 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 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { | 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, }); |
