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