mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Only invoke decorate
if the diag can eventually be emitted
This commit is contained in:
parent
a0c20d52e0
commit
772d8598d2
@ -398,8 +398,16 @@ pub fn lint_level(
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, run `decorate`.
|
||||
decorate(&mut err);
|
||||
// Finally, run `decorate`. This is guarded by a `can_emit_warnings()` check so that any
|
||||
// `def_path_str` called within `decorate` won't trigger a `must_produce_diag` ICE if the
|
||||
// `err` isn't eventually emitted (e.g. due to `-A warnings`). If an `err` is force-warn,
|
||||
// it's going to be emitted anyway.
|
||||
if matches!(err_level, rustc_errors::Level::ForceWarning(_))
|
||||
|| sess.dcx().can_emit_warnings()
|
||||
{
|
||||
decorate(&mut err);
|
||||
}
|
||||
|
||||
explain_lint_level_source(lint, level, src, &mut err);
|
||||
err.emit()
|
||||
}
|
||||
|
14
tests/ui/lint/decorate-def-path-str-ice.rs
Normal file
14
tests/ui/lint/decorate-def-path-str-ice.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// Checks that compiling this file with
|
||||
// `-Dunused_must_use -Awarnings --cap-lints=warn --crate-type=lib` does not ICE when emitting
|
||||
// diagnostics.
|
||||
// Issue: <https://github.com/rust-lang/rust/issues/121774>.
|
||||
|
||||
//@ compile-flags: -Dunused_must_use -Awarnings --cap-lints=warn --crate-type=lib
|
||||
//@ check-pass
|
||||
|
||||
#[must_use]
|
||||
fn f() {}
|
||||
|
||||
pub fn g() {
|
||||
f();
|
||||
}
|
Loading…
Reference in New Issue
Block a user