Skip to content

ICE: primitive read not possible for type #131347

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

struct S; static STUFF: [i8] = [0; S::N]; fn main() { assert_eq!(STUFF, [0; 63]); } 

original:

//@ run-pass struct S; impl S { const N: usize = 3; } static STUFF: [i8] = [0; S::N]; fn main() { assert_eq!(STUFF, [0; 63]); }

Version information

rustc 1.83.0-nightly (7d53688b2 2024-10-06) binary: rustc commit-hash: 7d53688b25d52d822c7094ee80db42b2b2f2a8d3 commit-date: 2024-10-06 host: x86_64-unknown-linux-gnu release: 1.83.0-nightly LLVM version: 19.1.1 

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zmir-opt-level=5 -Zvalidate-mir

Program output

error[E0277]: the size for values of type `[i8]` cannot be known at compilation time --> /tmp/icemaker_global_tempdir.DNQmEJ3ruUkV/rustc_testrunner_tmpdir_reporting.YpnplTJyJ0BS/mvce.rs:3:15 | 3 | static STUFF: [i8] = [0; S::N]; | ^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[i8]` error[E0599]: no associated item named `N` found for struct `S` in the current scope --> /tmp/icemaker_global_tempdir.DNQmEJ3ruUkV/rustc_testrunner_tmpdir_reporting.YpnplTJyJ0BS/mvce.rs:3:29 | 1 | struct S; | -------- associated item `N` not found for this struct 2 | 3 | static STUFF: [i8] = [0; S::N]; | ^ associated item not found in `S` error[E0277]: the size for values of type `[i8]` cannot be known at compilation time --> /tmp/icemaker_global_tempdir.DNQmEJ3ruUkV/rustc_testrunner_tmpdir_reporting.YpnplTJyJ0BS/mvce.rs:3:22 | 3 | static STUFF: [i8] = [0; S::N]; | ^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[i8]` = note: constant expressions must have a statically known size error: internal compiler error: /rustc/7d53688b25d52d822c7094ee80db42b2b2f2a8d3/compiler/rustc_const_eval/src/interpret/operand.rs:637:13: primitive read not possible for type: () thread 'rustc' panicked at /rustc/7d53688b25d52d822c7094ee80db42b2b2f2a8d3/compiler/rustc_const_eval/src/interpret/operand.rs:637:13: Box<dyn Any> stack backtrace: 0: 0x7e646991d14a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h6ace371e0627a94e 1: 0x7e646a003466 - core::fmt::write::h0da4415e760642fe 2: 0x7e646b2d4651 - std::io::Write::write_fmt::h14d763d63a110c4d 3: 0x7e646991cfa2 - std::sys::backtrace::BacktraceLock::print::h7d6a7a510b18a0ef 4: 0x7e646991f476 - std::panicking::default_hook::{{closure}}::h754c7d0464a75c1a 5: 0x7e646991f2c0 - std::panicking::default_hook::ha44cb32a98416a5c 6: 0x7e64689d4ebf - std[f5329afc3aca534d]::panicking::update_hook::<alloc[75367514fbcf0ba1]::boxed::Box<rustc_driver_impl[2db31ecf159f2c88]::install_ice_hook::{closure#0}>>::{closure#0} 7: 0x7e646991fb88 - std::panicking::rust_panic_with_hook::hba17070c6731b05a 8: 0x7e6468a0ea11 - std[f5329afc3aca534d]::panicking::begin_panic::<rustc_errors[497b4da1b5346fe1]::ExplicitBug>::{closure#0} 9: 0x7e6468a01ab6 - std[f5329afc3aca534d]::sys::backtrace::__rust_end_short_backtrace::<std[f5329afc3aca534d]::panicking::begin_panic<rustc_errors[497b4da1b5346fe1]::ExplicitBug>::{closure#0}, !> 10: 0x7e6468a01a73 - std[f5329afc3aca534d]::panicking::begin_panic::<rustc_errors[497b4da1b5346fe1]::ExplicitBug> 11: 0x7e6468a182a1 - <rustc_errors[497b4da1b5346fe1]::diagnostic::BugAbort as rustc_errors[497b4da1b5346fe1]::diagnostic::EmissionGuarantee>::emit_producing_guarantee 12: 0x7e646913e1ad - <rustc_errors[497b4da1b5346fe1]::DiagCtxtHandle>::span_bug::<rustc_span[4e6ff54001148787]::span_encoding::Span, alloc[75367514fbcf0ba1]::string::String> 13: 0x7e646916f9d8 - rustc_middle[371b8b9dd6010c8]::util::bug::opt_span_bug_fmt::<rustc_span[4e6ff54001148787]::span_encoding::Span>::{closure#0} 14: 0x7e646916fa0a - rustc_middle[371b8b9dd6010c8]::ty::context::tls::with_opt::<rustc_middle[371b8b9dd6010c8]::util::bug::opt_span_bug_fmt<rustc_span[4e6ff54001148787]::span_encoding::Span>::{closure#0}, !>::{closure#0} 15: 0x7e646915947b - rustc_middle[371b8b9dd6010c8]::ty::context::tls::with_context_opt::<rustc_middle[371b8b9dd6010c8]::ty::context::tls::with_opt<rustc_middle[371b8b9dd6010c8]::util::bug::opt_span_bug_fmt<rustc_span[4e6ff54001148787]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !> 16: 0x7e64691582a7 - rustc_middle[371b8b9dd6010c8]::util::bug::span_bug_fmt::<rustc_span[4e6ff54001148787]::span_encoding::Span> 17: 0x7e646aabce42 - <rustc_mir_transform[da304eeb1db9ec1]::gvn::VnState>::insert 18: 0x7e646aab24e0 - <rustc_mir_transform[da304eeb1db9ec1]::gvn::VnState>::simplify_rvalue 19: 0x7e64675d42a4 - <rustc_mir_transform[da304eeb1db9ec1]::gvn::GVN as rustc_mir_transform[da304eeb1db9ec1]::pass_manager::MirPass>::run_pass 20: 0x7e646a00b6cd - rustc_mir_transform[da304eeb1db9ec1]::pass_manager::run_passes_inner 21: 0x7e646a2b5822 - rustc_mir_transform[da304eeb1db9ec1]::optimized_mir 22: 0x7e646a2b40e1 - rustc_query_impl[8639a1bd341d7b6f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8639a1bd341d7b6f]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[371b8b9dd6010c8]::query::erase::Erased<[u8; 8usize]>> 23: 0x7e646a292038 - rustc_query_system[51edba716c9866b7]::query::plumbing::try_execute_query::<rustc_query_impl[8639a1bd341d7b6f]::DynamicConfig<rustc_query_system[51edba716c9866b7]::query::caches::DefIdCache<rustc_middle[371b8b9dd6010c8]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[8639a1bd341d7b6f]::plumbing::QueryCtxt, false> 24: 0x7e646a2915f3 - rustc_query_impl[8639a1bd341d7b6f]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace 25: 0x7e646742b6ff - <rustc_middle[371b8b9dd6010c8]::ty::context::TyCtxt>::instance_mir 26: 0x7e646a46d14a - rustc_interface[e2e0aaaa9098ac0f]::passes::run_required_analyses 27: 0x7e646ad219de - rustc_interface[e2e0aaaa9098ac0f]::passes::analysis 28: 0x7e646ad219b1 - rustc_query_impl[8639a1bd341d7b6f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8639a1bd341d7b6f]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[371b8b9dd6010c8]::query::erase::Erased<[u8; 1usize]>> 29: 0x7e646aed80ee - rustc_query_system[51edba716c9866b7]::query::plumbing::try_execute_query::<rustc_query_impl[8639a1bd341d7b6f]::DynamicConfig<rustc_query_system[51edba716c9866b7]::query::caches::SingleCache<rustc_middle[371b8b9dd6010c8]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[8639a1bd341d7b6f]::plumbing::QueryCtxt, false> 30: 0x7e646aed7dcf - rustc_query_impl[8639a1bd341d7b6f]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 31: 0x7e646ad191de - rustc_interface[e2e0aaaa9098ac0f]::interface::run_compiler::<core[c850f409d6837007]::result::Result<(), rustc_span[4e6ff54001148787]::ErrorGuaranteed>, rustc_driver_impl[2db31ecf159f2c88]::run_compiler::{closure#0}>::{closure#1} 32: 0x7e646adf6690 - std[f5329afc3aca534d]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e2e0aaaa9098ac0f]::util::run_in_thread_with_globals<rustc_interface[e2e0aaaa9098ac0f]::util::run_in_thread_pool_with_globals<rustc_interface[e2e0aaaa9098ac0f]::interface::run_compiler<core[c850f409d6837007]::result::Result<(), rustc_span[4e6ff54001148787]::ErrorGuaranteed>, rustc_driver_impl[2db31ecf159f2c88]::run_compiler::{closure#0}>::{closure#1}, core[c850f409d6837007]::result::Result<(), rustc_span[4e6ff54001148787]::ErrorGuaranteed>>::{closure#0}, core[c850f409d6837007]::result::Result<(), rustc_span[4e6ff54001148787]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c850f409d6837007]::result::Result<(), rustc_span[4e6ff54001148787]::ErrorGuaranteed>> 33: 0x7e646adf6d57 - <<std[f5329afc3aca534d]::thread::Builder>::spawn_unchecked_<rustc_interface[e2e0aaaa9098ac0f]::util::run_in_thread_with_globals<rustc_interface[e2e0aaaa9098ac0f]::util::run_in_thread_pool_with_globals<rustc_interface[e2e0aaaa9098ac0f]::interface::run_compiler<core[c850f409d6837007]::result::Result<(), rustc_span[4e6ff54001148787]::ErrorGuaranteed>, rustc_driver_impl[2db31ecf159f2c88]::run_compiler::{closure#0}>::{closure#1}, core[c850f409d6837007]::result::Result<(), rustc_span[4e6ff54001148787]::ErrorGuaranteed>>::{closure#0}, core[c850f409d6837007]::result::Result<(), rustc_span[4e6ff54001148787]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c850f409d6837007]::result::Result<(), rustc_span[4e6ff54001148787]::ErrorGuaranteed>>::{closure#1} as core[c850f409d6837007]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 34: 0x7e646adf7c41 - std::sys::pal::unix::thread::Thread::new::thread_start::ha1af13d74af699f6 35: 0x7e646c59639d - <unknown> 36: 0x7e646c61b49c - <unknown> 37: 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.83.0-nightly (7d53688b2 2024-10-06) running on x86_64-unknown-linux-gnu note: compiler flags: -Z mir-opt-level=5 -Z validate-mir -Z dump-mir-dir=dir query stack during panic: #0 [optimized_mir] optimizing MIR for `main` #1 [analysis] running analysis passes on this crate end of query stack error: aborting due to 4 previous errors Some errors have detailed explanations: E0277, E0599. For more information about an error, try `rustc --explain E0277`. 

Metadata

Metadata

Assignees

Labels

A-mir-opt-GVNArea: MIR opt Global Value Numbering (GVN)A-mir-opt-inliningArea: MIR inliningC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions