Closed
Description
auto-reduced (treereduce-rust):
trait X {}
trait Z {
type Assoc: Y;
}
struct A<T>(T);
impl<T: X> Z for A<T> {
type Assoc = T;
}
impl<T> From<<A<A<T>> as Z>::Assoc> for T {}
original:
#![feature(specialization)]
#![allow(incomplete_features)]
trait X {}
trait Y: X {}
trait Z {
type Assoc: Y;
}
struct A<T>(T);
impl<T> Y for T where T: X {}
impl<T: X> Z for A<T> {
type Assoc = T;
}
// this impl is invalid, but causes an ICE anyway
impl<T> From<<A<A<T>> as Z>::Assoc> for T {}
//~^ ERROR type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
fn main() {}
Version information
rustc 1.80.0-nightly (9fa862ff2 2024-05-04)
binary: rustc
commit-hash: 9fa862ff29ccfea885f8b1f33f4a507d456ae551
commit-date: 2024-05-04
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=coherence
Program output
error[E0405]: cannot find trait `Y` in this scope
--> /tmp/icemaker_global_tempdir.3x50tymIDXeY/rustc_testrunner_tmpdir_reporting.LJEEw1d4XM4C/mvce.rs:4:17
|
1 | trait X {}
| ------- similarly named trait `X` defined here
...
4 | type Assoc: Y;
| ^ help: a trait with a similar name exists: `X`
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.3x50tymIDXeY/rustc_testrunner_tmpdir_reporting.LJEEw1d4XM4C/mvce.rs:12:45
|
12 | impl<T> From<<A<A<T>> as Z>::Assoc> for T {}
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.3x50tymIDXeY/rustc_testrunner_tmpdir_reporting.LJEEw1d4XM4C/mvce.rs`
thread 'rustc' panicked at compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs:354:18:
called `Result::unwrap()` on an `Err` value: Sorts(ExpectedFound { expected: Alias(Projection, AliasTy { args: [A<A<Alias(Projection, AliasTy { args: [A<A<?6t>>], def_id: DefId(0:5 ~ mvce[9f0c]::Z::Assoc) })>>], def_id: DefId(0:5 ~ mvce[9f0c]::Z::Assoc) }), found: A<Alias(Projection, AliasTy { args: [A<A<?6t>>], def_id: DefId(0:5 ~ mvce[9f0c]::Z::Assoc) })> })
stack backtrace:
0: 0x74a6c565aef5 - std::backtrace_rs::backtrace::libunwind::trace::hf338f796a90cfd6e
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
1: 0x74a6c565aef5 - std::backtrace_rs::backtrace::trace_unsynchronized::h5d50ad2bb2b711c7
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x74a6c565aef5 - std::sys_common::backtrace::_print_fmt::hd839da3691208d62
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/std/src/sys_common/backtrace.rs:68:5
3: 0x74a6c565aef5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h83d8fc7c529aa9c8
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/std/src/sys_common/backtrace.rs:44:22
4: 0x74a6c56aa12b - core::fmt::rt::Argument::fmt::hc89f952445ec87cd
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/core/src/fmt/rt.rs:165:63
5: 0x74a6c56aa12b - core::fmt::write::hab4ec40d2f94d282
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/core/src/fmt/mod.rs:1157:21
6: 0x74a6c564f97f - std::io::Write::write_fmt::h80ec83f1a70093e1
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/std/src/io/mod.rs:1832:15
7: 0x74a6c565acce - std::sys_common::backtrace::_print::h02236002ae38795d
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/std/src/sys_common/backtrace.rs:47:5
8: 0x74a6c565acce - std::sys_common::backtrace::print::hd0708e89b2c5879c
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/std/src/sys_common/backtrace.rs:34:9
9: 0x74a6c565d639 - std::panicking::default_hook::{{closure}}::hd0afacda5c8cf9de
10: 0x74a6c565d37d - std::panicking::default_hook::h5e6fb6e8ba09191a
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/std/src/panicking.rs:298:9
11: 0x74a6c20b6a2c - std[23e06557834ee477]::panicking::update_hook::<alloc[c2573fa871629292]::boxed::Box<rustc_driver_impl[9a1cf205da409778]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x74a6c565dd36 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h17b339f4f9cbc47f
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/alloc/src/boxed.rs:2036:9
13: 0x74a6c565dd36 - std::panicking::rust_panic_with_hook::hcbe6cb1d0d4e1ee5
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/std/src/panicking.rs:799:13
14: 0x74a6c565dae4 - std::panicking::begin_panic_handler::{{closure}}::hc67a3006b30e8198
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/std/src/panicking.rs:664:13
15: 0x74a6c565b3b9 - std::sys_common::backtrace::__rust_end_short_backtrace::haf9fab6fbf5a2d3a
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/std/src/sys_common/backtrace.rs:171:18
16: 0x74a6c565d817 - rust_begin_unwind
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/std/src/panicking.rs:652:5
17: 0x74a6c56a66f3 - core::panicking::panic_fmt::h840d3ad0f99cdd30
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/core/src/panicking.rs:72:14
18: 0x74a6c56a6d36 - core::result::unwrap_failed::h55283fe3fc162273
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/core/src/result.rs:1654:5
19: 0x74a6c403a00a - <rustc_trait_selection[a8abe391119244a1]::solve::eval_ctxt::EvalCtxt>::unify_query_var_values
20: 0x74a6c402dbc3 - <rustc_trait_selection[a8abe391119244a1]::solve::inspect::analyse::InspectCandidate>::instantiate_nested_goals
21: 0x74a6c2bfed2e - <rustc_trait_selection[a8abe391119244a1]::traits::coherence::AmbiguityCausesVisitor as rustc_trait_selection[a8abe391119244a1]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
22: 0x74a6c2bfedc3 - <rustc_trait_selection[a8abe391119244a1]::traits::coherence::AmbiguityCausesVisitor as rustc_trait_selection[a8abe391119244a1]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
23: 0x74a6c3925b1a - rustc_trait_selection[a8abe391119244a1]::traits::coherence::overlap
24: 0x74a6c407660b - <rustc_middle[490be60d42aefdb2]::traits::specialization_graph::Children as rustc_trait_selection[a8abe391119244a1]::traits::specialize::specialization_graph::ChildrenExt>::insert
25: 0x74a6c0a75778 - <rustc_middle[490be60d42aefdb2]::traits::specialization_graph::Graph as rustc_trait_selection[a8abe391119244a1]::traits::specialize::specialization_graph::GraphExt>::insert
26: 0x74a6c3484ebc - rustc_trait_selection[a8abe391119244a1]::traits::specialize::specialization_graph_provider
27: 0x74a6c3484a1f - rustc_query_impl[c8a8c0bff8e01ad6]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c8a8c0bff8e01ad6]::query_impl::specialization_graph_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[490be60d42aefdb2]::query::erase::Erased<[u8; 8usize]>>
28: 0x74a6c3487417 - rustc_query_system[4b44ec3e43617094]::query::plumbing::try_execute_query::<rustc_query_impl[c8a8c0bff8e01ad6]::DynamicConfig<rustc_query_system[4b44ec3e43617094]::query::caches::DefIdCache<rustc_middle[490be60d42aefdb2]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[c8a8c0bff8e01ad6]::plumbing::QueryCtxt, false>
29: 0x74a6c3b8f8f4 - rustc_query_impl[c8a8c0bff8e01ad6]::query_impl::specialization_graph_of::get_query_non_incr::__rust_end_short_backtrace
30: 0x74a6c3ed3030 - rustc_hir_analysis[818e5c0bff74b8ba]::coherence::coherent_trait
31: 0x74a6c3ed2d23 - rustc_query_impl[c8a8c0bff8e01ad6]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c8a8c0bff8e01ad6]::query_impl::coherent_trait::dynamic_query::{closure#2}::{closure#0}, rustc_middle[490be60d42aefdb2]::query::erase::Erased<[u8; 1usize]>>
32: 0x74a6c3948093 - rustc_query_system[4b44ec3e43617094]::query::plumbing::try_execute_query::<rustc_query_impl[c8a8c0bff8e01ad6]::DynamicConfig<rustc_query_system[4b44ec3e43617094]::query::caches::DefIdCache<rustc_middle[490be60d42aefdb2]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c8a8c0bff8e01ad6]::plumbing::QueryCtxt, false>
33: 0x74a6c3946789 - rustc_query_impl[c8a8c0bff8e01ad6]::query_impl::coherent_trait::get_query_non_incr::__rust_end_short_backtrace
34: 0x74a6c3a2e8aa - rustc_hir_analysis[818e5c0bff74b8ba]::check::wfcheck::check_well_formed
35: 0x74a6c3a2c6ad - rustc_query_impl[c8a8c0bff8e01ad6]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c8a8c0bff8e01ad6]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[490be60d42aefdb2]::query::erase::Erased<[u8; 1usize]>>
36: 0x74a6c3a2be40 - rustc_query_system[4b44ec3e43617094]::query::plumbing::try_execute_query::<rustc_query_impl[c8a8c0bff8e01ad6]::DynamicConfig<rustc_query_system[4b44ec3e43617094]::query::caches::VecCache<rustc_hir[6ec3500a0b0e30a7]::hir_id::OwnerId, rustc_middle[490be60d42aefdb2]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c8a8c0bff8e01ad6]::plumbing::QueryCtxt, false>
37: 0x74a6c3a2bbbf - rustc_query_impl[c8a8c0bff8e01ad6]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
38: 0x74a6c3a29b01 - rustc_hir_analysis[818e5c0bff74b8ba]::check::wfcheck::check_mod_type_wf
39: 0x74a6c3a29947 - rustc_query_impl[c8a8c0bff8e01ad6]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c8a8c0bff8e01ad6]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[490be60d42aefdb2]::query::erase::Erased<[u8; 1usize]>>
40: 0x74a6c3e47a30 - rustc_query_system[4b44ec3e43617094]::query::plumbing::try_execute_query::<rustc_query_impl[c8a8c0bff8e01ad6]::DynamicConfig<rustc_query_system[4b44ec3e43617094]::query::caches::DefaultCache<rustc_span[ee88eaa59b68392e]::def_id::LocalModDefId, rustc_middle[490be60d42aefdb2]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c8a8c0bff8e01ad6]::plumbing::QueryCtxt, false>
41: 0x74a6c3e477db - rustc_query_impl[c8a8c0bff8e01ad6]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
42: 0x74a6c377eb1e - rustc_hir_analysis[818e5c0bff74b8ba]::check_crate
43: 0x74a6c37755c7 - rustc_interface[85d9b20ed3c7c603]::passes::analysis
44: 0x74a6c3775107 - rustc_query_impl[c8a8c0bff8e01ad6]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c8a8c0bff8e01ad6]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[490be60d42aefdb2]::query::erase::Erased<[u8; 1usize]>>
45: 0x74a6c41c05e5 - rustc_query_system[4b44ec3e43617094]::query::plumbing::try_execute_query::<rustc_query_impl[c8a8c0bff8e01ad6]::DynamicConfig<rustc_query_system[4b44ec3e43617094]::query::caches::SingleCache<rustc_middle[490be60d42aefdb2]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c8a8c0bff8e01ad6]::plumbing::QueryCtxt, false>
46: 0x74a6c41c0349 - rustc_query_impl[c8a8c0bff8e01ad6]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
47: 0x74a6c400624e - rustc_interface[85d9b20ed3c7c603]::interface::run_compiler::<core[29497e35239b89fd]::result::Result<(), rustc_span[ee88eaa59b68392e]::ErrorGuaranteed>, rustc_driver_impl[9a1cf205da409778]::run_compiler::{closure#0}>::{closure#1}
48: 0x74a6c3ff2849 - std[23e06557834ee477]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[85d9b20ed3c7c603]::util::run_in_thread_with_globals<rustc_interface[85d9b20ed3c7c603]::util::run_in_thread_pool_with_globals<rustc_interface[85d9b20ed3c7c603]::interface::run_compiler<core[29497e35239b89fd]::result::Result<(), rustc_span[ee88eaa59b68392e]::ErrorGuaranteed>, rustc_driver_impl[9a1cf205da409778]::run_compiler::{closure#0}>::{closure#1}, core[29497e35239b89fd]::result::Result<(), rustc_span[ee88eaa59b68392e]::ErrorGuaranteed>>::{closure#0}, core[29497e35239b89fd]::result::Result<(), rustc_span[ee88eaa59b68392e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[29497e35239b89fd]::result::Result<(), rustc_span[ee88eaa59b68392e]::ErrorGuaranteed>>
49: 0x74a6c3ff25f6 - <<std[23e06557834ee477]::thread::Builder>::spawn_unchecked_<rustc_interface[85d9b20ed3c7c603]::util::run_in_thread_with_globals<rustc_interface[85d9b20ed3c7c603]::util::run_in_thread_pool_with_globals<rustc_interface[85d9b20ed3c7c603]::interface::run_compiler<core[29497e35239b89fd]::result::Result<(), rustc_span[ee88eaa59b68392e]::ErrorGuaranteed>, rustc_driver_impl[9a1cf205da409778]::run_compiler::{closure#0}>::{closure#1}, core[29497e35239b89fd]::result::Result<(), rustc_span[ee88eaa59b68392e]::ErrorGuaranteed>>::{closure#0}, core[29497e35239b89fd]::result::Result<(), rustc_span[ee88eaa59b68392e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[29497e35239b89fd]::result::Result<(), rustc_span[ee88eaa59b68392e]::ErrorGuaranteed>>::{closure#2} as core[29497e35239b89fd]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
50: 0x74a6c5667b8b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hcdbd0506d988eb8c
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/alloc/src/boxed.rs:2022:9
51: 0x74a6c5667b8b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h09f9075aff61f253
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/alloc/src/boxed.rs:2022:9
52: 0x74a6c5667b8b - std::sys::pal::unix::thread::Thread::new::thread_start::hd3f8986c115a8175
at /rustc/9fa862ff29ccfea885f8b1f33f4a507d456ae551/library/std/src/sys/pal/unix/thread.rs:108:17
53: 0x74a6beea955a - <unknown>
54: 0x74a6bef26a3c - <unknown>
55: 0x0 - <unknown>
error: 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: please make sure that you have updated to the latest nightly
note: rustc 1.80.0-nightly (9fa862ff2 2024-05-04) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z next-solver=coherence -Z dump-mir-dir=dir
query stack during panic:
#0 [specialization_graph_of] building specialization graph of trait `core::convert::From`
#1 [coherent_trait] coherence checking all impls of trait `core::convert::From`
#2 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.3x50tymIDXeY/rustc_testrunner_tmpdir_reporting.LJEEw1d4XM4C/mvce.rs:12:1: 12:42>` is well-formed
#3 [check_mod_type_wf] checking that types are well-formed in top-level module
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0405, E0601.
For more information about an error, try `rustc --explain E0405`.
@rustbot label +F-specialization
Metadata
Metadata
Assignees
Labels
Category: This is a bug.`#![feature(specialization)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: This bug is tracked inside the repo by a `known-bug` test.Relevant to the compiler team, which will review and decide on the PR/issue.The Rustc Trait System Refactor Initiative (-Znext-solver)