@@ -59,8 +59,6 @@ struct ConstToPat<'tcx> {
5959 // inference context used for checking `T: Structural` bounds.
6060 infcx : InferCtxt < ' tcx > ,
6161
62- include_lint_checks : bool ,
63-
6462 treat_byte_string_as_slice : bool ,
6563}
6664
@@ -93,7 +91,6 @@ impl<'tcx> ConstToPat<'tcx> {
9391 span,
9492 infcx,
9593 param_env : pat_ctxt. param_env ,
96- include_lint_checks : pat_ctxt. include_lint_checks ,
9794 saw_const_match_error : Cell :: new ( false ) ,
9895 saw_const_match_lint : Cell :: new ( false ) ,
9996 behind_reference : Cell :: new ( false ) ,
@@ -134,7 +131,7 @@ impl<'tcx> ConstToPat<'tcx> {
134131 } )
135132 } ) ;
136133
137- if self . include_lint_checks && !self . saw_const_match_error . get ( ) {
134+ if !self . saw_const_match_error . get ( ) {
138135 // If we were able to successfully convert the const to some pat,
139136 // double-check that all types in the const implement `Structural`.
140137
@@ -239,21 +236,19 @@ impl<'tcx> ConstToPat<'tcx> {
239236
240237 let kind = match cv. ty ( ) . kind ( ) {
241238 ty:: Float ( _) => {
242- if self . include_lint_checks {
243239 tcx. emit_spanned_lint (
244240 lint:: builtin:: ILLEGAL_FLOATING_POINT_LITERAL_PATTERN ,
245241 id,
246242 span,
247243 FloatPattern ,
248244 ) ;
249- }
250245 PatKind :: Constant { value : cv }
251246 }
252247 ty:: Adt ( adt_def, _) if adt_def. is_union ( ) => {
253248 // Matching on union fields is unsafe, we can't hide it in constants
254249 self . saw_const_match_error . set ( true ) ;
255250 let err = UnionPattern { span } ;
256- tcx. sess . create_err ( err) . emit_unless ( ! self . include_lint_checks ) ;
251+ tcx. sess . emit_err ( err) ;
257252 PatKind :: Wild
258253 }
259254 ty:: Adt ( ..)
@@ -267,7 +262,7 @@ impl<'tcx> ConstToPat<'tcx> {
267262 {
268263 self . saw_const_match_error . set ( true ) ;
269264 let err = TypeNotStructural { span, non_sm_ty } ;
270- tcx. sess . create_err ( err) . emit_unless ( ! self . include_lint_checks ) ;
265+ tcx. sess . emit_err ( err) ;
271266 PatKind :: Wild
272267 }
273268 // If the type is not structurally comparable, just emit the constant directly,
@@ -280,8 +275,7 @@ impl<'tcx> ConstToPat<'tcx> {
280275 // Backwards compatibility hack because we can't cause hard errors on these
281276 // types, so we compare them via `PartialEq::eq` at runtime.
282277 ty:: Adt ( ..) if !self . type_marked_structural ( cv. ty ( ) ) && self . behind_reference . get ( ) => {
283- if self . include_lint_checks
284- && !self . saw_const_match_error . get ( )
278+ if !self . saw_const_match_error . get ( )
285279 && !self . saw_const_match_lint . get ( )
286280 {
287281 self . saw_const_match_lint . set ( true ) ;
@@ -305,7 +299,7 @@ impl<'tcx> ConstToPat<'tcx> {
305299 ) ;
306300 self . saw_const_match_error . set ( true ) ;
307301 let err = TypeNotStructural { span, non_sm_ty : cv. ty ( ) } ;
308- tcx. sess . create_err ( err) . emit_unless ( ! self . include_lint_checks ) ;
302+ tcx. sess . emit_err ( err) ;
309303 PatKind :: Wild
310304 }
311305 ty:: Adt ( adt_def, substs) if adt_def. is_enum ( ) => {
@@ -339,7 +333,7 @@ impl<'tcx> ConstToPat<'tcx> {
339333 ty:: Dynamic ( ..) => {
340334 self . saw_const_match_error . set ( true ) ;
341335 let err = InvalidPattern { span, non_sm_ty : cv. ty ( ) } ;
342- tcx. sess . create_err ( err) . emit_unless ( ! self . include_lint_checks ) ;
336+ tcx. sess . emit_err ( err) ;
343337 PatKind :: Wild
344338 }
345339 // `&str` is represented as `ConstValue::Slice`, let's keep using this
@@ -406,8 +400,7 @@ impl<'tcx> ConstToPat<'tcx> {
406400 // to figure out how to get a reference again.
407401 ty:: Adt ( _, _) if !self . type_marked_structural ( * pointee_ty) => {
408402 if self . behind_reference . get ( ) {
409- if self . include_lint_checks
410- && !self . saw_const_match_error . get ( )
403+ if !self . saw_const_match_error . get ( )
411404 && !self . saw_const_match_lint . get ( )
412405 {
413406 self . saw_const_match_lint . set ( true ) ;
@@ -423,7 +416,7 @@ impl<'tcx> ConstToPat<'tcx> {
423416 if !self . saw_const_match_error . get ( ) {
424417 self . saw_const_match_error . set ( true ) ;
425418 let err = TypeNotStructural { span, non_sm_ty : * pointee_ty } ;
426- tcx. sess . create_err ( err) . emit_unless ( ! self . include_lint_checks ) ;
419+ tcx. sess . emit_err ( err) ;
427420 }
428421 PatKind :: Wild
429422 }
@@ -437,7 +430,7 @@ impl<'tcx> ConstToPat<'tcx> {
437430 // (except slices, which are handled in a separate arm above).
438431
439432 let err = UnsizedPattern { span, non_sm_ty : * pointee_ty } ;
440- tcx. sess . create_err ( err) . emit_unless ( ! self . include_lint_checks ) ;
433+ tcx. sess . emit_err ( err) ;
441434
442435 PatKind :: Wild
443436 } else {
@@ -465,8 +458,7 @@ impl<'tcx> ConstToPat<'tcx> {
465458 // compilation choices change the runtime behaviour of the match.
466459 // See https://github.com/rust-lang/rust/issues/70861 for examples.
467460 ty:: FnPtr ( ..) | ty:: RawPtr ( ..) => {
468- if self . include_lint_checks
469- && !self . saw_const_match_error . get ( )
461+ if !self . saw_const_match_error . get ( )
470462 && !self . saw_const_match_lint . get ( )
471463 {
472464 self . saw_const_match_lint . set ( true ) ;
@@ -482,13 +474,12 @@ impl<'tcx> ConstToPat<'tcx> {
482474 _ => {
483475 self . saw_const_match_error . set ( true ) ;
484476 let err = InvalidPattern { span, non_sm_ty : cv. ty ( ) } ;
485- tcx. sess . create_err ( err) . emit_unless ( ! self . include_lint_checks ) ;
477+ tcx. sess . emit_err ( err) ;
486478 PatKind :: Wild
487479 }
488480 } ;
489481
490- if self . include_lint_checks
491- && !self . saw_const_match_error . get ( )
482+ if !self . saw_const_match_error . get ( )
492483 && !self . saw_const_match_lint . get ( )
493484 && mir_structural_match_violation
494485 // FIXME(#73448): Find a way to bring const qualification into parity with
0 commit comments