Guard decorate on when not to skip instead

This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-03-17 15:07:22 +00:00
parent 60de7554de
commit bdab02ca99
No known key found for this signature in database
GPG key ID: 95DDEBD74A1DC2C0

View file

@ -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);