@@ -196,9 +196,7 @@ impl<'tcx> ConstToPat<'tcx> {
196196 } ;
197197 // All branches above emitted an error. Don't print any more lints.
198198 // 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) ;
202200 return Box :: new ( Pat { span : self . span , ty : cv. ty ( ) , kind } ) ;
203201 } else if !self . saw_const_match_lint . get ( ) {
204202 if let Some ( mir_structural_match_violation) = mir_structural_match_violation {
@@ -351,15 +349,15 @@ impl<'tcx> ConstToPat<'tcx> {
351349 let e = tcx. sess . emit_err ( InvalidPattern { span, non_sm_ty : ty } ) ;
352350 self . saw_const_match_error . set ( Some ( e) ) ;
353351 // 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 )
355353 }
356354 ty:: Adt ( adt_def, _) if !self . type_marked_structural ( ty) => {
357355 debug ! ( "adt_def {:?} has !type_marked_structural for cv.ty: {:?}" , adt_def, ty, ) ;
358356 let err = TypeNotStructural { span, non_sm_ty : ty } ;
359357 let e = tcx. sess . emit_err ( err) ;
360358 self . saw_const_match_error . set ( Some ( e) ) ;
361359 // 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 )
363361 }
364362 ty:: Adt ( adt_def, args) if adt_def. is_enum ( ) => {
365363 let ( & variant_index, fields) = cv. unwrap_branch ( ) . split_first ( ) . unwrap ( ) ;
@@ -434,17 +432,13 @@ impl<'tcx> ConstToPat<'tcx> {
434432 } else {
435433 if let Some ( e) = self . saw_const_match_error . get ( ) {
436434 // 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)
440436 } else {
441437 let err = TypeNotStructural { span, non_sm_ty : * pointee_ty } ;
442438 let e = tcx. sess . emit_err ( err) ;
443439 self . saw_const_match_error . set ( Some ( e) ) ;
444440 // 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)
448442 }
449443 }
450444 }
@@ -456,9 +450,7 @@ impl<'tcx> ConstToPat<'tcx> {
456450 let err = UnsizedPattern { span, non_sm_ty : * pointee_ty } ;
457451 let e = tcx. sess . emit_err ( err) ;
458452 // 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)
462454 } else {
463455 let old = self . behind_reference . replace ( true ) ;
464456 // `b"foo"` produces a `&[u8; 3]`, but you can't use constants of array type when
@@ -489,7 +481,7 @@ impl<'tcx> ConstToPat<'tcx> {
489481 let e = tcx. sess . emit_err ( err) ;
490482 self . saw_const_match_error . set ( Some ( e) ) ;
491483 // 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 )
493485 }
494486 } ;
495487
0 commit comments