Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thread 'rustc' panicked at 'assertion failed: promoted.is_none()', compiler/rustc_mir/src/transform/check_consts/qualifs.rs:250:9 #81315

Closed
krinkinmu opened this issue Jan 23, 2021 · 3 comments · Fixed by #80404
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@krinkinmu
Copy link

krinkinmu commented Jan 23, 2021

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.

@krinkinmu krinkinmu added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 23, 2021
@jonas-schievink jonas-schievink added A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jan 23, 2021
@camelid
Copy link
Member

camelid commented Jan 24, 2021

This ICE first appeared in 1.42, but this code first started ICEing (with a slightly different message) in 1.41.

@rustbot label: regression-from-stable-to-stable

@rustbot rustbot added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Jan 24, 2021
@camelid camelid added the A-const-eval Area: Constant evaluation (MIR interpretation) label Jan 24, 2021
@camelid
Copy link
Member

camelid commented Jan 24, 2021

Minimized:

struct A {
    data: &'static u32,
}

const aa_storage: [A; 32] = [A { data: &1 }; 32];

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
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 (4d0dd02ee 2021-01-23) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_borrowck] borrow-checking `aa_storage`
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `playground`

To learn more, run the command again with --verbose.

Doesn't require const fn:
@rustbot label: -A-const-fn

This code also doesn't use nightly features.

@rustbot rustbot removed the A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. label Jan 24, 2021
@apiraino apiraino added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jan 28, 2021
@apiraino
Copy link
Contributor

Assigning P-high as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@bors bors closed this as completed in 99f2f5a Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants