@@ -445,6 +445,11 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
445
445
fn lower_pattern_unadjusted ( & mut self , pat : & ' tcx hir:: Pat ) -> Pat < ' tcx > {
446
446
let mut ty = self . tables . node_type ( pat. hir_id ) ;
447
447
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
+
448
453
let kind = match pat. kind {
449
454
hir:: PatKind :: Wild => PatKind :: Wild ,
450
455
@@ -548,8 +553,6 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
548
553
ty:: Slice ( ..) |
549
554
ty:: Array ( ..) =>
550
555
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 ) } ,
553
556
_ => span_bug ! (
554
557
pat. span,
555
558
"unexpanded type for vector pattern: {:?}" ,
@@ -572,19 +575,12 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
572
575
573
576
PatKind :: Leaf { subpatterns }
574
577
}
575
- ty:: Error => { // Avoid ICE (#50577)
576
- return Pat { span : pat. span , ty, kind : Box :: new ( PatKind :: Wild ) } ;
577
- }
578
578
_ => span_bug ! ( pat. span, "unexpected type for tuple pattern: {:?}" , ty) ,
579
579
}
580
580
}
581
581
582
582
hir:: PatKind :: Binding ( _, id, ident, ref sub) => {
583
583
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
- } ;
588
584
let bm = * self . tables . pat_binding_modes ( ) . get ( pat. hir_id )
589
585
. expect ( "missing binding mode" ) ;
590
586
let ( mutability, mode) = match bm {
@@ -624,9 +620,6 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
624
620
let res = self . tables . qpath_res ( qpath, pat. hir_id ) ;
625
621
let adt_def = match ty. kind {
626
622
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
- }
630
623
_ => span_bug ! ( pat. span,
631
624
"tuple struct pattern not applied to an ADT {:?}" ,
632
625
ty) ,
0 commit comments