Closed
Description
#![feature(const_generics)]
fn foo<const N: usize, const A: [u8; N]>() {}
fn bar() {
foo::<1, {[1]}>();
}
results in an ICE:
error: internal compiler error: src/librustc/ty/subst.rs:597: const parameter `N/#0` (Const { ty: usize, val: Param(N/#0) }/0) out of range when substituting substs=[]
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:584: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:200
5: std::panicking::default_hook
at src/libstd/panicking.rs:214
6: rustc::util::common::panic_hook
7: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:481
8: std::panicking::begin_panic
9: rustc_errors::Handler::span_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::span_bug_fmt
16: <rustc::ty::subst::SubstFolder as rustc::ty::fold::TypeFolder>::fold_const
17: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with
18: <rustc::ty::subst::SubstFolder as rustc::ty::fold::TypeFolder>::fold_ty
19: rustc::traits::codegen::<impl rustc::ty::context::TyCtxt>::subst_and_normalize_erasing_regions
20: rustc::ty::instance::Instance::resolve
21: <rustc::traits::project::AssocTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_const
22: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
23: rustc::ty::fold::TypeFoldable::fold_with
24: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with
25: <rustc::traits::project::AssocTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_ty
26: rustc::traits::project::normalize
27: rustc_typeck::check::FnCtxt::instantiate_value_path
28: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
29: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::check_call
30: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
31: rustc_typeck::check::FnCtxt::check_stmt
32: rustc_typeck::check::FnCtxt::check_block_with_expected
33: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
34: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
35: rustc_typeck::check::check_fn
36: rustc::ty::context::GlobalCtxt::enter_local
37: rustc_typeck::check::typeck_tables_of
38: rustc::ty::query::__query_compute::typeck_tables_of
39: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
40: rustc::dep_graph::graph::DepGraph::with_task_impl
41: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
42: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
43: rustc_typeck::check::typeck_item_bodies
44: rustc::ty::query::__query_compute::typeck_item_bodies
45: rustc::dep_graph::graph::DepGraph::with_task_impl
46: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
47: rustc::util::common::time
48: rustc_typeck::check_crate
49: rustc_interface::passes::analysis
50: rustc::ty::query::__query_compute::analysis
51: rustc::dep_graph::graph::DepGraph::with_task_impl
52: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
53: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
54: rustc_interface::passes::create_global_ctxt::{{closure}}
55: rustc_interface::interface::run_compiler_in_existing_thread_pool
56: std::thread::local::LocalKey<T>::with
57: scoped_tls::ScopedKey<T>::set
58: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
#0 [typeck_tables_of] processing `bar`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
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.38.0-nightly (4b65a86eb 2019-07-15) running on x86_64-unknown-linux-gnu
Metadata
Metadata
Assignees
Labels
Area: const generics (parameters and arguments)Area: Lazy normalization (tracking issue: #60471)Category: This is a bug.`#![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.ICE tracked in rust-lang/glacier.This issue requires a nightly compiler in some way.