@@ -196,9 +196,7 @@ impl<'tcx> ConstToPat<'tcx> {
196
196
} ;
197
197
// All branches above emitted an error. Don't print any more lints.
198
198
// We errored. Signal that in the pattern, so that follow up errors can be silenced.
199
- let kind = PatKind :: Constant {
200
- value : mir:: Const :: Ty ( ty:: Const :: new_error ( self . tcx ( ) , e, cv. ty ( ) ) ) ,
201
- } ;
199
+ let kind = PatKind :: Error ( e) ;
202
200
return Box :: new ( Pat { span : self . span , ty : cv. ty ( ) , kind } ) ;
203
201
} else if !self . saw_const_match_lint . get ( ) {
204
202
if let Some ( mir_structural_match_violation) = mir_structural_match_violation {
@@ -351,15 +349,15 @@ impl<'tcx> ConstToPat<'tcx> {
351
349
let e = tcx. sess . emit_err ( InvalidPattern { span, non_sm_ty : ty } ) ;
352
350
self . saw_const_match_error . set ( Some ( e) ) ;
353
351
// We errored. Signal that in the pattern, so that follow up errors can be silenced.
354
- PatKind :: Constant { value : mir :: Const :: Ty ( ty :: Const :: new_error ( tcx , e , ty ) ) }
352
+ PatKind :: Error ( e )
355
353
}
356
354
ty:: Adt ( adt_def, _) if !self . type_marked_structural ( ty) => {
357
355
debug ! ( "adt_def {:?} has !type_marked_structural for cv.ty: {:?}" , adt_def, ty, ) ;
358
356
let err = TypeNotStructural { span, non_sm_ty : ty } ;
359
357
let e = tcx. sess . emit_err ( err) ;
360
358
self . saw_const_match_error . set ( Some ( e) ) ;
361
359
// We errored. Signal that in the pattern, so that follow up errors can be silenced.
362
- PatKind :: Constant { value : mir :: Const :: Ty ( ty :: Const :: new_error ( tcx , e , ty ) ) }
360
+ PatKind :: Error ( e )
363
361
}
364
362
ty:: Adt ( adt_def, args) if adt_def. is_enum ( ) => {
365
363
let ( & variant_index, fields) = cv. unwrap_branch ( ) . split_first ( ) . unwrap ( ) ;
@@ -434,17 +432,13 @@ impl<'tcx> ConstToPat<'tcx> {
434
432
} else {
435
433
if let Some ( e) = self . saw_const_match_error . get ( ) {
436
434
// We already errored. Signal that in the pattern, so that follow up errors can be silenced.
437
- PatKind :: Constant {
438
- value : mir:: Const :: Ty ( ty:: Const :: new_error ( tcx, e, ty) ) ,
439
- }
435
+ PatKind :: Error ( e)
440
436
} else {
441
437
let err = TypeNotStructural { span, non_sm_ty : * pointee_ty } ;
442
438
let e = tcx. sess . emit_err ( err) ;
443
439
self . saw_const_match_error . set ( Some ( e) ) ;
444
440
// We errored. Signal that in the pattern, so that follow up errors can be silenced.
445
- PatKind :: Constant {
446
- value : mir:: Const :: Ty ( ty:: Const :: new_error ( tcx, e, ty) ) ,
447
- }
441
+ PatKind :: Error ( e)
448
442
}
449
443
}
450
444
}
@@ -456,9 +450,7 @@ impl<'tcx> ConstToPat<'tcx> {
456
450
let err = UnsizedPattern { span, non_sm_ty : * pointee_ty } ;
457
451
let e = tcx. sess . emit_err ( err) ;
458
452
// We errored. Signal that in the pattern, so that follow up errors can be silenced.
459
- PatKind :: Constant {
460
- value : mir:: Const :: Ty ( ty:: Const :: new_error ( tcx, e, ty) ) ,
461
- }
453
+ PatKind :: Error ( e)
462
454
} else {
463
455
let old = self . behind_reference . replace ( true ) ;
464
456
// `b"foo"` produces a `&[u8; 3]`, but you can't use constants of array type when
@@ -489,7 +481,7 @@ impl<'tcx> ConstToPat<'tcx> {
489
481
let e = tcx. sess . emit_err ( err) ;
490
482
self . saw_const_match_error . set ( Some ( e) ) ;
491
483
// We errored. Signal that in the pattern, so that follow up errors can be silenced.
492
- PatKind :: Constant { value : mir :: Const :: Ty ( ty :: Const :: new_error ( tcx , e , ty ) ) }
484
+ PatKind :: Error ( e )
493
485
}
494
486
} ;
495
487
0 commit comments