about summary refs log tree commit diff
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <jieyouxu@outlook.com>2024-03-17 15:07:22 +0000
committer许杰友 Jieyou Xu (Joe) <jieyouxu@outlook.com>2024-03-17 15:07:22 +0000
commitbdab02ca994eebd8b4a964793d2684fc87c11119 (patch)
tree7029bc2e536c16577cffa0b6623fc9e7bea669c7
parent60de7554de5537bfaf359905ec2c1fad60f9cfbd (diff)
downloadrust-bdab02ca994eebd8b4a964793d2684fc87c11119.tar.gz
rust-bdab02ca994eebd8b4a964793d2684fc87c11119.zip
Guard decorate on when not to skip instead
-rw-r--r--compiler/rustc_middle/src/lint.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs
index b5b22e3f4b7..8d9e0dfd869 100644
--- a/compiler/rustc_middle/src/lint.rs
+++ b/compiler/rustc_middle/src/lint.rs
@@ -408,13 +408,10 @@ pub fn lint_level(
         // 2. If the corresponding `rustc_errors::Level` is warning, then that can be affected by
         //    `-A warnings` or `--cap-lints=xxx` on the command line. In which case, the diagnostic
         //    will be emitted if `can_emit_warnings` is true.
-        {
-            use rustc_errors::Level as ELevel;
-            if matches!(err_level, ELevel::ForceWarning(_) | ELevel::Error)
-                || sess.dcx().can_emit_warnings()
-            {
-                decorate(&mut err);
-            }
+        let skip = err_level == rustc_errors::Level::Warning && !sess.dcx().can_emit_warnings();
+
+        if !skip {
+            decorate(&mut err);
         }
 
         explain_lint_level_source(lint, level, src, &mut err);