@@ -445,6 +445,11 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
445445 fn lower_pattern_unadjusted ( & mut self , pat : & ' tcx hir:: Pat ) -> Pat < ' tcx > {
446446 let mut ty = self . tables . node_type ( pat. hir_id ) ;
447447
448+ if let ty:: Error = ty. kind {
449+ // Avoid ICEs (e.g., #50577 and #50585).
450+ return Pat { span : pat. span , ty, kind : Box :: new ( PatKind :: Wild ) } ;
451+ }
452+
448453 let kind = match pat. kind {
449454 hir:: PatKind :: Wild => PatKind :: Wild ,
450455
@@ -548,8 +553,6 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
548553 ty:: Slice ( ..) |
549554 ty:: Array ( ..) =>
550555 self . slice_or_array_pattern ( pat. span , ty, prefix, slice, suffix) ,
551- // Avoid ICE
552- ty:: Error => return Pat { span : pat. span , ty, kind : Box :: new ( PatKind :: Wild ) } ,
553556 _ => span_bug ! (
554557 pat. span,
555558 "unexpanded type for vector pattern: {:?}" ,
@@ -572,19 +575,12 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
572575
573576 PatKind :: Leaf { subpatterns }
574577 }
575- ty:: Error => { // Avoid ICE (#50577)
576- return Pat { span : pat. span , ty, kind : Box :: new ( PatKind :: Wild ) } ;
577- }
578578 _ => span_bug ! ( pat. span, "unexpected type for tuple pattern: {:?}" , ty) ,
579579 }
580580 }
581581
582582 hir:: PatKind :: Binding ( _, id, ident, ref sub) => {
583583 let var_ty = self . tables . node_type ( pat. hir_id ) ;
584- if let ty:: Error = var_ty. kind {
585- // Avoid ICE
586- return Pat { span : pat. span , ty, kind : Box :: new ( PatKind :: Wild ) } ;
587- } ;
588584 let bm = * self . tables . pat_binding_modes ( ) . get ( pat. hir_id )
589585 . expect ( "missing binding mode" ) ;
590586 let ( mutability, mode) = match bm {
@@ -624,9 +620,6 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
624620 let res = self . tables . qpath_res ( qpath, pat. hir_id ) ;
625621 let adt_def = match ty. kind {
626622 ty:: Adt ( adt_def, _) => adt_def,
627- ty:: Error => { // Avoid ICE (#50585)
628- return Pat { span : pat. span , ty, kind : Box :: new ( PatKind :: Wild ) } ;
629- }
630623 _ => span_bug ! ( pat. span,
631624 "tuple struct pattern not applied to an ADT {:?}" ,
632625 ty) ,
0 commit comments