Closed
Description
Hi,
I detected this problem by coincidence and reporting it just because the error message asked to do so.
Code
struct A<'a> {
data: &'a [u32],
}
impl<'a> A<'a> {
const fn new(data: &'a [u32]) -> A<'a> {
A { data }
}
}
pub fn setup() {
static mut aa_storage: [A; 32] = [A::new(&[]); 32];
}
The problem goes away if I add #[derive(Clone, Copy)]
to struct A
, as required for the array initialization inside setup
.
Meta
rustc --version --verbose
:
rustc 1.50.0-nightly (bb1fbbf84 2020-12-22)
binary: rustc
commit-hash: bb1fbbf84455fbad9afd26c17e0f725019322655
commit-date: 2020-12-22
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly
I also verified that the problem exist after updating the toolchain in the version:
rustc 1.51.0-nightly (22ddcd1a1 2021-01-22)
binary: rustc
commit-hash: 22ddcd1a13082b7be0fc99b720677efd2b733816
commit-date: 2021-01-22
host: x86_64-unknown-linux-gnu
release: 1.51.0-nightly
LLVM version: 11.0.1
Error output
thread 'rustc' panicked at 'assertion failed: promoted.is_none()', compiler/rustc_mir/src/transform/check_consts/qualifs.rs:250:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.51.0-nightly (22ddcd1a1 2021-01-22) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type rlib
query stack during panic:
#0 [mir_borrowck] borrow-checking `setup::aa_storage`
#1 [analysis] running analysis passes on this crate
end of query stack
Backtrace
thread 'rustc' panicked at 'assertion failed: promoted.is_none()', compiler/rustc_mir/src/transform/check_consts/qualifs.rs:250:9
stack backtrace:
0: rust_begin_unwind
at /rustc/22ddcd1a13082b7be0fc99b720677efd2b733816/library/std/src/panicking.rs:493:5
1: core::panicking::panic_fmt
at /rustc/22ddcd1a13082b7be0fc99b720677efd2b733816/library/core/src/panicking.rs:92:14
2: core::panicking::panic
at /rustc/22ddcd1a13082b7be0fc99b720677efd2b733816/library/core/src/panicking.rs:50:5
3: rustc_mir::transform::check_consts::qualifs::in_operand
4: rustc_mir::transform::promote_consts::Validator::qualif_local
5: rustc_mir::transform::promote_consts::Validator::validate_local
6: rustc_mir::transform::promote_consts::Validator::validate_place
7: rustc_mir::transform::promote_consts::Validator::validate_local
8: rustc_mir::transform::promote_consts::Validator::validate_place
9: rustc_mir::transform::promote_consts::Validator::validate_local
10: rustc_mir::transform::promote_consts::Validator::validate_place
11: rustc_mir::transform::promote_consts::Validator::validate_local
12: rustc_mir::transform::promote_consts::Validator::validate_place
13: rustc_mir::transform::promote_consts::should_suggest_const_in_array_repeat_expressions_attribute
14: rustc_mir::borrow_check::type_check::TypeChecker::check_rvalue
15: rustc_mir::borrow_check::type_check::TypeChecker::typeck_mir
16: rustc_mir::borrow_check::type_check::type_check
17: rustc_mir::borrow_check::nll::compute_regions
18: rustc_mir::borrow_check::do_mir_borrowck
19: rustc_infer::infer::InferCtxtBuilder::enter
20: rustc_mir::borrow_check::mir_borrowck
21: core::ops::function::FnOnce::call_once
22: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_borrowck>::compute
23: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
24: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}
25: rustc_query_system::query::plumbing::force_query_with_job
26: rustc_query_system::query::plumbing::get_query_impl
27: rustc_query_system::query::plumbing::ensure_query_impl
28: rustc_session::utils::<impl rustc_session::session::Session>::time
29: rustc_interface::passes::analysis
30: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
31: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
32: rustc_data_structures::stack::ensure_sufficient_stack
33: rustc_query_system::query::plumbing::force_query_with_job
34: rustc_query_system::query::plumbing::get_query_impl
35: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
36: rustc_span::with_source_map
37: rustc_interface::interface::create_compiler_and_run
38: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Metadata
Metadata
Assignees
Labels
Area: Constant evaluation, covers all const contexts (static, const fn, ...)Category: This is a bug.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️High priorityRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.