Skip to content

ICE: must_produce_diag: trimmed_def_paths called but no diagnostics emitted #121774

Closed

Description

@dtolnay

Input:

// lib.rs

#[must_use]
fn f() {}

pub fn g() {
    f();
}

rustc lib.rs -Dunused_must_use -Awarnings --cap-lints=warn --crate-type=lib

thread 'rustc' panicked at compiler/rustc_errors/src/lib.rs:572:17:
must_produce_diag: trimmed_def_paths called but no diagnostics emitted; use `DelayDm` for lints or `with_no_trimmed_paths` for debugging
stack backtrace:
   0:     0x7f268108cdb6 - std::backtrace_rs::backtrace::libunwind::trace::h341f79bffd736d88
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f268108cdb6 - std::backtrace_rs::backtrace::trace_unsynchronized::h699175639bf0c53f
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f268108cdb6 - std::sys_common::backtrace::_print_fmt::he64554b6b8851325
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f268108cdb6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h6f1d81aff3ba783c
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f26810ddd3c - core::fmt::rt::Argument::fmt::ha094c70f8a774861
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/core/src/fmt/rt.rs:142:9
   5:     0x7f26810ddd3c - core::fmt::write::h7f13c4b287d5364f
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f268108163f - std::io::Write::write_fmt::h33c62cb7f1d9ccd2
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/std/src/io/mod.rs:1846:15
   7:     0x7f268108cb64 - std::sys_common::backtrace::_print::h5a328173cecd6a17
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f268108cb64 - std::sys_common::backtrace::print::h40f459d9b04f57e7
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f268108f8ab - std::panicking::default_hook::{{closure}}::hd2a3df71af903bed
  10:     0x7f268108f5f9 - std::panicking::default_hook::ha092baec2054d09a
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/std/src/panicking.rs:292:9
  11:     0x7f267dc9bcbc - std[aeaa4a650f96ca4f]::panicking::update_hook::<alloc[4c4126b71025da3b]::boxed::Box<rustc_driver_impl[2ad8c6e0ef02d37]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f2681090010 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::he192bb5ab07c6e66
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/alloc/src/boxed.rs:2030:9
  13:     0x7f2681090010 - std::panicking::rust_panic_with_hook::h46c6fddd63cff830
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/std/src/panicking.rs:783:13
  14:     0x7f268108fd19 - std::panicking::begin_panic_handler::{{closure}}::h8abc72b89d98e75c
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/std/src/panicking.rs:649:13
  15:     0x7f268108d296 - std::sys_common::backtrace::__rust_end_short_backtrace::h1eafc870bd031abe
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f268108fa84 - rust_begin_unwind
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/std/src/panicking.rs:645:5
  17:     0x7f26810da255 - core::panicking::panic_fmt::hd079a8afc216673e
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/core/src/panicking.rs:72:14
  18:     0x7f26805d5ea2 - <rustc_errors[8f2d5467e268fcd1]::DiagCtxtInner as core[ceaa87f59aeb8bba]::ops::drop::Drop>::drop.cold.0
  19:     0x7f267fb5719c - core[ceaa87f59aeb8bba]::ptr::drop_in_place::<rustc_errors[8f2d5467e268fcd1]::DiagCtxt>
  20:     0x7f267fdee217 - core[ceaa87f59aeb8bba]::ptr::drop_in_place::<rustc_session[6420a5b3483699f8]::parse::ParseSess>
  21:     0x7f267fdee7f1 - core[ceaa87f59aeb8bba]::ptr::drop_in_place::<rustc_interface[91b806f92bb77cda]::interface::Compiler>
  22:     0x7f267fd3e672 - rustc_interface[91b806f92bb77cda]::interface::run_compiler::<core[ceaa87f59aeb8bba]::result::Result<(), rustc_span[ac3b12a2af12cb0d]::ErrorGuaranteed>, rustc_driver_impl[2ad8c6e0ef02d37]::run_compiler::{closure#0}>::{closure#0}
  23:     0x7f267ffddd05 - std[aeaa4a650f96ca4f]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[91b806f92bb77cda]::util::run_in_thread_with_globals<rustc_interface[91b806f92bb77cda]::util::run_in_thread_pool_with_globals<rustc_interface[91b806f92bb77cda]::interface::run_compiler<core[ceaa87f59aeb8bba]::result::Result<(), rustc_span[ac3b12a2af12cb0d]::ErrorGuaranteed>, rustc_driver_impl[2ad8c6e0ef02d37]::run_compiler::{closure#0}>::{closure#0}, core[ceaa87f59aeb8bba]::result::Result<(), rustc_span[ac3b12a2af12cb0d]::ErrorGuaranteed>>::{closure#0}, core[ceaa87f59aeb8bba]::result::Result<(), rustc_span[ac3b12a2af12cb0d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ceaa87f59aeb8bba]::result::Result<(), rustc_span[ac3b12a2af12cb0d]::ErrorGuaranteed>>
  24:     0x7f267ffddb32 - <<std[aeaa4a650f96ca4f]::thread::Builder>::spawn_unchecked_<rustc_interface[91b806f92bb77cda]::util::run_in_thread_with_globals<rustc_interface[91b806f92bb77cda]::util::run_in_thread_pool_with_globals<rustc_interface[91b806f92bb77cda]::interface::run_compiler<core[ceaa87f59aeb8bba]::result::Result<(), rustc_span[ac3b12a2af12cb0d]::ErrorGuaranteed>, rustc_driver_impl[2ad8c6e0ef02d37]::run_compiler::{closure#0}>::{closure#0}, core[ceaa87f59aeb8bba]::result::Result<(), rustc_span[ac3b12a2af12cb0d]::ErrorGuaranteed>>::{closure#0}, core[ceaa87f59aeb8bba]::result::Result<(), rustc_span[ac3b12a2af12cb0d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ceaa87f59aeb8bba]::result::Result<(), rustc_span[ac3b12a2af12cb0d]::ErrorGuaranteed>>::{closure#1} as core[ceaa87f59aeb8bba]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f26810999e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4c4227d670230628
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/alloc/src/boxed.rs:2016:9
  26:     0x7f26810999e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4bc52f0323c8ae82
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/alloc/src/boxed.rs:2016:9
  27:     0x7f26810999e5 - std::sys::pal::unix::thread::Thread::new::thread_start::hd34fbf5607308b31
                               at /rustc/c475e2303b551d726307c646181e0677af1e0069/library/std/src/sys/pal/unix/thread.rs:108:17
  28:     0x7f267aa94ac3 - start_thread
                               at ./nptl/pthread_create.c:442:8
  29:     0x7f267ab26850 - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  30:                0x0 - <unknown>
$ rustc --version --verbose
rustc 1.78.0-nightly (c475e2303 2024-02-28)
binary: rustc
commit-hash: c475e2303b551d726307c646181e0677af1e0069
commit-date: 2024-02-28
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Feb 29, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 29, 2024
  3. dtolnay commented on Feb 29, 2024

    @dtolnay
    MemberAuthor

    Bisects to Rust 1.55.0, and nightly-2021-07-20. In older stable and nightly releases, this compiles successfully.

  4. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Feb 29, 2024
  5. added
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    on Feb 29, 2024
  6. apiraino commented on Feb 29, 2024

    @apiraino
    Contributor

    WG-prioritization assigning priority (Zulip discussion).

    @rustbot label -I-prioritize +P-medium

  7. added and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Feb 29, 2024
  8. apiraino commented on Feb 29, 2024

    @apiraino
    Contributor

    bisection points to rollup 27f5d83

    If I had to guess, I'd say that #93590 looks like the one. It's the only one in the rollup touching diagnostic code. Possibly my reasoning is off (pls correct me).

  9. dtolnay commented on Feb 29, 2024

    @dtolnay
    MemberAuthor

    Something went wrong with your bisect, as 27f5d83 is from 2022-02-02, whereas this ICE is present in nightly-2021-07-20.

    #86970 looks the most likely to me.

  10. Noratrieb commented on Feb 29, 2024

    @Noratrieb
    Member

    Either way, this is probably easier to debug from scratch instead of digging around commits.
    Previous issue with this ICE message should reveal information on how to fix these issues, which arise from eagerly formatting paths in lints instead of only when they're emitted.

  11. added
    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 29, 2024
  12. chenyukang commented on Mar 2, 2024

    @chenyukang
    Member

    Fix for a similar issue : #108162

  13. added a commit that references this issue on Mar 17, 2024
    8e748c0
  14. added a commit that references this issue on Mar 17, 2024
    cd654c6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions