@@ -224,7 +224,6 @@ mod private {
224224#[ allow( private_interfaces) ]  
225225pub  trait  Stage :  Sized  + ' static  + Sealed  { 
226226    type  Id :  Copy ; 
227-     const  SHOULD_EMIT_LINTS :  bool ; 
228227
229228    fn  parsers ( )  -> & ' static  GroupType < Self > ; 
230229
@@ -233,13 +232,14 @@ pub trait Stage: Sized + 'static + Sealed {
233232        sess :  & ' sess  Session , 
234233        diag :  impl  for < ' x >  Diagnostic < ' x > , 
235234    )  -> ErrorGuaranteed ; 
235+ 
236+     fn  should_emit ( & self )  -> ShouldEmit ; 
236237} 
237238
238239// allow because it's a sealed trait 
239240#[ allow( private_interfaces) ]  
240241impl  Stage  for  Early  { 
241242    type  Id  = NodeId ; 
242-     const  SHOULD_EMIT_LINTS :  bool  = false ; 
243243
244244    fn  parsers ( )  -> & ' static  GroupType < Self >  { 
245245        & early:: ATTRIBUTE_PARSERS 
@@ -255,13 +255,16 @@ impl Stage for Early {
255255            sess. dcx ( ) . create_err ( diag) . delay_as_bug ( ) 
256256        } 
257257    } 
258+ 
259+     fn  should_emit ( & self )  -> ShouldEmit  { 
260+         self . emit_errors 
261+     } 
258262} 
259263
260264// allow because it's a sealed trait 
261265#[ allow( private_interfaces) ]  
262266impl  Stage  for  Late  { 
263267    type  Id  = HirId ; 
264-     const  SHOULD_EMIT_LINTS :  bool  = true ; 
265268
266269    fn  parsers ( )  -> & ' static  GroupType < Self >  { 
267270        & late:: ATTRIBUTE_PARSERS 
@@ -273,6 +276,10 @@ impl Stage for Late {
273276    )  -> ErrorGuaranteed  { 
274277        tcx. dcx ( ) . emit_err ( diag) 
275278    } 
279+ 
280+     fn  should_emit ( & self )  -> ShouldEmit  { 
281+         ShouldEmit :: ErrorsAndLints 
282+     } 
276283} 
277284
278285/// used when parsing attributes for miscellaneous things *before* ast lowering 
@@ -311,7 +318,7 @@ impl<'f, 'sess: 'f, S: Stage> SharedContext<'f, 'sess, S> {
311318/// must be delayed until after HIR is built. This method will take care of the details of 
312319/// that. 
313320pub ( crate )  fn  emit_lint ( & mut  self ,  lint :  AttributeLintKind ,  span :  Span )  { 
314-         if  !S :: SHOULD_EMIT_LINTS  { 
321+         if  !self . stage . should_emit ( ) . should_emit ( )  { 
315322            return ; 
316323        } 
317324        let  id = self . target_id ; 
0 commit comments