Skip to content

ICE: An unexpected panic occurs when const function containing panic!("") drops a value with const_precise_live_drops. #89938

Closed
@lilasta

Description

@lilasta

This only occur in --edition=2021.

Code

playground

#![feature(const_precise_live_drops)]

const fn eh<T>(_val: T) {
    if false {
        // The same is true for `unimplemented`, `unreachable` and `todo`.
        // In the case of `panic!()`, an error doesn't occur.
        panic!("");
    }
}

fn main() {}

Meta

rustc --version --verbose:

rustc --version --verbose
rustc 1.57.0-nightly (c1026539b 2021-10-15)
binary: rustc
commit-hash: c1026539bd22e9d070988deaa47b1360cbc76436
commit-date: 2021-10-15
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0

Error output

thread 'rustc' panicked at 'assertion failed: promoted.is_none()', compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs:292:13
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.57.0-nightly (c1026539b 2021-10-15) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `eh`
#1 [analysis] running analysis passes on this crate
end of query stack
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/c1026539bd22e9d070988deaa47b1360cbc76436/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/c1026539bd22e9d070988deaa47b1360cbc76436/library/core/src/panicking.rs:100:14
   2: core::panicking::panic
             at /rustc/c1026539bd22e9d070988deaa47b1360cbc76436/library/core/src/panicking.rs:50:5
   3: rustc_const_eval::transform::check_consts::qualifs::in_operand
   4: <rustc_const_eval::transform::check_consts::resolver::FlowSensitiveAnalysis<Q> as rustc_mir_dataflow::framework::Analysis>::apply_statement_effect
   5: rustc_mir_dataflow::framework::engine::Engine<A>::iterate_to_fixpoint
   6: rustc_const_eval::transform::check_consts::check::Qualifs::needs_drop
   7: <rustc_const_eval::transform::check_consts::post_drop_elaboration::CheckLiveDrops as rustc_middle::mir::visit::Visitor>::visit_terminator
   8: rustc_const_eval::transform::check_consts::post_drop_elaboration::check_live_drops
   9: rustc_mir_transform::mir_drops_elaborated_and_const_checked
  10: rustc_query_system::query::plumbing::try_execute_query
  11: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_drops_elaborated_and_const_checked
  12: rustc_session::utils::<impl rustc_session::session::Session>::time
  13: rustc_interface::passes::analysis
  14: rustc_query_system::query::plumbing::try_execute_query
  15: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  16: rustc_interface::passes::QueryContext::enter
  17: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  18: rustc_span::with_source_map
  19: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-edition-2021Area: The 2021 editionC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions