Closed
Description
Code
Here's the trait:
#![feature(generic_const_exprs)]
pub trait CrossProduct<'a, T, R> {
fn cross(&'a self, t: &'a T) -> R;
}
impl<'a, T, U, const N: usize> CrossProduct<'a, [U; N], [(&'a T, &'a U); N * N]> for [T; N] {
fn cross(&'a self, us: &'a [U; N]) -> [(&'a T, &'a U); N * N] {
std::array::from_fn(|i| (&self[i / N], &us[i % N]))
}
}
Here's a simplification of how I use it:
struct PointF {
x: f32,
y: f32
}
let [p11, p12, p21, p22] = [1.0, 10.0]
.cross(&[(2.0, 3.0), (4.0, 5.0)])
.map(|(r, (cos, sin))| PointF {
x: r * cos,
y: r * sin,
});
Meta
rustc --version --verbose
:
rustc 1.70.0-nightly (a41fc00ea 2023-04-13)
binary: rustc
commit-hash: a41fc00eaf352541008965fec0dee811e44373b3
commit-date: 2023-04-13
host: x86_64-pc-windows-msvc
release: 1.70.0-nightly
LLVM version: 16.0.2
Error output
error: internal compiler error: compiler\rustc_middle\src\ty\instance.rs:428:18: failed to resolve instance for <[f32; 2] as CrossProduct<'_, [(f32, f32); 2], [(&f32, &(f32, f32)); 4]>>::cross
thread 'rustc' panicked at 'Box<dyn Any>', /rustc/a41fc00eaf352541008965fec0dee811e44373b3\compiler\rustc_errors\src\lib.rs:1643:9
stack backtrace:
0: 0x7ffdea6f6bf2 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd443998010db1a05
1: 0x7ffdea73503b - core::fmt::write::h5cd8644ec3b011fa
2: 0x7ffdea6ebf9a - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h3edd096ad40b804e
3: 0x7ffdea6f693b - std::sys::common::alloc::realloc_fallback::h14b78773cb2c0a2d
4: 0x7ffdea6fa2ca - std::panicking::default_hook::hecaec80bbc1f544c
5: 0x7ffdea6f9f30 - std::panicking::default_hook::hecaec80bbc1f544c
6: 0x7ffda1ba74ce - rustc_driver_impl[e96b6f59181605fa]::describe_lints
7: 0x7ffdea6fabdf - std::panicking::rust_panic_with_hook::hb0461a3dd2dbf9bc
8: 0x7ffda407b0c3 - <rustc_infer[9d55fc57327cd5e2]::infer::opaque_types::table::OpaqueTypeStorage as core[57f115ae994b613f]::fmt::Debug>::fmt
9: 0x7ffda407ab79 - <rustc_infer[9d55fc57327cd5e2]::infer::opaque_types::table::OpaqueTypeStorage as core[57f115ae994b613f]::fmt::Debug>::fmt
10: 0x7ffda40c8859 - <rustc_middle[985feb45447f3391]::ty::print::pretty::ForceTrimmedGuard as core[57f115ae994b613f]::ops::drop::Drop>::drop
11: 0x7ffda4153e40 - <rustc_middle[985feb45447f3391]::ty::print::pretty::TraitRefPrintOnlyTraitPath as rustc_middle[985feb45447f3391]::ty::context::Lift>::lift_to_tcx
12: 0x7ffda41539c2 - <rustc_middle[985feb45447f3391]::ty::print::pretty::TraitRefPrintOnlyTraitPath as rustc_middle[985feb45447f3391]::ty::context::Lift>::lift_to_tcx
13: 0x7ffda412871a - rustc_middle[985feb45447f3391]::util::bug::bug_fmt
14: 0x7ffda4127c7d - rustc_middle[985feb45447f3391]::ty::closure::place_to_string_for_capture
15: 0x7ffda4127c41 - rustc_middle[985feb45447f3391]::ty::closure::place_to_string_for_capture
16: 0x7ffda4128658 - rustc_middle[985feb45447f3391]::util::bug::bug_fmt
17: 0x7ffda41285d5 - rustc_middle[985feb45447f3391]::util::bug::bug_fmt
18: 0x7ffda1ac7631 - <rustc_middle[985feb45447f3391]::ty::instance::Instance>::expect_resolve
19: 0x7ffda0f5a76b - <rustc_monomorphize[5828fb58b0d741c5]::partitioning::default::DefaultPartitioning as rustc_monomorphize[5828fb58b0d741c5]::partitioning::Partitioner>::internalize_symbols
20: 0x7ffda0f57f14 - <rustc_monomorphize[5828fb58b0d741c5]::partitioning::default::DefaultPartitioning as rustc_monomorphize[5828fb58b0d741c5]::partitioning::Partitioner>::internalize_symbols
21: 0x7ffda0f58332 - <rustc_monomorphize[5828fb58b0d741c5]::partitioning::default::DefaultPartitioning as rustc_monomorphize[5828fb58b0d741c5]::partitioning::Partitioner>::internalize_symbols
22: 0x7ffda0f58332 - <rustc_monomorphize[5828fb58b0d741c5]::partitioning::default::DefaultPartitioning as rustc_monomorphize[5828fb58b0d741c5]::partitioning::Partitioner>::internalize_symbols
23: 0x7ffda0f58332 - <rustc_monomorphize[5828fb58b0d741c5]::partitioning::default::DefaultPartitioning as rustc_monomorphize[5828fb58b0d741c5]::partitioning::Partitioner>::internalize_symbols
24: 0x7ffda0f58332 - <rustc_monomorphize[5828fb58b0d741c5]::partitioning::default::DefaultPartitioning as rustc_monomorphize[5828fb58b0d741c5]::partitioning::Partitioner>::internalize_symbols
25: 0x7ffda0f58332 - <rustc_monomorphize[5828fb58b0d741c5]::partitioning::default::DefaultPartitioning as rustc_monomorphize[5828fb58b0d741c5]::partitioning::Partitioner>::internalize_symbols
26: 0x7ffda0f58332 - <rustc_monomorphize[5828fb58b0d741c5]::partitioning::default::DefaultPartitioning as rustc_monomorphize[5828fb58b0d741c5]::partitioning::Partitioner>::internalize_symbols
27: 0x7ffda0f58332 - <rustc_monomorphize[5828fb58b0d741c5]::partitioning::default::DefaultPartitioning as rustc_monomorphize[5828fb58b0d741c5]::partitioning::Partitioner>::internalize_symbols
28: 0x7ffda0f58332 - <rustc_monomorphize[5828fb58b0d741c5]::partitioning::default::DefaultPartitioning as rustc_monomorphize[5828fb58b0d741c5]::partitioning::Partitioner>::internalize_symbols
29: 0x7ffda0f58332 - <rustc_monomorphize[5828fb58b0d741c5]::partitioning::default::DefaultPartitioning as rustc_monomorphize[5828fb58b0d741c5]::partitioning::Partitioner>::internalize_symbols
30: 0x7ffd9fbcebb0 - rustc_monomorphize[5828fb58b0d741c5]::provide
31: 0x7ffd9fbd4242 - <rustc_monomorphize[5828fb58b0d741c5]::partitioning::default::DefaultPartitioning as rustc_monomorphize[5828fb58b0d741c5]::partitioning::Partitioner>::merge_codegen_units
32: 0x7ffd9fbd1136 - <rustc_monomorphize[5828fb58b0d741c5]::partitioning::default::DefaultPartitioning as rustc_monomorphize[5828fb58b0d741c5]::partitioning::Partitioner>::merge_codegen_units
33: 0x7ffd9fbd259a - <rustc_monomorphize[5828fb58b0d741c5]::partitioning::default::DefaultPartitioning as rustc_monomorphize[5828fb58b0d741c5]::partitioning::Partitioner>::merge_codegen_units
34: 0x7ffd9ff2225e - <&rustc_index[16cb0b634ffc838d]::vec::IndexVec<rustc_middle[985feb45447f3391]::mir::Promoted, rustc_middle[985feb45447f3391]::mir::Body> as rustc_serialize[cae443092dd0a1a4]::serialize::Decodable<rustc_query_impl[706c031ddb0ac593]::on_disk_cache::CacheDecoder>>::decode
35: 0x7ffd9fe6d834 - <&rustc_data_structures[e4e9da7c7d88d078]::unord::UnordSet<rustc_span[4fbd0892d97b3008]::def_id::LocalDefId> as rustc_serialize[cae443092dd0a1a4]::serialize::Decodable<rustc_query_impl[706c031ddb0ac593]::on_disk_cache::CacheDecoder>>::decode
36: 0x7ffd9ff02e1e - <&rustc_index[16cb0b634ffc838d]::vec::IndexVec<rustc_middle[985feb45447f3391]::mir::Promoted, rustc_middle[985feb45447f3391]::mir::Body> as rustc_serialize[cae443092dd0a1a4]::serialize::Decodable<rustc_query_impl[706c031ddb0ac593]::on_disk_cache::CacheDecoder>>::decode
etup_callbacks
42: 0x7ffd9f41acaa - rustc_interface[70690452c0b379a5]::passes::start_codegen
43: 0x7ffd9f41ef30 - rustc_interface[70690452c0b379a5]::proc_macro_decls::provide
44: 0x7ffd9f411817 - <rustc_interface[70690452c0b379a5]::queries::Queries>::ongoing_codegen
45: 0x7ffd9f3d5824 - <rustc_middle[985feb45447f3391]::ty::SymbolName as core[57f115ae994b613f]::fmt::Debug>::fmt
46: 0x7ffd9f3d336d - rustc_driver_impl[e96b6f59181605fa]::args::arg_expand_all
47: 0x7ffd9f3c87d0 - rustc_driver_impl[e96b6f59181605fa]::main
48: 0x7ffd9f3d4a69 - rustc_driver_impl[e96b6f59181605fa]::args::arg_expand_all
49: 0x7ffd9f3d4cc3 - rustc_driver_impl[e96b6f59181605fa]::args::arg_expand_all
50: 0x7ffdea70ca9c - std::sys::windows::thread::Thread::new::hf7ece0808c5f216a
51: 0x7ffe4db07614 - BaseThreadInitThunk
52: 0x7ffe4f1c26a1 - RtlUserThreadStart
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 (a41fc00ea 2023-04-13) running on x86_64-pc-windows-msvc
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
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
end of query stack
Backtrace
<backtrace>
Metadata
Metadata
Assignees
Labels
Category: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.`#![feature(generic_const_exprs)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.