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

ICE: should not be requesting the constness of items that can't be const: ImplItem( #139278

Closed
matthiaskrgr opened this issue Apr 2, 2025 · 4 comments · Fixed by #139349
Closed
Assignees
Labels
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.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Apr 2, 2025

auto-reduced (treereduce-rust):

struct Foo;

impl Drop for Foo {
    thread_local!(static SPLOK: u32 = 0);
}

thread_local!(static Box: Foo = Foo);

original:

//@ run-pass
//@ needs-threads

use std::thread;

struct Foo;

impl Drop for Foo {
        thread_local! {
            // no docs
            #[allow(unused)]
            static FOO: i32 = 42;
            /// docs
            pub static BAR: String = String::from("bar");

            // look at these restrictions!!
            pub(crate) static BAZ: usize = 0;
            pub(in foo) static QUUX: usize = 0;
        }
        thread_local!(static SPLOK: u32 = 0);
    }

thread_local!(static Box: Foo = Foo);

fn main() {
    // Off the main thread due to #28129, be sure to initialize FOO first before
    // calling `println!`
    thread::spawn(|| {
        FOO.with(|_| {});
        println!("test1");
    })
    .join()
    .unwrap();
}

Version information

rustc 1.88.0-nightly (4f0de4c81 2025-04-02)
binary: rustc
commit-hash: 4f0de4c81d80121ac7b576bc68d8016064f4d261
commit-date: 2025-04-02
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.1

Possibly related line of code:

}
// If the function itself is not annotated with `const`, it may still be a `const fn`
// if it resides in a const trait impl.
parent_impl_or_trait_constness(tcx, def_id)
} else {
tcx.dcx().span_bug(
tcx.def_span(def_id),
format!("should not be requesting the constness of items that can't be const: {node:#?}: {:?}", tcx.def_kind(def_id))
)
}
}
}

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0438]: const `SPLOK` is not a member of trait `Drop`
 --> /tmp/icemaker_global_tempdir.iMZkdTjDBtF1/rustc_testrunner_tmpdir_reporting.H4njEG4lXrr3/mvce.rs:4:5
  |
4 |     thread_local!(static SPLOK: u32 = 0);
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `Drop`
  |
  = note: this error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.iMZkdTjDBtF1/rustc_testrunner_tmpdir_reporting.H4njEG4lXrr3/mvce.rs:7:38
  |
7 | thread_local!(static Box: Foo = Foo);
  |                                      ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.iMZkdTjDBtF1/rustc_testrunner_tmpdir_reporting.H4njEG4lXrr3/mvce.rs`

error[E0046]: not all trait items implemented, missing: `drop`
 --> /tmp/icemaker_global_tempdir.iMZkdTjDBtF1/rustc_testrunner_tmpdir_reporting.H4njEG4lXrr3/mvce.rs:3:1
  |
3 | impl Drop for Foo {
  | ^^^^^^^^^^^^^^^^^ missing `drop` in implementation
  |
  = help: implement the missing item: `fn drop(&mut self) { todo!() }`

error: internal compiler error: should not be requesting the constness of items that can't be const: ImplItem(
                                    ImplItem {
                                        ident: SPLOK#0,
                                        owner_id: DefId(0:6 ~ mvce[fb01]::{impl#0}::SPLOK),
                                        generics: Generics {
                                            params: [],
                                            predicates: [],
                                            has_where_clause_predicates: false,
                                            where_clause_span: /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/std/src/sys/thread_local/native/mod.rs:108:68: 108:68 (#10),
                                            span: /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/std/src/sys/thread_local/native/mod.rs:108:38: 108:38 (#10),
                                        },
                                        kind: Const(
                                            Ty {
                                                hir_id: HirId(DefId(0:6 ~ mvce[fb01]::{impl#0}::SPLOK).1),
                                                span: /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/std/src/sys/thread_local/native/mod.rs:108:40: 108:68 (#10),
                                                kind: Path(
                                                    Resolved(
                                                        None,
                                                        Path {
                                                            span: /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/std/src/sys/thread_local/native/mod.rs:108:40: 108:68 (#10),
                                                            res: Def(
                                                                Struct,
                                                                DefId(1:571 ~ std[64a3]::thread::local::LocalKey),
                                                            ),
                                                            segments: [
                                                                PathSegment {
                                                                    ident: $crate#10,
                                                                    hir_id: HirId(DefId(0:6 ~ mvce[fb01]::{impl#0}::SPLOK).2),
                                                                    res: Def(
                                                                        Mod,
                                                                        DefId(1:0 ~ std[64a3]),
                                                                    ),
                                                                    args: None,
                                                                    infer_args: false,
                                                                },
                                                                PathSegment {
                                                                    ident: thread#10,
                                                                    hir_id: HirId(DefId(0:6 ~ mvce[fb01]::{impl#0}::SPLOK).3),
                                                                    res: Def(
                                                                        Mod,
                                                                        DefId(1:406 ~ std[64a3]::thread),
                                                                    ),
                                                                    args: None,
                                                                    infer_args: false,
                                                                },
                                                                PathSegment {
                                                                    ident: LocalKey#10,
                                                                    hir_id: HirId(DefId(0:6 ~ mvce[fb01]::{impl#0}::SPLOK).6),
                                                                    res: Def(
                                                                        Struct,
                                                                        DefId(1:571 ~ std[64a3]::thread::local::LocalKey),
                                                                    ),
                                                                    args: Some(
                                                                        GenericArgs {
                                                                            args: [
                                                                                Type(
                                                                                    Ty {
                                                                                        hir_id: HirId(DefId(0:6 ~ mvce[fb01]::{impl#0}::SPLOK).4),
                                                                                        span: /tmp/icemaker_global_tempdir.iMZkdTjDBtF1/rustc_testrunner_tmpdir_reporting.H4njEG4lXrr3/mvce.rs:4:33: 4:36 (#0),
                                                                                        kind: Path(
                                                                                            Resolved(
                                                                                                None,
                                                                                                Path {
                                                                                                    span: /tmp/icemaker_global_tempdir.iMZkdTjDBtF1/rustc_testrunner_tmpdir_reporting.H4njEG4lXrr3/mvce.rs:4:33: 4:36 (#0),
                                                                                                    res: PrimTy(
                                                                                                        Uint(
                                                                                                            U32,
                                                                                                        ),
                                                                                                    ),
                                                                                                    segments: [
                                                                                                        PathSegment {
                                                                                                            ident: u32#0,
                                                                                                            hir_id: HirId(DefId(0:6 ~ mvce[fb01]::{impl#0}::SPLOK).5),
                                                                                                            res: PrimTy(
                                                                                                                Uint(
                                                                                                                    U32,
                                                                                                                ),
                                                                                                            ),
                                                                                                            args: None,
                                                                                                            infer_args: false,
                                                                                                        },
                                                                                                    ],
                                                                                                },
                                                                                            ),
                                                                                        ),
                                                                                    },
                                                                                ),
                                                                            ],
                                                                            constraints: [],
                                                                            parenthesized: No,
                                                                            span_ext: /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/std/src/sys/thread_local/native/mod.rs:108:64: 108:68 (#10),
                                                                        },
                                                                    ),
                                                                    infer_args: false,
                                                                },
                                                            ],
                                                        },
                                                    ),
                                                ),
                                            },
                                            BodyId {
                                                hir_id: HirId(DefId(0:6 ~ mvce[fb01]::{impl#0}::SPLOK).7),
                                            },
                                        ),
                                        defaultness: Final,
                                        span: /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/std/src/sys/thread_local/native/mod.rs:108:22: 109:81 (#10),
                                        vis_span: /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/std/src/sys/thread_local/native/mod.rs:108:22: 108:22 (#10),
                                    },
                                ): AssocConst
 --> /tmp/icemaker_global_tempdir.iMZkdTjDBtF1/rustc_testrunner_tmpdir_reporting.H4njEG4lXrr3/mvce.rs:4:5
  |
4 |     thread_local!(static SPLOK: u32 = 0);
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error: internal compiler error originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)


thread 'rustc' panicked at compiler/rustc_const_eval/src/const_eval/fn_queries.rs:43:27:
Box<dyn Any>
stack backtrace:
   0:     0x7310a3271b23 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h6276d246583c5920
   1:     0x7310a3a06111 - core::fmt::write::h1ce97450a6826ddd
   2:     0x7310a4ea2fd1 - std::io::Write::write_fmt::h9303e97b3c369b59
   3:     0x7310a3271982 - std::sys::backtrace::BacktraceLock::print::hea9f14d6ca9b0147
   4:     0x7310a327546a - std::panicking::default_hook::{{closure}}::h47e4ac810bd31853
   5:     0x7310a3274fef - std::panicking::default_hook::h0a321ea46395d69c
   6:     0x7310a22ec910 - std[64a3ecc47e3ea7b6]::panicking::update_hook::<alloc[b66be81d450b4e53]::boxed::Box<rustc_driver_impl[364dfd96f8312c97]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7310a3275ce3 - std::panicking::rust_panic_with_hook::hf664c17233f51fc1
   8:     0x7310a232bd31 - std[64a3ecc47e3ea7b6]::panicking::begin_panic::<rustc_errors[ce2661ba159e5cd2]::ExplicitBug>::{closure#0}
   9:     0x7310a231f926 - std[64a3ecc47e3ea7b6]::sys::backtrace::__rust_end_short_backtrace::<std[64a3ecc47e3ea7b6]::panicking::begin_panic<rustc_errors[ce2661ba159e5cd2]::ExplicitBug>::{closure#0}, !>
  10:     0x7310a231f5a7 - std[64a3ecc47e3ea7b6]::panicking::begin_panic::<rustc_errors[ce2661ba159e5cd2]::ExplicitBug>
  11:     0x7310a2335591 - <rustc_errors[ce2661ba159e5cd2]::diagnostic::BugAbort as rustc_errors[ce2661ba159e5cd2]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7310a2222f10 - <rustc_errors[ce2661ba159e5cd2]::DiagCtxtHandle>::span_bug::<rustc_span[16c8bd6e3b329917]::span_encoding::Span, alloc[b66be81d450b4e53]::string::String>
  13:     0x7310a3f4076a - rustc_const_eval[2390ba62feb5bb12]::const_eval::fn_queries::constness
  14:     0x7310a3f3ffb7 - rustc_query_impl[45df45b8015af900]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[45df45b8015af900]::query_impl::constness::dynamic_query::{closure#2}::{closure#0}, rustc_middle[952277fedfa7cd0]::query::erase::Erased<[u8; 1usize]>>
  15:     0x7310a3f3dd18 - rustc_query_system[70e2f348503a4b9c]::query::plumbing::try_execute_query::<rustc_query_impl[45df45b8015af900]::DynamicConfig<rustc_query_system[70e2f348503a4b9c]::query::caches::DefIdCache<rustc_middle[952277fedfa7cd0]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[45df45b8015af900]::plumbing::QueryCtxt, false>
  16:     0x7310a3f3d808 - rustc_query_impl[45df45b8015af900]::query_impl::constness::get_query_non_incr::__rust_end_short_backtrace
  17:     0x7310a46c54cc - rustc_trait_selection[6fb3ce8d98383ae4]::traits::effects::evaluate_host_effect_obligation
  18:     0x7310a43ed9a0 - <rustc_trait_selection[6fb3ce8d98383ae4]::traits::fulfill::FulfillProcessor as rustc_data_structures[845dae019623b7f5]::obligation_forest::ObligationProcessor>::process_obligation
  19:     0x7310a3a07d04 - <rustc_data_structures[845dae019623b7f5]::obligation_forest::ObligationForest<rustc_trait_selection[6fb3ce8d98383ae4]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[6fb3ce8d98383ae4]::traits::fulfill::FulfillProcessor>
  20:     0x7310a3ef1d62 - <rustc_trait_selection[6fb3ce8d98383ae4]::traits::fulfill::FulfillmentContext<rustc_infer[b309e7d4c50f26cd]::traits::engine::ScrubbedTraitError> as rustc_infer[b309e7d4c50f26cd]::traits::engine::TraitEngine<rustc_infer[b309e7d4c50f26cd]::traits::engine::ScrubbedTraitError>>::select_all_or_error
  21:     0x7310a4703e32 - <rustc_const_eval[2390ba62feb5bb12]::check_consts::qualifs::NeedsNonConstDrop as rustc_const_eval[2390ba62feb5bb12]::check_consts::qualifs::Qualif>::in_any_value_of_ty
  22:     0x7310a4702e20 - <rustc_const_eval[2390ba62feb5bb12]::check_consts::check::Qualifs>::needs_non_const_drop
  23:     0x7310a4701953 - rustc_mir_transform[868be19dd7dc581f]::mir_const_qualif
  24:     0x7310a47016a5 - rustc_query_impl[45df45b8015af900]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[45df45b8015af900]::query_impl::mir_const_qualif::dynamic_query::{closure#2}::{closure#0}, rustc_middle[952277fedfa7cd0]::query::erase::Erased<[u8; 4usize]>>
  25:     0x7310a47009eb - rustc_query_system[70e2f348503a4b9c]::query::plumbing::try_execute_query::<rustc_query_impl[45df45b8015af900]::DynamicConfig<rustc_query_system[70e2f348503a4b9c]::query::caches::DefIdCache<rustc_middle[952277fedfa7cd0]::query::erase::Erased<[u8; 4usize]>>, false, false, false>, rustc_query_impl[45df45b8015af900]::plumbing::QueryCtxt, false>
  26:     0x7310a470074e - rustc_query_impl[45df45b8015af900]::query_impl::mir_const_qualif::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7310a114452f - rustc_mir_transform[868be19dd7dc581f]::mir_promoted
  28:     0x7310a439ff92 - rustc_query_impl[45df45b8015af900]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[45df45b8015af900]::query_impl::mir_promoted::dynamic_query::{closure#2}::{closure#0}, rustc_middle[952277fedfa7cd0]::query::erase::Erased<[u8; 16usize]>>
  29:     0x7310a43a022a - rustc_query_system[70e2f348503a4b9c]::query::plumbing::try_execute_query::<rustc_query_impl[45df45b8015af900]::DynamicConfig<rustc_data_structures[845dae019623b7f5]::vec_cache::VecCache<rustc_span[16c8bd6e3b329917]::def_id::LocalDefId, rustc_middle[952277fedfa7cd0]::query::erase::Erased<[u8; 16usize]>, rustc_query_system[70e2f348503a4b9c]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[45df45b8015af900]::plumbing::QueryCtxt, false>
  30:     0x7310a4bb860b - rustc_query_impl[45df45b8015af900]::query_impl::mir_promoted::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7310a4bb86ed - rustc_query_impl[45df45b8015af900]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[45df45b8015af900]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[952277fedfa7cd0]::query::erase::Erased<[u8; 8usize]>>
  32:     0x7310a3cb1f6c - rustc_query_system[70e2f348503a4b9c]::query::plumbing::try_execute_query::<rustc_query_impl[45df45b8015af900]::DynamicConfig<rustc_data_structures[845dae019623b7f5]::vec_cache::VecCache<rustc_span[16c8bd6e3b329917]::def_id::LocalDefId, rustc_middle[952277fedfa7cd0]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[70e2f348503a4b9c]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[45df45b8015af900]::plumbing::QueryCtxt, false>
  33:     0x7310a3cb19cb - rustc_query_impl[45df45b8015af900]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7310a3ead9e3 - rustc_mir_transform[868be19dd7dc581f]::mir_drops_elaborated_and_const_checked
  35:     0x7310a3ead0e5 - rustc_query_impl[45df45b8015af900]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[45df45b8015af900]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[952277fedfa7cd0]::query::erase::Erased<[u8; 8usize]>>
  36:     0x7310a3cb1f6c - rustc_query_system[70e2f348503a4b9c]::query::plumbing::try_execute_query::<rustc_query_impl[45df45b8015af900]::DynamicConfig<rustc_data_structures[845dae019623b7f5]::vec_cache::VecCache<rustc_span[16c8bd6e3b329917]::def_id::LocalDefId, rustc_middle[952277fedfa7cd0]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[70e2f348503a4b9c]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[45df45b8015af900]::plumbing::QueryCtxt, false>
  37:     0x7310a3cb184b - rustc_query_impl[45df45b8015af900]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  38:     0x7310a3f70a06 - rustc_mir_transform[868be19dd7dc581f]::mir_for_ctfe
  39:     0x7310a3f70827 - rustc_query_impl[45df45b8015af900]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[45df45b8015af900]::query_impl::mir_for_ctfe::dynamic_query::{closure#2}::{closure#0}, rustc_middle[952277fedfa7cd0]::query::erase::Erased<[u8; 8usize]>>
  40:     0x7310a3d585ef - rustc_query_system[70e2f348503a4b9c]::query::plumbing::try_execute_query::<rustc_query_impl[45df45b8015af900]::DynamicConfig<rustc_query_system[70e2f348503a4b9c]::query::caches::DefIdCache<rustc_middle[952277fedfa7cd0]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[45df45b8015af900]::plumbing::QueryCtxt, false>
  41:     0x7310a48a5dbb - rustc_query_impl[45df45b8015af900]::query_impl::mir_for_ctfe::get_query_non_incr::__rust_end_short_backtrace
  42:     0x7310a48a5ee7 - <rustc_const_eval[2390ba62feb5bb12]::interpret::eval_context::InterpCx<rustc_const_eval[2390ba62feb5bb12]::const_eval::machine::CompileTimeMachine>>::load_mir
  43:     0x7310a4b49a2a - rustc_const_eval[2390ba62feb5bb12]::const_eval::eval_queries::eval_static_initializer_provider
  44:     0x7310a4b49627 - rustc_query_impl[45df45b8015af900]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[45df45b8015af900]::query_impl::eval_static_initializer::dynamic_query::{closure#2}::{closure#0}, rustc_middle[952277fedfa7cd0]::query::erase::Erased<[u8; 16usize]>>
  45:     0x7310a4b49609 - <rustc_query_impl[45df45b8015af900]::query_impl::eval_static_initializer::dynamic_query::{closure#2} as core[4c10ad9516df98d8]::ops::function::FnOnce<(rustc_middle[952277fedfa7cd0]::ty::context::TyCtxt, rustc_span[16c8bd6e3b329917]::def_id::DefId)>>::call_once
  46:     0x7310a3c77300 - rustc_query_system[70e2f348503a4b9c]::query::plumbing::try_execute_query::<rustc_query_impl[45df45b8015af900]::DynamicConfig<rustc_query_system[70e2f348503a4b9c]::query::caches::DefIdCache<rustc_middle[952277fedfa7cd0]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[45df45b8015af900]::plumbing::QueryCtxt, false>
  47:     0x7310a4b13166 - rustc_query_impl[45df45b8015af900]::query_impl::eval_static_initializer::get_query_non_incr::__rust_end_short_backtrace
  48:     0x7310a3cb02bb - rustc_hir_analysis[c0538ce4abe59eb]::check_crate
  49:     0x7310a41c8fa5 - rustc_interface[809c8c781064d3fa]::passes::run_required_analyses
  50:     0x7310a41b74de - rustc_interface[809c8c781064d3fa]::passes::analysis
  51:     0x7310a41b74b3 - rustc_query_impl[45df45b8015af900]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[45df45b8015af900]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[952277fedfa7cd0]::query::erase::Erased<[u8; 0usize]>>
  52:     0x7310a49b99bd - rustc_query_system[70e2f348503a4b9c]::query::plumbing::try_execute_query::<rustc_query_impl[45df45b8015af900]::DynamicConfig<rustc_query_system[70e2f348503a4b9c]::query::caches::SingleCache<rustc_middle[952277fedfa7cd0]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[45df45b8015af900]::plumbing::QueryCtxt, false>
  53:     0x7310a49b96b8 - rustc_query_impl[45df45b8015af900]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  54:     0x7310a4b9380d - rustc_interface[809c8c781064d3fa]::passes::create_and_enter_global_ctxt::<core[4c10ad9516df98d8]::option::Option<rustc_interface[809c8c781064d3fa]::queries::Linker>, rustc_driver_impl[364dfd96f8312c97]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  55:     0x7310a4b5cf2a - rustc_interface[809c8c781064d3fa]::interface::run_compiler::<(), rustc_driver_impl[364dfd96f8312c97]::run_compiler::{closure#0}>::{closure#1}
  56:     0x7310a499bfd2 - std[64a3ecc47e3ea7b6]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[809c8c781064d3fa]::util::run_in_thread_with_globals<rustc_interface[809c8c781064d3fa]::util::run_in_thread_pool_with_globals<rustc_interface[809c8c781064d3fa]::interface::run_compiler<(), rustc_driver_impl[364dfd96f8312c97]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  57:     0x7310a499c8b4 - <<std[64a3ecc47e3ea7b6]::thread::Builder>::spawn_unchecked_<rustc_interface[809c8c781064d3fa]::util::run_in_thread_with_globals<rustc_interface[809c8c781064d3fa]::util::run_in_thread_pool_with_globals<rustc_interface[809c8c781064d3fa]::interface::run_compiler<(), rustc_driver_impl[364dfd96f8312c97]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[4c10ad9516df98d8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  58:     0x7310a499dcab - std::sys::pal::unix::thread::Thread::new::thread_start::hcc40a29411d3318b
  59:     0x73109e8a370a - <unknown>
  60:     0x73109e927aac - <unknown>
  61:                0x0 - <unknown>

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: please make sure that you have updated to the latest nightly

note: rustc 1.88.0-nightly (4f0de4c81 2025-04-02) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [constness] checking if item is const: `<impl at /tmp/icemaker_global_tempdir.iMZkdTjDBtF1/rustc_testrunner_tmpdir_reporting.H4njEG4lXrr3/mvce.rs:3:1: 3:18>::SPLOK`
#1 [mir_const_qualif] const checking `Box::{constant#0}::{closure#0}::VAL`
#2 [mir_promoted] promoting constants in MIR for `Box::{constant#0}::{closure#0}::VAL`
#3 [mir_borrowck] borrow-checking `Box::{constant#0}::{closure#0}::VAL`
#4 [mir_drops_elaborated_and_const_checked] elaborating drops for `Box::{constant#0}::{closure#0}::VAL`
#5 [mir_for_ctfe] caching mir of `Box::{constant#0}::{closure#0}::VAL` for CTFE  |  = note: this failure-note originates in the macro `$crate::thread::local_impl::thread_local_inner` which comes from the expansion of the macro `thread_local` (in Nightly builds, run with -Z macro-backtrace for more info)

#6 [eval_static_initializer] evaluating initializer of static `Box::{constant#0}::{closure#0}::VAL`
#7 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0046, E0438, E0601.
For more information about an error, try `rustc --explain E0046`.

@matthiaskrgr matthiaskrgr 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 Apr 2, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 2, 2025
@matthiaskrgr
Copy link
Member Author

bisects to #139018

@cyrgani
Copy link
Contributor

cyrgani commented Apr 3, 2025

simpler:

struct Foo;

impl Drop for Foo {
    const SPLOK: u32 = 0;
}
const X: Foo = Foo;

@meithecatte
Copy link
Contributor

The bad commit is 6697f02.

@meithecatte
Copy link
Contributor

@rustbot claim

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 4, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 4, 2025
…r=compiler-errors

adt_destructor: sanity-check returned item

Fixes rust-lang#139278
@bors bors closed this as completed in a14e8f6 Apr 4, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 4, 2025
Rollup merge of rust-lang#139349 - meithecatte:destructor-constness, r=compiler-errors

adt_destructor: sanity-check returned item

Fixes rust-lang#139278
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants