Closed
Description
I tried this code:
trait Sup<T> {
type Assoc: Default;
}
impl<T: Default> Sup<T> for () {
type Assoc = T;
}
impl<T: Default, U: Default> Dyn<T, U> for () {}
trait Dyn<A, B>: Sup<A, Assoc = A> + Sup<B> {}
fn main() {
let q: <dyn Dyn<i32, u32> as Sup<u32>>::Assoc = Default::default();
}
I expected to see this happen: It errors b/c we don't know what the associated type for <dyn Dyn<i32, u32> as Sup<u32>>::Assoc
is.
Instead, this happened: Codegen ICE.
Meta
rustc --version --verbose
:
rustc 1.85.0-nightly (a47555110 2024-11-22)
Backtrace
error: internal compiler error: compiler/rustc_middle/src/ty/instance.rs:587:21: failed to resolve instance for <<dyn Dyn<i32, u32> as Sup<u32>>::Assoc as Default>::default
--> src/main.rs:13:53
|
13 | let q: <dyn Dyn<i32, u32> as Sup<u32>>::Assoc = Default::default();
| ^^^^^^^^^^^^^^^^^^
thread 'rustc' panicked at compiler/rustc_middle/src/ty/instance.rs:587:21:
Box<dyn Any>
stack backtrace:
0: 0x79442cbce6ea - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h304520fd6a30aa07
1: 0x79442d419525 - core::fmt::write::hf5713710ce10ff22
2: 0x79442e234d91 - std::io::Write::write_fmt::hda708db57927dacf
3: 0x79442cbd0dbb - std::panicking::default_hook::{{closure}}::he1ad87607d0c11c5
4: 0x79442cbd0a2e - std::panicking::default_hook::h81c8cd2e7c59ee33
5: 0x79442bd9a5d7 - std[5204e9590b4985ef]::panicking::update_hook::<alloc[fd15fd9026f491e1]::boxed::Box<rustc_driver_impl[c41f2638408ed175]::install_ice_hook::{closure#0}>>::{closure#0}
6: 0x79442cbd16d7 - std::panicking::rust_panic_with_hook::had2118629c312a4a
7: 0x79442bdd1591 - std[5204e9590b4985ef]::panicking::begin_panic::<rustc_errors[98c49d204a493357]::ExplicitBug>::{closure#0}
8: 0x79442bdc51b6 - std[5204e9590b4985ef]::sys::backtrace::__rust_end_short_backtrace::<std[5204e9590b4985ef]::panicking::begin_panic<rustc_errors[98c49d204a493357]::ExplicitBug>::{closure#0}, !>
9: 0x79442bdc0716 - std[5204e9590b4985ef]::panicking::begin_panic::<rustc_errors[98c49d204a493357]::ExplicitBug>
10: 0x79442bdda611 - <rustc_errors[98c49d204a493357]::diagnostic::BugAbort as rustc_errors[98c49d204a493357]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
11: 0x79442c2d448d - <rustc_errors[98c49d204a493357]::DiagCtxtHandle>::span_bug::<rustc_span[233999951ced9cd1]::span_encoding::Span, alloc[fd15fd9026f491e1]::string::String>
12: 0x79442c376108 - rustc_middle[c83967c7761a8780]::util::bug::opt_span_bug_fmt::<rustc_span[233999951ced9cd1]::span_encoding::Span>::{closure#0}
13: 0x79442c35b11a - rustc_middle[c83967c7761a8780]::ty::context::tls::with_opt::<rustc_middle[c83967c7761a8780]::util::bug::opt_span_bug_fmt<rustc_span[233999951ced9cd1]::span_encoding::Span>::{closure#0}, !>::{closure#0}
14: 0x79442c35afcb - rustc_middle[c83967c7761a8780]::ty::context::tls::with_context_opt::<rustc_middle[c83967c7761a8780]::ty::context::tls::with_opt<rustc_middle[c83967c7761a8780]::util::bug::opt_span_bug_fmt<rustc_span[233999951ced9cd1]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
15: 0x79442a17cf27 - rustc_middle[c83967c7761a8780]::util::bug::span_bug_fmt::<rustc_span[233999951ced9cd1]::span_encoding::Span>
16: 0x79442daa9de0 - <rustc_middle[c83967c7761a8780]::ty::instance::Instance>::expect_resolve
17: 0x79442a8bb0d8 - rustc_monomorphize[d67c1690e64672e3]::collector::collect_items_rec::{closure#0}
18: 0x79442e3d1f21 - rustc_monomorphize[d67c1690e64672e3]::collector::collect_items_rec
19: 0x79442d9bfc06 - rustc_monomorphize[d67c1690e64672e3]::partitioning::collect_and_partition_mono_items
20: 0x79442e2ca1d6 - rustc_query_impl[2ecbb548ea5419f8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2ecbb548ea5419f8]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c83967c7761a8780]::query::erase::Erased<[u8; 24usize]>>
21: 0x79442e2ca19b - <rustc_query_impl[2ecbb548ea5419f8]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[d89802b8f5f07590]::ops::function::FnOnce<(rustc_middle[c83967c7761a8780]::ty::context::TyCtxt, ())>>::call_once
22: 0x79442e2c9e33 - rustc_query_system[842c6bba149f2c70]::query::plumbing::try_execute_query::<rustc_query_impl[2ecbb548ea5419f8]::DynamicConfig<rustc_query_system[842c6bba149f2c70]::query::caches::SingleCache<rustc_middle[c83967c7761a8780]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[2ecbb548ea5419f8]::plumbing::QueryCtxt, false>
23: 0x79442e2c9ba1 - rustc_query_impl[2ecbb548ea5419f8]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
24: 0x79442e26b942 - <rustc_codegen_llvm[1041eb84fe8a92c6]::LlvmCodegenBackend as rustc_codegen_ssa[4b0e0146219e1624]::traits::backend::CodegenBackend>::codegen_crate
25: 0x79442e562737 - <rustc_interface[706ab71263ce060a]::queries::Linker>::codegen_and_build_linker
26: 0x79442e1861d7 - rustc_interface[706ab71263ce060a]::interface::run_compiler::<core[d89802b8f5f07590]::result::Result<(), rustc_span[233999951ced9cd1]::ErrorGuaranteed>, rustc_driver_impl[c41f2638408ed175]::run_compiler::{closure#0}>::{closure#1}
27: 0x79442e23ed16 - std[5204e9590b4985ef]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[706ab71263ce060a]::util::run_in_thread_with_globals<rustc_interface[706ab71263ce060a]::interface::run_compiler<core[d89802b8f5f07590]::result::Result<(), rustc_span[233999951ced9cd1]::ErrorGuaranteed>, rustc_driver_impl[c41f2638408ed175]::run_compiler::{closure#0}>::{closure#1}, core[d89802b8f5f07590]::result::Result<(), rustc_span[233999951ced9cd1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d89802b8f5f07590]::result::Result<(), rustc_span[233999951ced9cd1]::ErrorGuaranteed>>
28: 0x79442e2779b0 - <<std[5204e9590b4985ef]::thread::Builder>::spawn_unchecked_<rustc_interface[706ab71263ce060a]::util::run_in_thread_with_globals<rustc_interface[706ab71263ce060a]::interface::run_compiler<core[d89802b8f5f07590]::result::Result<(), rustc_span[233999951ced9cd1]::ErrorGuaranteed>, rustc_driver_impl[c41f2638408ed175]::run_compiler::{closure#0}>::{closure#1}, core[d89802b8f5f07590]::result::Result<(), rustc_span[233999951ced9cd1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d89802b8f5f07590]::result::Result<(), rustc_span[233999951ced9cd1]::ErrorGuaranteed>>::{closure#1} as core[d89802b8f5f07590]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
29: 0x79442e277d2b - std::sys::pal::unix::thread::Thread::new::thread_start::hcdbd1049068002f4
30: 0x79442f806a94 - <unknown>
31: 0x79442f893a34 - clone
32: 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.82.0 (f6e511eec 2024-10-15) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items