@@ -345,7 +345,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
345345 }
346346
347347 // Avoid creating a temporary
348- ExprKind :: VarRef { .. } | ExprKind :: SelfRef | ExprKind :: StaticRef { .. } => {
348+ ExprKind :: VarRef { .. } |
349+ ExprKind :: SelfRef |
350+ ExprKind :: StaticRef { .. } |
351+ ExprKind :: PlaceTypeAscription { .. } |
352+ ExprKind :: ValueTypeAscription { .. } => {
349353 debug_assert ! ( Category :: of( & expr. kind) == Some ( Category :: Place ) ) ;
350354
351355 let place = unpack ! ( block = this. as_place( block, expr) ) ;
@@ -391,11 +395,16 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
391395 | ExprKind :: Adt { .. }
392396 | ExprKind :: Closure { .. }
393397 | ExprKind :: Literal { .. }
394- | ExprKind :: Yield { .. }
395- | ExprKind :: PlaceTypeAscription { .. }
396- | ExprKind :: ValueTypeAscription { .. } => {
398+ | ExprKind :: Yield { .. } => {
397399 debug_assert ! ( match Category :: of( & expr. kind) . unwrap( ) {
400+ // should be handled above
398401 Category :: Rvalue ( RvalueFunc :: Into ) => false ,
402+
403+ // must be handled above or else we get an
404+ // infinite loop in the builder; see
405+ // e.g. `ExprKind::VarRef` above
406+ Category :: Place => false ,
407+
399408 _ => true ,
400409 } ) ;
401410
0 commit comments