Repository navigation
Conflicting trait impls cause ICE with generic_const_exprs #119692
Description
Activity
- addedC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
on Jan 7, 2024 - addedneeds-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triagingThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
on Jan 7, 2024 Bisects to #119148
edit: oops, tested against the wrong code
bisects to nightly-2023-05-18found 7 bors merge commits in the specified range
commit[0] 2023-05-16: Auto merge of #111650 - matthiaskrgr:rollup-n7w17v4, r=matthiaskrgr
commit[1] 2023-05-16: Auto merge of #111556 - cjgillot:copy-prop-nrvo, r=oli-obk
commit[2] 2023-05-17: Auto merge of #111664 - weihanglo:update-cargo, r=weihanglo
commit[3] 2023-05-17: Auto merge of #111630 - BoxyUwU:ty_const_debug_formatting, r=compiler-errors
commit[4] 2023-05-17: Auto merge of #111671 - Dylan-DPC:rollup-1jy5r16, r=Dylan-DPC
commit[5] 2023-05-17: Auto merge of #111680 - Dylan-DPC:rollup-1p45gxt, r=Dylan-DPC
commit[6] 2023-05-17: Auto merge of #111568 - scottmcm:undo-opt, r=WaffleLapkin
ERROR: no CI builds available between e77366b and e9e1bbc within last 167 days@rustbot label +requires-incomplete-features +F-adt_const_params +F-generic_const_exprs +requires-nightly -needs-triage
- addedF-adt_const_params`#![feature(adt_const_params)]``#![feature(adt_const_params)]`F-generic_const_exprs`#![feature(generic_const_exprs)]``#![feature(generic_const_exprs)]`requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.and removedneeds-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triagingThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
on Feb 14, 2024 - addedS-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.Status: This bug is tracked inside the repo by a `known-bug` test.
on Apr 15, 2024 Much better minimization found by @pacak and @theemathas in #126078:
#![feature(generic_const_exprs)] #![allow(incomplete_features)] trait Array { const SIZE: usize; } impl<const N: usize> Array for [i32; N] { const SIZE: usize = N; } // Note: Overlapping impls not detected by compiler trait Reflexive<T> { fn reflexive() {} } impl<T> Reflexive<T> for T {} impl<A: Array> Reflexive<[i32; A::SIZE]> for A {} fn do_reflexive<const N: usize>() { <[i32; N]>::reflexive(); } // Note: Load-bearing `pub`. Removing the pub stops the ICE. pub fn what() { do_reflexive::<0>() }
Compiler error
Compiling playground v0.0.1 (/playground) error: internal compiler error: compiler/rustc_middle/src/ty/instance.rs:510:25: failed to resolve instance for <[i32; 0] as Reflexive<[i32; 0]>>::reflexive: Ok( None, ) thread 'rustc' panicked at compiler/rustc_middle/src/ty/instance.rs:510:25: Box<dyn Any> stack backtrace: 0: 0x7f5499f58f15 - std::backtrace_rs::backtrace::libunwind::trace::h7d3c800091db3e91 at /rustc/804421dff5542c9c7da5c60257b5dbc849719505/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5 1: 0x7f5499f58f15 - std::backtrace_rs::backtrace::trace_unsynchronized::h4cc0a280c32586b8 at /rustc/804421dff5542c9c7da5c60257b5dbc849719505/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f5499f58f15 - std::sys_common::backtrace::_print_fmt::h9005d7a683a6d7a4 at /rustc/804421dff5542c9c7da5c60257b5dbc849719505/library/std/src/sys_common/backtrace.rs:68:5 3: 0x7f5499f58f15 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h519c17d5956798a6 at /rustc/804421dff5542c9c7da5c60257b5dbc849719505/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7f5499fa9c5b - core::fmt::rt::Argument::fmt::haa193bfc28a485eb at /rustc/804421dff5542c9c7da5c60257b5dbc849719505/library/core/src/fmt/rt.rs:165:63 5: 0x7f5499fa9c5b - core::fmt::write::h355a93f02c4b3ea1 at /rustc/804421dff5542c9c7da5c60257b5dbc849719505/library/core/src/fmt/mod.rs:1168:21 6: 0x7f5499f4dc9f - std::io::Write::write_fmt::hbe0fd00858f9c1ec at /rustc/804421dff5542c9c7da5c60257b5dbc849719505/library/std/src/io/mod.rs:1835:15 7: 0x7f5499f58cee - std::sys_common::backtrace::_print::h7fe7f477e21fa361 at /rustc/804421dff5542c9c7da5c60257b5dbc849719505/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7f5499f58cee - std::sys_common::backtrace::print::h6c8dafcb53369ea1 at /rustc/804421dff5542c9c7da5c60257b5dbc849719505/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7f5499f5b729 - std::panicking::default_hook::{{closure}}::hbcbc771124e8a531 10: 0x7f5499f5b4ca - std::panicking::default_hook::ha99c0605f25db782 at /rustc/804421dff5542c9c7da5c60257b5dbc849719505/library/std/src/panicking.rs:298:9 11: 0x7f549d1a4a00 - std[59958118404e088f]::panicking::update_hook::<alloc[25fe46b0aaca8953]::boxed::Box<rustc_driver_impl[2627b6be84d2f0c]::install_ice_hook::{closure#0}>>::{closure#0} 12: 0x7f5499f5be5b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h4e37e0de343f25a5 at /rustc/804421dff5542c9c7da5c60257b5dbc849719505/library/alloc/src/boxed.rs:2077:9 13: 0x7f5499f5be5b - std::panicking::rust_panic_with_hook::h6b51162bdfe57bbe at /rustc/804421dff5542c9c7da5c60257b5dbc849719505/library/std/src/panicking.rs:799:13 14: 0x7f549d1d5224 - std[59958118404e088f]::panicking::begin_panic::<rustc_errors[2ff0989c1584c7c0]::ExplicitBug>::{closure#0} 15: 0x7f549d1d1d06 - std[59958118404e088f]::sys_common::backtrace::__rust_end_short_backtrace::<std[59958118404e088f]::panicking::begin_panic<rustc_errors[2ff0989c1584c7c0]::ExplicitBug>::{closure#0}, !> 16: 0x7f549d1cd116 - std[59958118404e088f]::panicking::begin_panic::<rustc_errors[2ff0989c1584c7c0]::ExplicitBug> 17: 0x7f549d1de841 - <rustc_errors[2ff0989c1584c7c0]::diagnostic::BugAbort as rustc_errors[2ff0989c1584c7c0]::diagnostic::EmissionGuarantee>::emit_producing_guarantee 18: 0x7f549d6bb04c - rustc_middle[ce3fbd8192a3c5ff]::util::bug::opt_span_bug_fmt::<rustc_span[6bc65aeac19990f8]::span_encoding::Span>::{closure#0} 19: 0x7f549d6a487a - rustc_middle[ce3fbd8192a3c5ff]::ty::context::tls::with_opt::<rustc_middle[ce3fbd8192a3c5ff]::util::bug::opt_span_bug_fmt<rustc_span[6bc65aeac19990f8]::span_encoding::Span>::{closure#0}, !>::{closure#0} 20: 0x7f549d6a46fb - rustc_middle[ce3fbd8192a3c5ff]::ty::context::tls::with_context_opt::<rustc_middle[ce3fbd8192a3c5ff]::ty::context::tls::with_opt<rustc_middle[ce3fbd8192a3c5ff]::util::bug::opt_span_bug_fmt<rustc_span[6bc65aeac19990f8]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !> 21: 0x7f549bb5dd70 - rustc_middle[ce3fbd8192a3c5ff]::util::bug::bug_fmt 22: 0x7f549eb00f42 - <rustc_middle[ce3fbd8192a3c5ff]::ty::instance::Instance>::expect_resolve 23: 0x7f549f3f7d5f - rustc_monomorphize[b056ba09cdf9a699]::collector::collect_items_rec::{closure#0} 24: 0x7f549e66637f - rustc_monomorphize[b056ba09cdf9a699]::collector::collect_items_rec 25: 0x7f549e666af6 - rustc_monomorphize[b056ba09cdf9a699]::collector::collect_items_rec 26: 0x7f549effee27 - rustc_monomorphize[b056ba09cdf9a699]::partitioning::collect_and_partition_mono_items 27: 0x7f549f3d3364 - rustc_query_impl[9fa61a5fc93b94b6]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9fa61a5fc93b94b6]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ce3fbd8192a3c5ff]::query::erase::Erased<[u8; 24usize]>> 28: 0x7f549f3d3349 - <rustc_query_impl[9fa61a5fc93b94b6]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[666eafb1203b88c6]::ops::function::FnOnce<(rustc_middle[ce3fbd8192a3c5ff]::ty::context::TyCtxt, ())>>::call_once 29: 0x7f549f3d2f08 - rustc_query_system[8cc4c292d92d3869]::query::plumbing::try_execute_query::<rustc_query_impl[9fa61a5fc93b94b6]::DynamicConfig<rustc_query_system[8cc4c292d92d3869]::query::caches::SingleCache<rustc_middle[ce3fbd8192a3c5ff]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[9fa61a5fc93b94b6]::plumbing::QueryCtxt, false> 30: 0x7f549f3d2c21 - rustc_query_impl[9fa61a5fc93b94b6]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace 31: 0x7f549f0af509 - rustc_codegen_ssa[7de31db090aae023]::back::symbol_export::exported_symbols_provider_local 32: 0x7f549e7533a5 - rustc_query_impl[9fa61a5fc93b94b6]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9fa61a5fc93b94b6]::query_impl::exported_symbols::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ce3fbd8192a3c5ff]::query::erase::Erased<[u8; 16usize]>> 33: 0x7f549e753373 - <rustc_query_impl[9fa61a5fc93b94b6]::query_impl::exported_symbols::dynamic_query::{closure#2} as core[666eafb1203b88c6]::ops::function::FnOnce<(rustc_middle[ce3fbd8192a3c5ff]::ty::context::TyCtxt, rustc_span[6bc65aeac19990f8]::def_id::CrateNum)>>::call_once 34: 0x7f549f23b4b1 - rustc_query_system[8cc4c292d92d3869]::query::plumbing::try_execute_query::<rustc_query_impl[9fa61a5fc93b94b6]::DynamicConfig<rustc_query_system[8cc4c292d92d3869]::query::caches::VecCache<rustc_span[6bc65aeac19990f8]::def_id::CrateNum, rustc_middle[ce3fbd8192a3c5ff]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[9fa61a5fc93b94b6]::plumbing::QueryCtxt, false> 35: 0x7f549f23b0ab - rustc_query_impl[9fa61a5fc93b94b6]::query_impl::exported_symbols::get_query_non_incr::__rust_end_short_backtrace 36: 0x7f549f23adec - rustc_middle[ce3fbd8192a3c5ff]::query::plumbing::query_get_at::<rustc_query_system[8cc4c292d92d3869]::query::caches::VecCache<rustc_span[6bc65aeac19990f8]::def_id::CrateNum, rustc_middle[ce3fbd8192a3c5ff]::query::erase::Erased<[u8; 16usize]>>> 37: 0x7f549ed6e9c0 - <rustc_metadata[d6f8184ef093beb3]::rmeta::encoder::EncodeContext>::encode_crate_root 38: 0x7f549f5ef046 - rustc_metadata[d6f8184ef093beb3]::rmeta::encoder::encode_metadata 39: 0x7f549f4255b2 - rustc_metadata[d6f8184ef093beb3]::fs::encode_and_write_metadata 40: 0x7f549f42405e - rustc_interface[ed174d428a840afd]::passes::start_codegen 41: 0x7f549f4237a8 - <rustc_interface[ed174d428a840afd]::queries::Queries>::codegen_and_build_linker 42: 0x7f549f242332 - rustc_interface[ed174d428a840afd]::interface::run_compiler::<core[666eafb1203b88c6]::result::Result<(), rustc_span[6bc65aeac19990f8]::ErrorGuaranteed>, rustc_driver_impl[2627b6be84d2f0c]::run_compiler::{closure#0}>::{closure#1} 43: 0x7f549f1f6009 - std[59958118404e088f]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ed174d428a840afd]::util::run_in_thread_with_globals<rustc_interface[ed174d428a840afd]::util::run_in_thread_pool_with_globals<rustc_interface[ed174d428a840afd]::interface::run_compiler<core[666eafb1203b88c6]::result::Result<(), rustc_span[6bc65aeac19990f8]::ErrorGuaranteed>, rustc_driver_impl[2627b6be84d2f0c]::run_compiler::{closure#0}>::{closure#1}, core[666eafb1203b88c6]::result::Result<(), rustc_span[6bc65aeac19990f8]::ErrorGuaranteed>>::{closure#0}, core[666eafb1203b88c6]::result::Result<(), rustc_span[6bc65aeac19990f8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[666eafb1203b88c6]::result::Result<(), rustc_span[6bc65aeac19990f8]::ErrorGuaranteed>> 44: 0x7f549f1f5dc0 - <<std[59958118404e088f]::thread::Builder>::spawn_unchecked_<rustc_interface[ed174d428a840afd]::util::run_in_thread_with_globals<rustc_interface[ed174d428a840afd]::util::run_in_thread_pool_with_globals<rustc_interface[ed174d428a840afd]::interface::run_compiler<core[666eafb1203b88c6]::result::Result<(), rustc_span[6bc65aeac19990f8]::ErrorGuaranteed>, rustc_driver_impl[2627b6be84d2f0c]::run_compiler::{closure#0}>::{closure#1}, core[666eafb1203b88c6]::result::Result<(), rustc_span[6bc65aeac19990f8]::ErrorGuaranteed>>::{closure#0}, core[666eafb1203b88c6]::result::Result<(), rustc_span[6bc65aeac19990f8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[666eafb1203b88c6]::result::Result<(), rustc_span[6bc65aeac19990f8]::ErrorGuaranteed>>::{closure#2} as core[666eafb1203b88c6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 45: 0x7f5499f65e4b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1f264a7d3d0a179d at /rustc/804421dff5542c9c7da5c60257b5dbc849719505/library/alloc/src/boxed.rs:2063:9 46: 0x7f5499f65e4b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h137c7bc9bcca4c45 at /rustc/804421dff5542c9c7da5c60257b5dbc849719505/library/alloc/src/boxed.rs:2063:9 47: 0x7f5499f65e4b - std::sys::pal::unix::thread::Thread::new::thread_start::hf2fbd4f8eae045d7 at /rustc/804421dff5542c9c7da5c60257b5dbc849719505/library/std/src/sys/pal/unix/thread.rs:108:17 48: 0x7f5499e73609 - start_thread 49: 0x7f5499d96353 - clone 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: please make sure that you have updated to the latest nightly note: please attach the file at `/playground/rustc-ice-2024-06-08T09_09_04-50.txt` to your bug report note: compiler flags: --crate-type lib -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 #1 [exported_symbols] collecting exported symbols for crate `0` end of query stack error: could not compile `playground` (lib)- removedF-adt_const_params`#![feature(adt_const_params)]``#![feature(adt_const_params)]`
on Jun 8, 2024 - removedrequires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
on Dec 12, 2025 - added a commit that references this issue
on May 2, 2026 - added a commit that references this issue
on May 3, 2026 - added a commit that references this issue
on May 4, 2026 - added a commit that references this issue
on May 4, 2026 - added a commit that references this issue
on Aug 7, 2026
Code (Playground)
The code should not compile, since the first two trait impls are conflicting. If
generic_const_exprsis disabled (it is not needed code-wise in this reduced example, but was necessary in my original code), the compiler gives the correct error message:Note that the even the third trait impl is needed in order to reproduce the ICE. The code compiles fine if either the second or the third trait impl is removed (the first one is actually used, so it cant be removed).
Meta
rustc --version --verbose:Error output
Backtrace
rustc-ice-2024-01-07T13_58_40-55799.txt