diff options
| 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 |
| commit | bdab02ca994eebd8b4a964793d2684fc87c11119 (patch) | |
| tree | 7029bc2e536c16577cffa0b6623fc9e7bea669c7 | |
| parent | 60de7554de5537bfaf359905ec2c1fad60f9cfbd (diff) | |
| download | rust-bdab02ca994eebd8b4a964793d2684fc87c11119.tar.gz rust-bdab02ca994eebd8b4a964793d2684fc87c11119.zip | |
Guard decorate on when not to skip instead
| -rw-r--r-- | compiler/rustc_middle/src/lint.rs | 11 |
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); |
