Skip to content

Commit 149ee59

Browse files
Rollup merge of #144866 - JonathanBrouwer:should_emit_fix, r=jdonszelmann
Remove `SHOULD_EMIT_LINTS` in favor of `should_emit` r? ``@jdonszelmann``
2 parents d2fcd71 + f92934f commit 149ee59

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ mod private {
222222
#[allow(private_interfaces)]
223223
pub 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)]
238239
impl 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)]
260264
impl 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

Comments
 (0)