-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICE: must_produce_diag: trimmed_def_paths called but no diagnostics emitted #121774
Comments
Bisects to Rust 1.55.0, and nightly-2021-07-20. In older stable and nightly releases, this compiles successfully. |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-medium |
Either way, this is probably easier to debug from scratch instead of digging around commits. |
Fix for a similar issue : #108162 |
Rollup merge of rust-lang#122578 - jieyouxu:guard-decorate, r=fee1-dead Only invoke `decorate` if the diag can eventually be emitted Lints can call [`trimmed_def_paths`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/print/fn.trimmed_def_paths.html#), such as through manual implementations of `LintDiagnostic` and calling `def_path_str`. /~https://github.com/rust-lang/rust/blob/05a2be3def211255dc7640b006ac10f0f02baf5c/compiler/rustc_lint/src/lints.rs#L1834-L1839 The emission of a lint eventually relies on [`TyCtxt::node_lint`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.node_lint), which has a `decorate` closure which is responsible for decorating the diagnostic with "lint stuff". `node_lint` in turn relies on [`lint_level`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/lint/fn.lint_level.html). Within `lint_level`, `decorate` is eventually called just before `Diag::emit` is called to decorate the diagnostic. However, if `-A warnings` or `--cap-lint=allow` are set, or if the unused_must_use lint is explicitly allowed, then `decorate` would be called, which would call `def_path_str`, but the diagnostic would never be emitted and hence would trigger the `must_produce_diag` ICE. To avoid calling `decorate` when we don't eventually emit the diagnostic, we check that: - if `--force-warn` is specified, then call `decorate`; otherwise - if we can emit warnings (or higher), then call `decorate`. Fixes rust-lang#121774.
Input:
rustc lib.rs -Dunused_must_use -Awarnings --cap-lints=warn --crate-type=lib
The text was updated successfully, but these errors were encountered: