avoid infinite loop in MIR lowering

This commit is contained in:
Niko Matsakis 2018-09-24 17:53:28 -04:00 committed by Keith Yeung
parent fba9d14779
commit 4a293a3990

View File

@ -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,
});