Skip to content
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

error: internal compiler error: trimmed_def_paths constructed #89775

Closed
wooster0 opened this issue Oct 11, 2021 · 4 comments · Fixed by #89785
Closed

error: internal compiler error: trimmed_def_paths constructed #89775

wooster0 opened this issue Oct 11, 2021 · 4 comments · Fixed by #89785
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@wooster0
Copy link
Contributor

wooster0 commented Oct 11, 2021

I came across this while working on #89737. Sadly I wasn't really able to minimize this.

  1. Checkout this branch: https://github.com/r00ster91/rust/tree/uselog10 and go to 428a47987a4943525d50ea4f80fb6cb1b4bce58c (but other commits will likely work too).
  2. Go to https://github.com/r00ster91/rust/blob/428a47987a4943525d50ea4f80fb6cb1b4bce58c/library/alloc/src/string.rs#L2363 and paste in the following:
fn x<T>(val: &T) {
    let mut buf = String::new();
    let mut formatter = core::fmt::Formatter::new(&mut buf);
    fmt::Display::fmt(val, &mut formatter).unwrap();
}
$ RUST_BACKTRACE=1 ./x.py check
Updating only changed submodules
Submodules updated in 0.02 seconds
    Finished dev [unoptimized + debuginfo] target(s) in 0.14s
Checking stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Checking alloc v0.0.0 (/home/hiyoko/Code/rust/library/alloc)
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs:696:81
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/core/src/panicking.rs:101:14
   2: core::panicking::panic
             at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/core/src/panicking.rs:50:5
   3: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt>::suggest_add_reference_to_arg
   4: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_selection_error
   5: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
   6: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
   7: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_argument_types
   8: rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::confirm_builtin_call
   9: rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
  10: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  11: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  12: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  13: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  14: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_stmt
  15: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  16: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  17: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_return_expr
  18: rustc_typeck::check::check::check_fn
  19: rustc_infer::infer::InferCtxtBuilder::enter
  20: rustc_typeck::check::typeck
  21: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  22: rustc_data_structures::stack::ensure_sufficient_stack
  23: rustc_query_system::query::plumbing::force_query_with_job
  24: rustc_query_system::query::plumbing::get_query_impl
  25: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
  26: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners
  27: rustc_typeck::check::typeck_item_bodies
  28: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  29: rustc_query_system::query::plumbing::force_query_with_job
  30: rustc_query_system::query::plumbing::get_query_impl
  31: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
  32: rustc_session::utils::<impl rustc_session::session::Session>::time
  33: rustc_typeck::check_crate
  34: rustc_interface::passes::analysis
  35: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  36: rustc_data_structures::stack::ensure_sufficient_stack
  37: rustc_query_system::query::plumbing::force_query_with_job
  38: rustc_query_system::query::plumbing::get_query_impl
  39: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  40: rustc_interface::passes::QueryContext::enter
  41: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  42: rustc_span::with_source_map
  43: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.56.0-beta.1 (e784c962e 2021-09-07) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z macro-backtrace -Z crate-attr=doc(html_root_url="https://doc.rust-lang.org/nightly/") -Z binary-dep-depinfo -Z force-unstable-if-unmarked -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -C incremental -C link-args=-Wl,-rpath,$ORIGIN/../lib -C prefer-dynamic -C llvm-args=-import-instr-limit=10 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [typeck] type-checking `string::x`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: internal compiler error: trimmed_def_paths constructed
  |
  = note: delayed at    0: rustc_errors::Handler::delay_good_path_bug
             1: rustc_middle::ty::print::pretty::trimmed_def_paths
             2: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
             3: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
             4: rustc_data_structures::stack::ensure_sufficient_stack
             5: rustc_query_system::query::plumbing::force_query_with_job
             6: rustc_query_system::query::plumbing::get_query_impl
             7: rustc_query_system::query::plumbing::get_query
             8: <rustc_middle::ty::print::pretty::FmtPrinter<F> as rustc_middle::ty::print::Printer>::print_def_path
             9: rustc_middle::ty::print::pretty::<impl rustc_middle::ty::context::TyCtxt>::def_path_str_with_substs
            10: rustc_middle::ty::print::pretty::<impl rustc_middle::ty::context::TyCtxt>::def_path_str
            11: rustc_trait_selection::traits::on_unimplemented::OnUnimplementedFormatString::format
            12: rustc_trait_selection::traits::on_unimplemented::OnUnimplementedDirective::evaluate
            13: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::on_unimplemented::InferCtxtExt>::on_unimplemented_note
            14: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_selection_error
            15: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
            16: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
            17: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_argument_types
            18: rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::confirm_builtin_call
            19: rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
            20: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
            21: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
            22: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
            23: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
            24: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_stmt
            25: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
            26: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
            27: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_return_expr
            28: rustc_typeck::check::check::check_fn
            29: rustc_infer::infer::InferCtxtBuilder::enter
            30: rustc_typeck::check::typeck
            31: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
            32: rustc_data_structures::stack::ensure_sufficient_stack
            33: rustc_query_system::query::plumbing::force_query_with_job
            34: rustc_query_system::query::plumbing::get_query_impl
            35: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
            36: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners
            37: rustc_typeck::check::typeck_item_bodies
            38: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
            39: rustc_query_system::query::plumbing::force_query_with_job
            40: rustc_query_system::query::plumbing::get_query_impl
            41: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
            42: rustc_session::utils::<impl rustc_session::session::Session>::time
            43: rustc_typeck::check_crate
            44: rustc_interface::passes::analysis
            45: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
            46: rustc_data_structures::stack::ensure_sufficient_stack
            47: rustc_query_system::query::plumbing::force_query_with_job
            48: rustc_query_system::query::plumbing::get_query_impl
            49: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
            50: rustc_interface::passes::QueryContext::enter
            51: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
            52: rustc_span::with_source_map
            53: scoped_tls::ScopedKey<T>::set
            54: std::sys_common::backtrace::__rust_begin_short_backtrace
            55: core::ops::function::FnOnce::call_once{{vtable.shim}}
            56: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/alloc/src/boxed.rs:1636:9
            57: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/alloc/src/boxed.rs:1636:9
            58: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/sys/unix/thread.rs:106:17
            59: <unknown>
            60: clone
          

thread 'rustc' panicked at 'no warnings or errors encountered even though `delayed_good_path_bugs` issued', compiler/rustc_errors/src/lib.rs:1166:13
stack backtrace:
   0:     0x7f9a0c91e4fc - std::backtrace_rs::backtrace::libunwind::trace::h51faa62df48810e4
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f9a0c91e4fc - std::backtrace_rs::backtrace::trace_unsynchronized::h91de4d8e16d607e4
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f9a0c91e4fc - std::sys_common::backtrace::_print_fmt::h71b0935f97e4322c
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f9a0c91e4fc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9a78218788c14e18
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f9a0c97c20c - core::fmt::write::h3381b3176fe2b3d3
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/core/src/fmt/mod.rs:1150:17
   5:     0x7f9a0c90f435 - std::io::Write::write_fmt::h1d5220480c7a2437
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/io/mod.rs:1667:15
   6:     0x7f9a0c921a60 - std::sys_common::backtrace::_print::h4b77abc4d907ed0e
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f9a0c921a60 - std::sys_common::backtrace::print::hb170c60b542377ad
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f9a0c921a60 - std::panicking::default_hook::{{closure}}::h12bbda9af8901ee3
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/panicking.rs:210:50
   9:     0x7f9a0c921617 - std::panicking::default_hook::h8c6c66d3f3ba6768
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/panicking.rs:227:9
  10:     0x7f9a0d0f5861 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h5d5f6bcd40777e95
  11:     0x7f9a0c922279 - std::panicking::rust_panic_with_hook::h36f2fa0bb09f4069
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/panicking.rs:628:17
  12:     0x7f9a0c921d30 - std::panicking::begin_panic_handler::{{closure}}::h9c42b65a42d06a7a
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/panicking.rs:521:13
  13:     0x7f9a0c91e9c4 - std::sys_common::backtrace::__rust_end_short_backtrace::hc791bddfe31e532c
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7f9a0c921c99 - rust_begin_unwind
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/panicking.rs:517:5
  15:     0x7f9a0c8e681b - std::panicking::begin_panic_fmt::h32ac317c038a272d
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/panicking.rs:460:5
  16:     0x7f9a0f65254e - rustc_errors::HandlerInner::flush_delayed::hc1a0dc2a3b52b7c5
  17:     0x7f9a0f650e41 - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::h6b6fa9db3b176321
  18:     0x7f9a0ec14b16 - core::ptr::drop_in_place<rustc_session::parse::ParseSess>::h0f64c3a6d9ae48b4
  19:     0x7f9a0ec16b0e - <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop::h38ccacfabbb0cd9a
  20:     0x7f9a0ebe8a8d - core::ptr::drop_in_place<rustc_interface::interface::Compiler>::he462bcfe0a585c06
  21:     0x7f9a0ebe876c - rustc_span::with_source_map::h42000c6d4d4801a0
  22:     0x7f9a0ebfa858 - scoped_tls::ScopedKey<T>::set::h9c4e59a22d2be862
  23:     0x7f9a0ebe99db - std::sys_common::backtrace::__rust_begin_short_backtrace::hb112af792d752f1d
  24:     0x7f9a0ebe6b95 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h9bf5ff18e54ee278
  25:     0x7f9a0c92e8c3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbbbb32ef11ea0ad2
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/alloc/src/boxed.rs:1636:9
  26:     0x7f9a0c92e8c3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3b8ef23699fc5385
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/alloc/src/boxed.rs:1636:9
  27:     0x7f9a0c92e8c3 - std::sys::unix::thread::Thread::new::thread_start::ha57f5cba35f709b7
                               at /rustc/e784c962ea252f0874a4305168077e7048cb39e9/library/std/src/sys/unix/thread.rs:106:17
  28:     0x7f9a0c85d3ba - <unknown>
  29:     0x7f9a0c775b03 - clone
  30:                0x0 - <unknown>

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.56.0-beta.1 (e784c962e 2021-09-07) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z macro-backtrace -Z crate-attr=doc(html_root_url="https://doc.rust-lang.org/nightly/") -Z binary-dep-depinfo -Z force-unstable-if-unmarked -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -C incremental -C link-args=-Wl,-rpath,$ORIGIN/../lib -C prefer-dynamic -C llvm-args=-import-instr-limit=10 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
thread panicked while panicking. aborting.
rustc exited with signal: 4 (core dumped)
error: could not compile `alloc`

Caused by:
  process didn't exit successfully: `/home/hiyoko/Code/rust/build/bootstrap/debug/rustc --crate-name alloc --edition=2018 library/alloc/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -C metadata=621a2bc69488ac6f -C extra-filename=-621a2bc69488ac6f --out-dir /home/hiyoko/Code/rust/build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -C incremental=/home/hiyoko/Code/rust/build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/incremental -L dependency=/home/hiyoko/Code/rust/build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps -L dependency=/home/hiyoko/Code/rust/build/x86_64-unknown-linux-gnu/stage0-std/release/deps --extern compiler_builtins=/home/hiyoko/Code/rust/build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-686309a2c7d6dc4a.rmeta --extern core=/home/hiyoko/Code/rust/build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps/libcore-a6e29391d99a380a.rmeta --cfg=bootstrap -Zmacro-backtrace '-Clink-args=-Wl,-rpath,$ORIGIN/../lib' -Cprefer-dynamic -Cllvm-args=-import-instr-limit=10 '-Zcrate-attr=doc(html_root_url="https://doc.rust-lang.org/nightly/")' -Z binary-dep-depinfo` (exit status: 254)
Build completed unsuccessfully in 0:00:01
@wooster0 wooster0 added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 11, 2021
@the8472
Copy link
Member

the8472 commented Oct 11, 2021

See also #89564

@nbdd0121
Copy link
Contributor

Slightly minimized: place

#![no_std]
#![feature(fmt_internals)]
#![feature(compiler_builtins)]
#![compiler_builtins]

use core::fmt;

struct String;

impl core::fmt::Write for String {
    fn write_str(&mut self, _: &str) -> fmt::Result {
        Ok(())
    }
}

fn x<T>(val: &T) {
    let mut buf = String;
    let mut formatter = core::fmt::Formatter::new(&mut buf);
    core::fmt::Display::fmt(val, &mut formatter).unwrap();
}

in ice.rs. Then run:

RUSTC_BOOTSTRAP=1 rustc +beta library/core/src/lib.rs --crate-type=lib --edition=2018 --cfg bootstrap --crate-name=core
RUSTC_BOOTSTRAP=1 rustc +beta ice.rs --crate-type=lib --edition=2018 --cfg bootstrap --extern core=libcore.rlib

will produce the ICE.

@nbdd0121
Copy link
Contributor

Caused by #89479, cc @camsteffen @Manishearth.

That PR renames a lot of diagnostic items, but didn't use cfg(bootstrap) to gate the name change, so causes breakage when compiling stage 0 std or stage 1 compiler.

@Manishearth
Copy link
Member

Oops, sorry!

@bors bors closed this as completed in f94a325 Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants