Closed
Description
I have the following code:
pub type TruncatedVector<T, const N: usize> = Vector<T, {N - 1}>;
impl<T, const N: usize> Vector<T, {N}> {
/// Drop the last component and return the vector with one fewer dimension.
pub fn trunc(self) -> (TruncatedVector<T, {N}>, T) {
// ....
}
}
Attempting to use this function, such as in the following manner:
let (xyz, w): (TruncatedVector<u32, 4>, u32) = vec4(0u32, 1, 2, 3).trunc();
causes the compiler to crash with the following backtrace:
error: internal compiler error: src/librustc_codegen_llvm/context.rs:856: failed to get layout for `Vector<u32, {N - 1}>`: the type `[u32; _]` has an unknown layout
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:650:9
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:47
3: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:36
4: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:198
5: std::panicking::default_hook
at src/libstd/panicking.rs:212
6: rustc::util::common::panic_hook
7: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:479
8: std::panicking::begin_panic
9: rustc_errors::Handler::bug
10: rustc::util::bug::opt_span_bug_fmt::{{closure}}
11: rustc::ty::context::tls::with_opt::{{closure}}
12: rustc::ty::context::tls::with_context_opt
13: rustc::ty::context::tls::with_opt
14: rustc::util::bug::opt_span_bug_fmt
15: rustc::util::bug::bug_fmt
16: <rustc_codegen_llvm::context::CodegenCx as rustc_target::abi::LayoutOf>::layout_of::{{closure}}
17: <rustc_codegen_llvm::context::CodegenCx as rustc_target::abi::LayoutOf>::layout_of
18: <rustc_target::abi::call::FnType<&rustc::ty::TyS> as rustc::ty::layout::FnTypeExt<C>>::new_internal::{{closure}}
19: <rustc_target::abi::call::FnType<&rustc::ty::TyS> as rustc::ty::layout::FnTypeExt<C>>::new
20: rustc_codegen_llvm::declare::<impl rustc_codegen_ssa::traits::declare::DeclareMethods for rustc_codegen_llvm::context::CodegenCx>::declare_fn
21: rustc_codegen_llvm::mono_item::<impl rustc_codegen_ssa::traits::declare::PreDefineMethods for rustc_codegen_llvm::context::CodegenCx>::predefine_fn
22: <rustc::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::predefine
23: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
24: rustc::dep_graph::graph::DepGraph::with_task
25: rustc_codegen_llvm::base::compile_codegen_unit
26: rustc_codegen_ssa::base::codegen_crate
27: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
28: rustc::util::common::time
29: rustc_interface::passes::start_codegen
30: rustc::ty::context::tls::enter_global
31: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
32: rustc_interface::passes::create_global_ctxt::{{closure}}
33: rustc_interface::passes::BoxedGlobalCtxt::enter
34: rustc_interface::queries::Query<T>::compute
35: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::ongoing_codegen
36: rustc_interface::interface::run_compiler_in_existing_thread_pool
37: std::thread::local::LocalKey<T>::with
38: scoped_tls::ScopedKey<T>::set
39: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
end of query stack
error: aborting due to previous error
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.37.0-nightly (8ebd67e4e 2019-06-27) running on x86_64-unknown-linux-gnu
note: compiler flags: -C debuginfo=2 -C incremental
This issue has been assigned to @DutchGhost via this comment.
Metadata
Metadata
Assignees
Labels
Area: const generics (parameters and arguments)Category: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.`#![feature(const_generics)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.This issue requires a nightly compiler in some way.