@@ -416,7 +416,6 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
416416 }
417417
418418 PatKind :: Slice ( ref prefix, ref slice, ref suffix) => {
419- let ty = self . tables . node_id_to_type ( pat. hir_id ) ;
420419 match ty. sty {
421420 ty:: TyRef ( _, ty, _) =>
422421 PatternKind :: Deref {
@@ -427,11 +426,12 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
427426 pat. span , ty, prefix, slice, suffix) )
428427 } ,
429428 } ,
430-
431429 ty:: TySlice ( ..) |
432430 ty:: TyArray ( ..) =>
433431 self . slice_or_array_pattern ( pat. span , ty, prefix, slice, suffix) ,
434-
432+ ty:: TyError => { // Avoid ICE
433+ return Pattern { span : pat. span , ty, kind : Box :: new ( PatternKind :: Wild ) } ;
434+ }
435435 ref sty =>
436436 span_bug ! (
437437 pat. span,
@@ -441,7 +441,6 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
441441 }
442442
443443 PatKind :: Tuple ( ref subpatterns, ddpos) => {
444- let ty = self . tables . node_id_to_type ( pat. hir_id ) ;
445444 match ty. sty {
446445 ty:: TyTuple ( ref tys) => {
447446 let subpatterns =
@@ -455,7 +454,9 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
455454
456455 PatternKind :: Leaf { subpatterns : subpatterns }
457456 }
458-
457+ ty:: TyError => { // Avoid ICE (#50577)
458+ return Pattern { span : pat. span , ty, kind : Box :: new ( PatternKind :: Wild ) } ;
459+ }
459460 ref sty => span_bug ! ( pat. span, "unexpected type for tuple pattern: {:?}" , sty) ,
460461 }
461462 }
@@ -464,6 +465,9 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
464465 let var_ty = self . tables . node_id_to_type ( pat. hir_id ) ;
465466 let region = match var_ty. sty {
466467 ty:: TyRef ( r, _, _) => Some ( r) ,
468+ ty:: TyError => { // Avoid ICE
469+ return Pattern { span : pat. span , ty, kind : Box :: new ( PatternKind :: Wild ) } ;
470+ }
467471 _ => None ,
468472 } ;
469473 let bm = * self . tables . pat_binding_modes ( ) . get ( pat. hir_id )
@@ -505,12 +509,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
505509 let def = self . tables . qpath_def ( qpath, pat. hir_id ) ;
506510 let adt_def = match ty. sty {
507511 ty:: TyAdt ( adt_def, _) => adt_def,
508- ty:: TyError => { // Avoid ICE (#50585)
509- return Pattern {
510- span : pat. span ,
511- ty,
512- kind : Box :: new ( PatternKind :: Wild ) ,
513- } ;
512+ ty:: TyError => { // Avoid ICE (#50585)
513+ return Pattern { span : pat. span , ty, kind : Box :: new ( PatternKind :: Wild ) } ;
514514 }
515515 _ => span_bug ! ( pat. span,
516516 "tuple struct pattern not applied to an ADT {:?}" ,
0 commit comments