Skip to content

ICE with Drop types in statics #34053

Closed
Closed
@kornholi

Description

@kornholi
#![feature(drop_types_in_const)]
struct A(i32); // not limited to tuple structs

impl Drop for A {
    fn drop(&mut self) { }
}

static FOO: A = A(123);

fn main() {
    println!("{}", &FOO.0);
}

gives:

error: internal compiler error: unexpected panic
thread 'rustc' panicked at 'assertion failed: `(left == right)` (left: `1`, right: `2`)', ../src/librustc_trans/adt.rs:1425
stack backtrace:
   1:     0x7f73f3db3534 - std::sys::backtrace::tracing::imp::write::h6528da8103c51ab9
   2:     0x7f73f3dc1b3b - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::hbe741a5cc3c49508
   3:     0x7f73f3dc16d8 - std::panicking::default_hook::he0146e6a74621cb4
   4:     0x7f73f3d8488d - std::panicking::rust_panic_with_hook::h587239a80cad02d2
   5:     0x7f73f3dc1dd1 - std::panicking::begin_panic::h77cefecf7d758cdf
   6:     0x7f73f3d869da - std::panicking::begin_panic_fmt::hb3024643f3039337
   7:     0x7f73f17c5ce7 - rustc_trans::adt::build_const_struct::hdd0431344839d114
   8:     0x7f73f17c48f5 - rustc_trans::adt::trans_const::h7635f041c0960e31
   9:     0x7f73f18709af - rustc_trans::consts::const_expr_unadjusted::h7fee3ce2f8dec095
  10:     0x7f73f186c1c6 - rustc_trans::consts::const_expr::h89b51f911278b3c4
  11:     0x7f73f17f735c - rustc_trans::base::trans_item::hca2904a0eb6b2a6f
  12:     0x7f73f181047d - _<rustc_trans..base..TransItemsWithinModVisitor<'a, 'tcx> as rustc..hir..intravisit..Visitor<'v>>::visit_item::h9938dc39c74c3b7b
  13:     0x7f73f18008a7 - rustc_trans::base::trans_crate::h999c47a06d45abea
  14:     0x7f73f4311cdb - rustc_driver::driver::phase_4_translate_to_llvm::had910d0e745bc40f
  15:     0x7f73f430f9db - rustc_driver::driver::compile_input::_$u7b$$u7b$closure$u7d$$u7d$::he7bfc52a5708c702
  16:     0x7f73f430ad04 - rustc_driver::driver::phase_3_run_analysis_passes::_$u7b$$u7b$closure$u7d$$u7d$::h14076f482deadce2
  17:     0x7f73f4304073 - rustc::ty::context::TyCtxt::create_and_enter::hd16288ef035eb80e
  18:     0x7f73f42caee4 - rustc_driver::driver::compile_input::hfd60b020f6d0208d
  19:     0x7f73f42b51c9 - rustc_driver::run_compiler::h884d01d12eb76bbb
  20:     0x7f73f42b1e80 - std::panicking::try::call::h04b58e895b5a0293
  21:     0x7f73f3dd050b - __rust_try
  22:     0x7f73f3dd04ae - __rust_maybe_catch_panic
  23:     0x7f73f42b2a4a - _<F as alloc..boxed..FnBox<A>>::call_box::h09d8d6a2bbba123a
  24:     0x7f73f3dbfd34 - std::sys::thread::Thread::new::thread_start::h9c883b6d445ece46
  25:     0x7f73eb9b0473 - start_thread
  26:     0x7f73f3a0c69c - clone
  27:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions