@@ -222,7 +222,6 @@ mod private {
222222#[ allow( private_interfaces) ]
223223pub trait Stage : Sized + ' static + Sealed {
224224 type Id : Copy ;
225- const SHOULD_EMIT_LINTS : bool ;
226225
227226 fn parsers ( ) -> & ' static GroupType < Self > ;
228227
@@ -231,13 +230,14 @@ pub trait Stage: Sized + 'static + Sealed {
231230 sess : & ' sess Session ,
232231 diag : impl for < ' x > Diagnostic < ' x > ,
233232 ) -> ErrorGuaranteed ;
233+
234+ fn should_emit ( & self ) -> ShouldEmit ;
234235}
235236
236237// allow because it's a sealed trait
237238#[ allow( private_interfaces) ]
238239impl Stage for Early {
239240 type Id = NodeId ;
240- const SHOULD_EMIT_LINTS : bool = false ;
241241
242242 fn parsers ( ) -> & ' static GroupType < Self > {
243243 & early:: ATTRIBUTE_PARSERS
@@ -253,13 +253,16 @@ impl Stage for Early {
253253 sess. dcx ( ) . create_err ( diag) . delay_as_bug ( )
254254 }
255255 }
256+
257+ fn should_emit ( & self ) -> ShouldEmit {
258+ self . emit_errors
259+ }
256260}
257261
258262// allow because it's a sealed trait
259263#[ allow( private_interfaces) ]
260264impl Stage for Late {
261265 type Id = HirId ;
262- const SHOULD_EMIT_LINTS : bool = true ;
263266
264267 fn parsers ( ) -> & ' static GroupType < Self > {
265268 & late:: ATTRIBUTE_PARSERS
@@ -271,6 +274,10 @@ impl Stage for Late {
271274 ) -> ErrorGuaranteed {
272275 tcx. dcx ( ) . emit_err ( diag)
273276 }
277+
278+ fn should_emit ( & self ) -> ShouldEmit {
279+ ShouldEmit :: ErrorsAndLints
280+ }
274281}
275282
276283/// used when parsing attributes for miscellaneous things *before* ast lowering
@@ -309,7 +316,7 @@ impl<'f, 'sess: 'f, S: Stage> SharedContext<'f, 'sess, S> {
309316 /// must be delayed until after HIR is built. This method will take care of the details of
310317 /// that.
311318 pub ( crate ) fn emit_lint ( & mut self , lint : AttributeLintKind , span : Span ) {
312- if !S :: SHOULD_EMIT_LINTS {
319+ if !self . stage . should_emit ( ) . should_emit ( ) {
313320 return ;
314321 }
315322 let id = self . target_id ;
0 commit comments