Closed
Description
Promotion of const generic parameters causes the compiler to crash.
#![feature(const_generics)]
fn promote<const N: i32>() {
// works:
//
// let n = N;
// &n;
&N;
}
fn main() {
promote::<0>();
}
$ RUST_BACKTRACE=1 rustc +nightly promotion_const_generics_ice.rs
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> promotion_const_generics_ice.rs:1:12
|
1 | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
thread 'rustc' panicked at 'assertion failed: key.value.promoted.is_none()', src/librustc_mir/const_eval.rs:577:17
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.25/src/backtrace/libunwind.rs:97
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.25/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:197
5: std::panicking::default_hook
at src/libstd/panicking.rs:211
6: rustc::util::common::panic_hook
7: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:478
8: std::panicking::begin_panic
9: rustc_mir::const_eval::const_eval_provider
10: rustc::ty::query::__query_compute::const_eval
11: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval>::compute
12: rustc::dep_graph::graph::DepGraph::with_task_impl
13: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
14: rustc_mir::monomorphize::collector::collect_items_rec
15: rustc_mir::monomorphize::collector::collect_items_rec
16: rustc_mir::monomorphize::collector::collect_crate_mono_items::{{closure}}
17: rustc::util::common::time
18: rustc_mir::monomorphize::collector::collect_crate_mono_items
19: rustc::util::common::time
20: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
21: rustc::ty::query::__query_compute::collect_and_partition_mono_items
22: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_and_partition_mono_items>::compute
23: rustc::dep_graph::graph::DepGraph::with_task_impl
24: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
25: rustc_codegen_ssa::base::codegen_crate
26: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
27: rustc::util::common::time
28: rustc_interface::passes::start_codegen
29: rustc::ty::context::tls::enter_global
30: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
31: rustc_interface::passes::create_global_ctxt::{{closure}}
32: rustc_interface::passes::BoxedGlobalCtxt::enter
33: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::ongoing_codegen
34: rustc_interface::interface::run_compiler_in_existing_thread_pool
35: std::thread::local::LocalKey<T>::with
36: scoped_tls::ScopedKey<T>::set
37: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
#0 [const_eval] const-evaluating + checking `promote`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: internal compiler error: unexpected panic
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 (7840a0b75 2019-05-31) running on x86_64-unknown-linux-gnu
Metadata
Metadata
Assignees
Labels
Area: Constant evaluation, covers all const contexts (static, const fn, ...)Area: const generics (parameters and arguments)Category: This is a bug.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.`#![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.