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

ICE: failed to resolve instance for .. -Zprint-mono-items=eager #109098

Closed
matthiaskrgr opened this issue Mar 13, 2023 · 2 comments · Fixed by #109110
Closed

ICE: failed to resolve instance for .. -Zprint-mono-items=eager #109098

matthiaskrgr opened this issue Mar 13, 2023 · 2 comments · Fixed by #109110
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-monomorphization Issue: An error at monomorphization time. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

rustc file.rs -Zprint-mono-items=eager

#![crate_type = "lib"]

trait Visit {
    fn visit() {}
}

trait Array<'a> {
    type Element: 'a;
}

impl Visit for () where
    (): for<'a> Array<'a, Element=()>,
{}

Meta

rustc --version --verbose:

rustc 1.70.0-nightly (7b4f48927 2023-03-12)
binary: rustc
commit-hash: 7b4f48927dce585f747a58083b45ab62b9d73a53
commit-date: 2023-03-12
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7

Error output

<output>
Backtrace

error: internal compiler error: compiler/rustc_middle/src/ty/instance.rs:397:18: failed to resolve instance for <() as Visit>::visit

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/compiler/rustc_errors/src/lib.rs:1644:9
stack backtrace:
   0:     0x7ff93cd6651a - std::backtrace_rs::backtrace::libunwind::trace::hf7d75cca16fd1b61
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7ff93cd6651a - std::backtrace_rs::backtrace::trace_unsynchronized::hf5ec95734aab509d
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ff93cd6651a - std::sys_common::backtrace::_print_fmt::he95113413355c8cd
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7ff93cd6651a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h072d12f2e69ca92b
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ff93cdc9c5e - core::fmt::write::h1d23f16415e96af2
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/core/src/fmt/mod.rs:1232:17
   5:     0x7ff93cd59275 - std::io::Write::write_fmt::hcf1e413fde4ffcd5
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/io/mod.rs:1684:15
   6:     0x7ff93cd662e5 - std::sys_common::backtrace::_print::h6b2b14bedd5177e7
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7ff93cd662e5 - std::sys_common::backtrace::print::h09ccebfbcd382e89
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7ff93cd6905f - std::panicking::default_hook::{{closure}}::h4ee055db778febc2
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/panicking.rs:271:22
   9:     0x7ff93cd68d9b - std::panicking::default_hook::ha74f60e3a15d95fb
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/panicking.rs:290:9
  10:     0x7ff940097085 - rustc_driver_impl[d355a67661263e47]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7ff93cd6989d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h7f34603beb945e8f
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/alloc/src/boxed.rs:2002:9
  12:     0x7ff93cd6989d - std::panicking::rust_panic_with_hook::h4b5d379936d4932f
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/panicking.rs:696:13
  13:     0x7ff940602371 - std[e52d7c968ed01318]::panicking::begin_panic::<rustc_errors[45159b7f7e36021d]::ExplicitBug>::{closure#0}
  14:     0x7ff9405fdaa6 - std[e52d7c968ed01318]::sys_common::backtrace::__rust_end_short_backtrace::<std[e52d7c968ed01318]::panicking::begin_panic<rustc_errors[45159b7f7e36021d]::ExplicitBug>::{closure#0}, !>
  15:     0x7ff940686046 - std[e52d7c968ed01318]::panicking::begin_panic::<rustc_errors[45159b7f7e36021d]::ExplicitBug>
  16:     0x7ff940651e06 - std[e52d7c968ed01318]::panic::panic_any::<rustc_errors[45159b7f7e36021d]::ExplicitBug>
  17:     0x7ff94064d966 - <rustc_errors[45159b7f7e36021d]::HandlerInner>::bug::<&alloc[fc860cae0dfa1ab1]::string::String>
  18:     0x7ff94064d630 - <rustc_errors[45159b7f7e36021d]::Handler>::bug::<&alloc[fc860cae0dfa1ab1]::string::String>
  19:     0x7ff940639a9b - rustc_middle[a96ac5d591578447]::util::bug::opt_span_bug_fmt::<rustc_span[f8bdfaef83e46314]::span_encoding::Span>::{closure#0}
  20:     0x7ff9406384fa - rustc_middle[a96ac5d591578447]::ty::context::tls::with_opt::<rustc_middle[a96ac5d591578447]::util::bug::opt_span_bug_fmt<rustc_span[f8bdfaef83e46314]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7ff9406384c6 - rustc_middle[a96ac5d591578447]::ty::context::tls::with_context_opt::<rustc_middle[a96ac5d591578447]::ty::context::tls::with_opt<rustc_middle[a96ac5d591578447]::util::bug::opt_span_bug_fmt<rustc_span[f8bdfaef83e46314]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7ff9406399e6 - rustc_middle[a96ac5d591578447]::util::bug::opt_span_bug_fmt::<rustc_span[f8bdfaef83e46314]::span_encoding::Span>
  23:     0x7ff93e6b44b3 - rustc_middle[a96ac5d591578447]::util::bug::bug_fmt
  24:     0x7ff93fa29e8d - <rustc_middle[a96ac5d591578447]::ty::instance::Instance>::expect_resolve
  25:     0x7ff93f5b918a - rustc_monomorphize[237522c315bd14cc]::collector::collect_roots
  26:     0x7ff93f5b3f1e - <rustc_session[7e23441c2db8ce4a]::session::Session>::time::<alloc[fc860cae0dfa1ab1]::vec::Vec<rustc_middle[a96ac5d591578447]::mir::mono::MonoItem>, rustc_monomorphize[237522c315bd14cc]::collector::collect_crate_mono_items::{closure#0}>
  27:     0x7ff93f5b3cd1 - rustc_monomorphize[237522c315bd14cc]::collector::collect_crate_mono_items
  28:     0x7ff93f5b2160 - rustc_monomorphize[237522c315bd14cc]::partitioning::collect_and_partition_mono_items
  29:     0x7ff93e8a1372 - rustc_query_system[704b80a7bc44cd49]::query::plumbing::try_execute_query::<rustc_query_impl[217bee59c5548bf5]::queries::collect_and_partition_mono_items, rustc_query_impl[217bee59c5548bf5]::plumbing::QueryCtxt>
  30:     0x7ff93e8a102d - <rustc_query_impl[217bee59c5548bf5]::Queries as rustc_middle[a96ac5d591578447]::ty::query::QueryEngine>::collect_and_partition_mono_items
  31:     0x7ff93f852bd7 - rustc_codegen_ssa[d7553c89eed4006]::back::symbol_export::exported_symbols_provider_local
  32:     0x7ff93f7e35ba - rustc_query_system[704b80a7bc44cd49]::query::plumbing::try_execute_query::<rustc_query_impl[217bee59c5548bf5]::queries::exported_symbols, rustc_query_impl[217bee59c5548bf5]::plumbing::QueryCtxt>
  33:     0x7ff93f7e3211 - <rustc_query_impl[217bee59c5548bf5]::Queries as rustc_middle[a96ac5d591578447]::ty::query::QueryEngine>::exported_symbols
  34:     0x7ff93f34b042 - <rustc_metadata[836a88d53bc31123]::rmeta::encoder::EncodeContext>::encode_crate_root
  35:     0x7ff93f2dc516 - rustc_metadata[836a88d53bc31123]::rmeta::encoder::encode_metadata_impl
  36:     0x7ff93f2d68dc - rustc_data_structures[cc19bc993ab9b64]::sync::join::<rustc_metadata[836a88d53bc31123]::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata[836a88d53bc31123]::rmeta::encoder::encode_metadata::{closure#1}, (), ()>
  37:     0x7ff93f2d65e1 - rustc_metadata[836a88d53bc31123]::rmeta::encoder::encode_metadata
  38:     0x7ff93f2d57ea - rustc_metadata[836a88d53bc31123]::fs::encode_and_write_metadata
  39:     0x7ff93f2cee2e - rustc_interface[6bf42eb308c32713]::passes::start_codegen
  40:     0x7ff93f2cb948 - <rustc_middle[a96ac5d591578447]::ty::context::GlobalCtxt>::enter::<<rustc_interface[6bf42eb308c32713]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[125d846441ac421f]::result::Result<alloc[fc860cae0dfa1ab1]::boxed::Box<dyn core[125d846441ac421f]::any::Any>, rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>>
  41:     0x7ff93f2c9774 - <rustc_interface[6bf42eb308c32713]::queries::Queries>::ongoing_codegen
  42:     0x7ff93f2c84cc - rustc_span[f8bdfaef83e46314]::with_source_map::<core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>, rustc_interface[6bf42eb308c32713]::interface::run_compiler<core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>, rustc_driver_impl[d355a67661263e47]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  43:     0x7ff93f2bf70c - std[e52d7c968ed01318]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[6bf42eb308c32713]::util::run_in_thread_pool_with_globals<rustc_interface[6bf42eb308c32713]::interface::run_compiler<core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>, rustc_driver_impl[d355a67661263e47]::run_compiler::{closure#1}>::{closure#0}, core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>>
  44:     0x7ff93f2bf13a - <<std[e52d7c968ed01318]::thread::Builder>::spawn_unchecked_<rustc_interface[6bf42eb308c32713]::util::run_in_thread_pool_with_globals<rustc_interface[6bf42eb308c32713]::interface::run_compiler<core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>, rustc_driver_impl[d355a67661263e47]::run_compiler::{closure#1}>::{closure#0}, core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[125d846441ac421f]::result::Result<(), rustc_span[f8bdfaef83e46314]::ErrorGuaranteed>>::{closure#1} as core[125d846441ac421f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7ff93cd73793 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc0a50816e1eb2bba
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/alloc/src/boxed.rs:1988:9
  46:     0x7ff93cd73793 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb2f83fc2049033c3
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/alloc/src/boxed.rs:1988:9
  47:     0x7ff93cd73793 - std::sys::unix::thread::Thread::new::thread_start::hce5861512f8bf7ea
                               at /rustc/7b4f48927dce585f747a58083b45ab62b9d73a53/library/std/src/sys/unix/thread.rs:108:17
  48:     0x7ff93caf4bb5 - <unknown>
  49:     0x7ff93cb76d90 - <unknown>
  50:                0x0 - <unknown>

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.70.0-nightly (7b4f48927 2023-03-12) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z print-mono-items=eager

query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
#1 [exported_symbols] collecting exported symbols for crate `0`
end of query stack
error: aborting due to previous error

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. I-monomorphization Issue: An error at monomorphization time. labels Mar 13, 2023
@matthiaskrgr
Copy link
Member Author

reduced

#![crate_type = "lib"]

trait Visit {
    fn visit() {}
}

trait Array<'a> {}

impl Visit for () where
    (): for<'a> Array<'a, >,
{}

@compiler-errors
Copy link
Member

This actually repro's with -Clink-dead-code=on as well.

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) ❄️ I-monomorphization Issue: An error at monomorphization time. requires-nightly This issue requires a nightly compiler in some way. 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.

2 participants