Open anderspapitto opened 4 months ago
Reduced version:
#![feature(generic_const_exprs)]
fn any<T>() -> T {
loop {}
}
trait Cast {
fn cast(&self);
}
impl<const N: usize> Cast for [(); N]
where
// remove the line below for a different ice
LaneCount<N>: SupportedLaneCount,
{
fn cast(&self) {}
}
fn double_up_u8<const N: usize>(x: [(); N]) -> [(); N * 2]
where
LaneCount<N>: SupportedLaneCount,
LaneCount<{ N * 2 }>: SupportedLaneCount,
{
x.cast();
any()
}
fn quadruple_up_u8<const N: usize>(x: [(); N]) -> [(); N * 2 * 2]
where
LaneCount<N>: SupportedLaneCount,
LaneCount<{ N * 2 }>: SupportedLaneCount,
LaneCount<{ N * 2 * 2 }>: SupportedLaneCount,
{
double_up_u8(double_up_u8(x))
}
pub fn quadruple_up_u8_concrete() {
quadruple_up_u8::<0>(any());
}
struct LaneCount<const N: usize>;
trait SupportedLaneCount {}
impl SupportedLaneCount for LaneCount<0> {}
Removing the commented line gives:
error: internal compiler error: compiler/rustc_codegen_llvm/src/context.rs:1173:21: `fn_abi_of_instance(any::<[(); N * 2]>, [])` failed: Layout(Unknown([(); UnevaluatedConst { def: DefId(0:15 ~ playground[c7cd]::double_up_u8::{constant#2}), args: [(Mul: (0_usize: usize), (2_usize: usize))] }]))
--> src/lib.rs:3:1
|
3 | fn any<T>() -> T {
| ^^^^^^^^^^^^^^^^
thread 'rustc' panicked at compiler/rustc_codegen_llvm/src/context.rs:1173:21:
Box<dyn Any>
stack backtrace:
0: 0x7fb17b384bad - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hfd30b84ebe11988c
1: 0x7fb17bb94c97 - core::fmt::write::hb626a39072c0eb4c
2: 0x7fb17cb1e7d1 - std::io::Write::write_fmt::h0614c4dd6b12fec7
3: 0x7fb17b38728b - std::panicking::default_hook::{{closure}}::h4464369cfb2c3523
4: 0x7fb17b386efe - std::panicking::default_hook::hbe88f1457419259e
5: 0x7fb17a4e5d29 - std[4821b876adeec04f]::panicking::update_hook::<alloc[579338a18283919f]::boxed::Box<rustc_driver_impl[699cd2d3c3a41798]::install_ice_hook::{closure#0}>>::{closure#0}
6: 0x7fb17b387ba7 - std::panicking::rust_panic_with_hook::hdf548254c8466072
7: 0x7fb17a51f851 - std[4821b876adeec04f]::panicking::begin_panic::<rustc_errors[3009ca04ab9b3e26]::ExplicitBug>::{closure#0}
8: 0x7fb17a512f16 - std[4821b876adeec04f]::sys::backtrace::__rust_end_short_backtrace::<std[4821b876adeec04f]::panicking::begin_panic<rustc_errors[3009ca04ab9b3e26]::ExplicitBug>::{closure#0}, !>
9: 0x7fb17a512c96 - std[4821b876adeec04f]::panicking::begin_panic::<rustc_errors[3009ca04ab9b3e26]::ExplicitBug>
10: 0x7fb17a528a71 - <rustc_errors[3009ca04ab9b3e26]::diagnostic::BugAbort as rustc_errors[3009ca04ab9b3e26]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
11: 0x7fb17a31d25d - <rustc_errors[3009ca04ab9b3e26]::DiagCtxtHandle>::span_bug::<rustc_span[617b2c4e116b8252]::span_encoding::Span, alloc[579338a18283919f]::string::String>
12: 0x7fb17a3418b8 - rustc_middle[177a089697687a0f]::util::bug::opt_span_bug_fmt::<rustc_span[617b2c4e116b8252]::span_encoding::Span>::{closure#0}
13: 0x7fb17a3418ea - rustc_middle[177a089697687a0f]::ty::context::tls::with_opt::<rustc_middle[177a089697687a0f]::util::bug::opt_span_bug_fmt<rustc_span[617b2c4e116b8252]::span_encoding::Span>::{closure#0}, !>::{closure#0}
14: 0x7fb17a33101b - rustc_middle[177a089697687a0f]::ty::context::tls::with_context_opt::<rustc_middle[177a089697687a0f]::ty::context::tls::with_opt<rustc_middle[177a089697687a0f]::util::bug::opt_span_bug_fmt<rustc_span[617b2c4e116b8252]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
15: 0x7fb17a330887 - rustc_middle[177a089697687a0f]::util::bug::span_bug_fmt::<rustc_span[617b2c4e116b8252]::span_encoding::Span>
16: 0x7fb17a36cbe4 - <rustc_codegen_llvm[f7f993617aa7612f]::context::CodegenCx as rustc_middle[177a089697687a0f]::ty::layout::FnAbiOfHelpers>::handle_fn_abi_err
17: 0x7fb17a343d34 - <rustc_codegen_llvm[f7f993617aa7612f]::context::CodegenCx as rustc_middle[177a089697687a0f]::ty::layout::FnAbiOf>::fn_abi_of_instance::{closure#0}
18: 0x7fb178a3d120 - <rustc_codegen_llvm[f7f993617aa7612f]::context::CodegenCx as rustc_codegen_ssa[dea1e47a759436d]::traits::declare::PreDefineMethods>::predefine_fn
19: 0x7fb17ca988ff - rustc_codegen_llvm[f7f993617aa7612f]::base::compile_codegen_unit::module_codegen
20: 0x7fb17cb72293 - <rustc_codegen_llvm[f7f993617aa7612f]::LlvmCodegenBackend as rustc_codegen_ssa[dea1e47a759436d]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
21: 0x7fb17cb6ec84 - <rustc_codegen_llvm[f7f993617aa7612f]::LlvmCodegenBackend as rustc_codegen_ssa[dea1e47a759436d]::traits::backend::CodegenBackend>::codegen_crate
22: 0x7fb17cb77bf0 - <rustc_interface[4e8b14457d10516f]::queries::Linker>::codegen_and_build_linker
23: 0x7fb17c96e199 - rustc_interface[4e8b14457d10516f]::interface::run_compiler::<core[3a188adb88b8af3f]::result::Result<(), rustc_span[617b2c4e116b8252]::ErrorGuaranteed>, rustc_driver_impl[699cd2d3c3a41798]::run_compiler::{closure#0}>::{closure#1}
24: 0x7fb17ca3b604 - std[4821b876adeec04f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[4e8b14457d10516f]::util::run_in_thread_with_globals<rustc_interface[4e8b14457d10516f]::util::run_in_thread_pool_with_globals<rustc_interface[4e8b14457d10516f]::interface::run_compiler<core[3a188adb88b8af3f]::result::Result<(), rustc_span[617b2c4e116b8252]::ErrorGuaranteed>, rustc_driver_impl[699cd2d3c3a41798]::run_compiler::{closure#0}>::{closure#1}, core[3a188adb88b8af3f]::result::Result<(), rustc_span[617b2c4e116b8252]::ErrorGuaranteed>>::{closure#0}, core[3a188adb88b8af3f]::result::Result<(), rustc_span[617b2c4e116b8252]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3a188adb88b8af3f]::result::Result<(), rustc_span[617b2c4e116b8252]::ErrorGuaranteed>>
25: 0x7fb17ca3bc70 - <<std[4821b876adeec04f]::thread::Builder>::spawn_unchecked_<rustc_interface[4e8b14457d10516f]::util::run_in_thread_with_globals<rustc_interface[4e8b14457d10516f]::util::run_in_thread_pool_with_globals<rustc_interface[4e8b14457d10516f]::interface::run_compiler<core[3a188adb88b8af3f]::result::Result<(), rustc_span[617b2c4e116b8252]::ErrorGuaranteed>, rustc_driver_impl[699cd2d3c3a41798]::run_compiler::{closure#0}>::{closure#1}, core[3a188adb88b8af3f]::result::Result<(), rustc_span[617b2c4e116b8252]::ErrorGuaranteed>>::{closure#0}, core[3a188adb88b8af3f]::result::Result<(), rustc_span[617b2c4e116b8252]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3a188adb88b8af3f]::result::Result<(), rustc_span[617b2c4e116b8252]::ErrorGuaranteed>>::{closure#1} as core[3a188adb88b8af3f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
26: 0x7fb17ca3bfeb - std::sys::pal::unix::thread::Thread::new::thread_start::h7ef170129820a8c9
27: 0x7fb176f63609 - start_thread
28: 0x7fb176e88353 - clone
29: 0x0 - <unknown>
Further reduced for the second ICE:
#![feature(generic_const_exprs)]
fn double_up_u8<const N: usize>() -> [(); N * 2]
where
LaneCount<{ N * 2 }>: IsZero,
{
loop {}
}
fn quadruple_up_u8<const N: usize>() -> [(); N * 2 * 2]
where
LaneCount<{ N * 2 }>: IsZero,
LaneCount<{ N * 2 * 2 }>: IsZero,
{
double_up_u8()
}
pub fn quadruple_up_u8_concrete() {
quadruple_up_u8::<0>();
}
struct LaneCount<const N: usize>;
trait IsZero {}
impl IsZero for LaneCount<0> {}
More reduction:
#![feature(generic_const_exprs)]
fn double_up<const M: usize>() -> [(); M * 2] {
todo!()
}
fn quadruple_up<const N: usize>() -> [(); N * 2 * 2] {
double_up()
}
pub fn init() {
quadruple_up::<0>();
}
I tried this code (https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=d0cf160632f8eed6e09099624d1cd545):