about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2025-08-05 03:51:37 +0200
committerGitHub <noreply@github.com>2025-08-05 03:51:37 +0200
commit149ee59876d06e60ea5b2390ddfb537b42f9d6ba (patch)
treecf8c7feee79c2ed96bffc0ab875eddcc003dd865
parentd2fcd71be658e078a54b3fd84332d67348451240 (diff)
parentf92934f43ac34d65a0c39e589d330f27a2f45574 (diff)
Rollup merge of #144866 - JonathanBrouwer:should_emit_fix, r=jdonszelmann
Remove `SHOULD_EMIT_LINTS` in favor of `should_emit`

r? ``@jdonszelmann``
-rw-r--r--compiler/rustc_attr_parsing/src/context.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs
index b51db9b4b9e..c6599f20c2d 100644
--- a/compiler/rustc_attr_parsing/src/context.rs
+++ b/compiler/rustc_attr_parsing/src/context.rs
@@ -222,7 +222,6 @@ mod private {
 #[allow(private_interfaces)]
 pub trait Stage: Sized + 'static + Sealed {
     type Id: Copy;
-    const SHOULD_EMIT_LINTS: bool;
 
     fn parsers() -> &'static GroupType<Self>;
 
@@ -231,13 +230,14 @@ pub trait Stage: Sized + 'static + Sealed {
         sess: &'sess Session,
         diag: impl for<'x> Diagnostic<'x>,
     ) -> ErrorGuaranteed;
+
+    fn should_emit(&self) -> ShouldEmit;
 }
 
 // allow because it's a sealed trait
 #[allow(private_interfaces)]
 impl Stage for Early {
     type Id = NodeId;
-    const SHOULD_EMIT_LINTS: bool = false;
 
     fn parsers() -> &'static GroupType<Self> {
         &early::ATTRIBUTE_PARSERS
@@ -253,13 +253,16 @@ impl Stage for Early {
             sess.dcx().create_err(diag).delay_as_bug()
         }
     }
+
+    fn should_emit(&self) -> ShouldEmit {
+        self.emit_errors
+    }
 }
 
 // allow because it's a sealed trait
 #[allow(private_interfaces)]
 impl Stage for Late {
     type Id = HirId;
-    const SHOULD_EMIT_LINTS: bool = true;
 
     fn parsers() -> &'static GroupType<Self> {
         &late::ATTRIBUTE_PARSERS
@@ -271,6 +274,10 @@ impl Stage for Late {
     ) -> ErrorGuaranteed {
         tcx.dcx().emit_err(diag)
     }
+
+    fn should_emit(&self) -> ShouldEmit {
+        ShouldEmit::ErrorsAndLints
+    }
 }
 
 /// used when parsing attributes for miscellaneous things *before* ast lowering
@@ -309,7 +316,7 @@ impl<'f, 'sess: 'f, S: Stage> SharedContext<'f, 'sess, S> {
     /// must be delayed until after HIR is built. This method will take care of the details of
     /// that.
     pub(crate) fn emit_lint(&mut self, lint: AttributeLintKind, span: Span) {
-        if !S::SHOULD_EMIT_LINTS {
+        if !self.stage.should_emit().should_emit() {
             return;
         }
         let id = self.target_id;