@@ -222,7 +222,6 @@ mod private {
222
222
#[ allow( private_interfaces) ]
223
223
pub trait Stage : Sized + ' static + Sealed {
224
224
type Id : Copy ;
225
- const SHOULD_EMIT_LINTS : bool ;
226
225
227
226
fn parsers ( ) -> & ' static GroupType < Self > ;
228
227
@@ -231,13 +230,14 @@ pub trait Stage: Sized + 'static + Sealed {
231
230
sess : & ' sess Session ,
232
231
diag : impl for < ' x > Diagnostic < ' x > ,
233
232
) -> ErrorGuaranteed ;
233
+
234
+ fn should_emit ( & self ) -> ShouldEmit ;
234
235
}
235
236
236
237
// allow because it's a sealed trait
237
238
#[ allow( private_interfaces) ]
238
239
impl Stage for Early {
239
240
type Id = NodeId ;
240
- const SHOULD_EMIT_LINTS : bool = false ;
241
241
242
242
fn parsers ( ) -> & ' static GroupType < Self > {
243
243
& early:: ATTRIBUTE_PARSERS
@@ -253,13 +253,16 @@ impl Stage for Early {
253
253
sess. dcx ( ) . create_err ( diag) . delay_as_bug ( )
254
254
}
255
255
}
256
+
257
+ fn should_emit ( & self ) -> ShouldEmit {
258
+ self . emit_errors
259
+ }
256
260
}
257
261
258
262
// allow because it's a sealed trait
259
263
#[ allow( private_interfaces) ]
260
264
impl Stage for Late {
261
265
type Id = HirId ;
262
- const SHOULD_EMIT_LINTS : bool = true ;
263
266
264
267
fn parsers ( ) -> & ' static GroupType < Self > {
265
268
& late:: ATTRIBUTE_PARSERS
@@ -271,6 +274,10 @@ impl Stage for Late {
271
274
) -> ErrorGuaranteed {
272
275
tcx. dcx ( ) . emit_err ( diag)
273
276
}
277
+
278
+ fn should_emit ( & self ) -> ShouldEmit {
279
+ ShouldEmit :: ErrorsAndLints
280
+ }
274
281
}
275
282
276
283
/// used when parsing attributes for miscellaneous things *before* ast lowering
@@ -309,7 +316,7 @@ impl<'f, 'sess: 'f, S: Stage> SharedContext<'f, 'sess, S> {
309
316
/// must be delayed until after HIR is built. This method will take care of the details of
310
317
/// that.
311
318
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 ( ) {
313
320
return ;
314
321
}
315
322
let id = self . target_id ;
0 commit comments