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] Error: missing type for 'static' item #134542

Closed
ejhari opened this issue Dec 20, 2024 · 1 comment
Closed

[ICE] Error: missing type for 'static' item #134542

ejhari opened this issue Dec 20, 2024 · 1 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.

Comments

@ejhari
Copy link

ejhari commented Dec 20, 2024

Code

use std::sync::atomic::AtomicBool;

static SHUTDOWN = AtomicBool::new(false);

fn main() {
    println!("Hello, world!");
}

Meta

rustc --version --verbose:

rustc 1.80.1 (3f5fd8dd4 2024-08-06)
binary: rustc
commit-hash: 3f5fd8dd41153bc5fdca9427e9e05be2c767ba23
commit-date: 2024-08-06
host: x86_64-unknown-linux-gnu
release: 1.80.1
LLVM version: 18.1.7

Error output

$ cargo run
Compiling rust v0.1.0 (/home/hari/Workspace/Labs/rust)
error: missing type for `static` item
--> src/main.rs:3:16
|
3 | static SHUTDOWN = AtomicBool::new(false);
|                ^ help: provide a type for the static variable: `: AtomicBool`

thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/validity.rs:740:21:
assertion `left == right` failed
left: Mut
right: Not
stack backtrace:
0:     0x75b8a76bbf05 - std::backtrace_rs::backtrace::libunwind::trace::h23054e327d0d4b55
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
1:     0x75b8a76bbf05 - std::backtrace_rs::backtrace::trace_unsynchronized::h0cc587407d7f7f64
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2:     0x75b8a76bbf05 - std::sys_common::backtrace::_print_fmt::h4feeb59774730d6b
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/sys_common/backtrace.rs:68:5
3:     0x75b8a76bbf05 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd736fd5964392270
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/sys_common/backtrace.rs:44:22
4:     0x75b8a770cc4b - core::fmt::rt::Argument::fmt::h105051d8ea1ade1e
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/fmt/rt.rs:165:63
5:     0x75b8a770cc4b - core::fmt::write::hc6043626647b98ea
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/fmt/mod.rs:1168:21
6:     0x75b8a76b0bdf - std::io::Write::write_fmt::h0d24b3e0473045db
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/io/mod.rs:1835:15
7:     0x75b8a76bbcde - std::sys_common::backtrace::_print::h62df6fc36dcebfc8
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/sys_common/backtrace.rs:47:5
8:     0x75b8a76bbcde - std::sys_common::backtrace::print::h45eb8174d25a1e76
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/sys_common/backtrace.rs:34:9
9:     0x75b8a76be719 - std::panicking::default_hook::{{closure}}::haf3f0170eb4f3b53
10:     0x75b8a76be4ba - std::panicking::default_hook::hb5d3b27aa9f6dcda
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:298:9
11:     0x75b8a40150c1 - std[fba9fafec3bdacf8]::panicking::update_hook::<alloc[a325a9cea6fa5e89]::boxed::Box<rustc_driver_impl[ce01f96e2e949677]::install_ice_hook::{closure#0}>>::{closure#0}
12:     0x75b8a76bee4b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h2026a29033a1b9f6
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/alloc/src/boxed.rs:2077:9
13:     0x75b8a76bee4b - std::panicking::rust_panic_with_hook::h6b49d59f86ee588c
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:799:13
14:     0x75b8a76bebc4 - std::panicking::begin_panic_handler::{{closure}}::hd4c2f7ed79b82b70
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:664:13
15:     0x75b8a76bc3c9 - std::sys_common::backtrace::__rust_end_short_backtrace::h2946d6d32d7ea1ad
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/sys_common/backtrace.rs:171:18
16:     0x75b8a76be8f7 - rust_begin_unwind
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:652:5
17:     0x75b8a77091e3 - core::panicking::panic_fmt::ha02418e5cd774672
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/panicking.rs:72:14
18:     0x75b8a770970e - core::panicking::assert_failed_inner::h4faeef112caf2bb9
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/panicking.rs:408:17
19:     0x75b8a3f93233 - core[1a380081440346cb]::panicking::assert_failed::<rustc_ast_ir[1cfa22c48385e561]::Mutability, rustc_ast_ir[1cfa22c48385e561]::Mutability>
20:     0x75b8a68dbff2 - rustc_const_eval[964325fd78f4b8e1]::interpret::validity::mutability::<rustc_const_eval[964325fd78f4b8e1]::const_eval::machine::CompileTimeInterpreter>.cold
21:     0x75b8a5afdf6a - <rustc_const_eval[964325fd78f4b8e1]::interpret::validity::ValidityVisitor<rustc_const_eval[964325fd78f4b8e1]::const_eval::machine::CompileTimeInterpreter> as rustc_const_eval[964325fd78f4b8e1]::interpret::visitor::ValueVisitor<rustc_const_eval[964325fd78f4b8e1]::const_eval::machine::CompileTimeInterpreter>>::visit_value
22:     0x75b8a5afd2f0 - <rustc_const_eval[964325fd78f4b8e1]::interpret::validity::ValidityVisitor<rustc_const_eval[964325fd78f4b8e1]::const_eval::machine::CompileTimeInterpreter> as rustc_const_eval[964325fd78f4b8e1]::interpret::visitor::ValueVisitor<rustc_const_eval[964325fd78f4b8e1]::const_eval::machine::CompileTimeInterpreter>>::visit_value
23:     0x75b8a5b02e21 - <rustc_const_eval[964325fd78f4b8e1]::interpret::eval_context::InterpCx<rustc_const_eval[964325fd78f4b8e1]::const_eval::machine::CompileTimeInterpreter>>::validate_operand_internal
24:     0x75b8a6480dcc - rustc_const_eval[964325fd78f4b8e1]::const_eval::eval_queries::eval_body_using_ecx::<rustc_middle[ecc07153edf3c281]::mir::interpret::allocation::ConstAllocation>
25:     0x75b8a6447ea3 - rustc_const_eval[964325fd78f4b8e1]::const_eval::eval_queries::eval_static_initializer_provider
26:     0x75b8a6447be7 - rustc_query_impl[c1633093ec927e0e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c1633093ec927e0e]::query_impl::eval_static_initializer::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ecc07153edf3c281]::query::erase::Erased<[u8; 16usize]>>
27:     0x75b8a6447bc9 - <rustc_query_impl[c1633093ec927e0e]::query_impl::eval_static_initializer::dynamic_query::{closure#2} ascore[1a380081440346cb]::ops::function::FnOnce<(rustc_middle[ecc07153edf3c281]::ty::context::TyCtxt, rustc_span[4d50fd03223eefaa]::def_id::DefId)>>::call_once
28:     0x75b8a5a19bb5 - rustc_query_system[b257ee99c2874caa]::query::plumbing::try_execute_query::<rustc_query_impl[c1633093ec927e0e]::DynamicConfig<rustc_query_system[b257ee99c2874caa]::query::caches::DefIdCache<rustc_middle[ecc07153edf3c281]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[c1633093ec927e0e]::plumbing::QueryCtxt, true>
29:     0x75b8a5f1324a - rustc_query_impl[c1633093ec927e0e]::query_impl::eval_static_initializer::get_query_incr::__rust_end_short_backtrace
30:     0x75b8a5ddf57c - rustc_hir_analysis[be96d916f40dad1b]::check_crate
31:     0x75b8a5e9362b - rustc_interface[c31201428b712578]::passes::analysis
32:     0x75b8a5e93025 - rustc_query_impl[c1633093ec927e0e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c1633093ec927e0e]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ecc07153edf3c281]::query::erase::Erased<[u8;1usize]>>
33:     0x75b8a6139ef5 - rustc_query_system[b257ee99c2874caa]::query::plumbing::try_execute_query::<rustc_query_impl[c1633093ec927e0e]::DynamicConfig<rustc_query_system[b257ee99c2874caa]::query::caches::SingleCache<rustc_middle[ecc07153edf3c281]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c1633093ec927e0e]::plumbing::QueryCtxt, true>
34:     0x75b8a6139b38 - rustc_query_impl[c1633093ec927e0e]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
35:     0x75b8a601224d - rustc_interface[c31201428b712578]::interface::run_compiler::<core[1a380081440346cb]::result::Result<(),rustc_span[4d50fd03223eefaa]::ErrorGuaranteed>, rustc_driver_impl[ce01f96e2e949677]::run_compiler::{closure#0}>::{closure#1}
36:     0x75b8a6147869 - std[fba9fafec3bdacf8]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c31201428b712578]::util::run_in_thread_with_globals<rustc_interface[c31201428b712578]::interface::run_compiler<core[1a380081440346cb]::result::Result<(), rustc_span[4d50fd03223eefaa]::ErrorGuaranteed>, rustc_driver_impl[ce01f96e2e949677]::run_compiler::{closure#0}>::{closure#1}, core[1a380081440346cb]::result::Result<(), rustc_span[4d50fd03223eefaa]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[1a380081440346cb]::result::Result<(), rustc_span[4d50fd03223eefaa]::ErrorGuaranteed>>
37:     0x75b8a614766a - <<std[fba9fafec3bdacf8]::thread::Builder>::spawn_unchecked_<rustc_interface[c31201428b712578]::util::run_in_thread_with_globals<rustc_interface[c31201428b712578]::interface::run_compiler<core[1a380081440346cb]::result::Result<(), rustc_span[4d50fd03223eefaa]::ErrorGuaranteed>, rustc_driver_impl[ce01f96e2e949677]::run_compiler::{closure#0}>::{closure#1}, core[1a380081440346cb]::result::Result<(), rustc_span[4d50fd03223eefaa]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[1a380081440346cb]::result::Result<(), rustc_span[4d50fd03223eefaa]::ErrorGuaranteed>>::{closure#2} as core[1a380081440346cb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
38:     0x75b8a76c8e3b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hdf5fcef8be77a431
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/alloc/src/boxed.rs:2063:9
39:     0x75b8a76c8e3b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8e8c5ceee46ee198
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/alloc/src/boxed.rs:2063:9
40:     0x75b8a76c8e3b - std::sys::pal::unix::thread::Thread::new::thread_start::hb85dbfa54ba503d6
at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/sys/pal/unix/thread.rs:108:17
41:     0x75b8a0ea339d - <unknown>
42:     0x75b8a0f2849c - <unknown>
43:                0x0 - <unknown>

error: 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.80.1 (3f5fd8dd4 2024-08-06) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
#0 [eval_static_initializer] evaluating initializer of static `SHUTDOWN`
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `rust` (bin "rust") due to 1 previous error
Backtrace

No backtrace. Build failed due to same error.

@ejhari ejhari 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 Dec 20, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 20, 2024
@ejhari ejhari changed the title Compiler panicked when type was not provided for a static variable [ICE] Error: missing type for static item Dec 20, 2024
@ejhari ejhari changed the title [ICE] Error: missing type for static item [ICE] Error: missing type for 'static' item Dec 20, 2024
@theemathas
Copy link
Contributor

Duplicate of #124164. This bug is already fixed in a newer version of Rust.

@fmease fmease closed this as completed Dec 20, 2024
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 20, 2024
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

No branches or pull requests

4 participants