Skip to content

ICE: expected int of size 8, but got size 2 #131102

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

Closed
matthiaskrgr opened this issue Oct 1, 2024 · 0 comments · Fixed by #136180
Closed

ICE: expected int of size 8, but got size 2 #131102

matthiaskrgr opened this issue Oct 1, 2024 · 0 comments · Fixed by #136180
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

pub struct Blorb<const N: u16>([String; N]);

pub struct Wrap(Blorb<0>);

pub const fn i(_: Wrap) {}

original:

//@ build-pass

pub(crate) const fn f<T, const N: usize>(_: [std::mem::MaybeUninit<T>; N]) {}

pub struct Blubb<T>(*const T);

pub const fn g<T, const N: usize>(_: [Blubb<T>; N]) {}

pub struct Blorb<const N: u16>([String; N]);

pub const fn h(_: Blorb<0>) {}

pub struct Wrap(Blorb<0>);

pub const fn i(_: Wrap) {}

fn main() {}

Version information

rustc 1.83.0-nightly (c4f717650 2024-10-01)
binary: rustc
commit-hash: c4f7176501a7d3c19c230b8c9111b2d39142f83a
commit-date: 2024-10-01
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0

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

Program output

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.LKr6KsHYtGSy/rustc_testrunner_tmpdir_reporting.3bKrkGKxt953/mvce.rs:5:27
  |
5 | pub const fn i(_: Wrap) {}
  |                           ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.LKr6KsHYtGSy/rustc_testrunner_tmpdir_reporting.3bKrkGKxt953/mvce.rs`

error: the constant `N` is not of type `usize`
 --> /tmp/icemaker_global_tempdir.LKr6KsHYtGSy/rustc_testrunner_tmpdir_reporting.3bKrkGKxt953/mvce.rs:1:32
  |
1 | pub struct Blorb<const N: u16>([String; N]);
  |                                ^^^^^^^^^^^ expected `usize`, found `u16`

error: internal compiler error: compiler/rustc_middle/src/ty/consts/int.rs:263:13: expected int of size 8, but got size 2

thread 'rustc' panicked at compiler/rustc_middle/src/ty/consts/int.rs:263:13:
Box<dyn Any>
stack backtrace:
   0:     0x7047d26daeda - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::had0a4a07d444c243
   1:     0x7047d2e033e6 - core::fmt::write::hfa03780471fd40a1
   2:     0x7047d3fbd491 - std::io::Write::write_fmt::he88bb98b829c33b1
   3:     0x7047d26dad32 - std::sys::backtrace::BacktraceLock::print::h1e8153a6bf47e7a5
   4:     0x7047d26dd251 - std::panicking::default_hook::{{closure}}::h2d7a6dde612f1b16
   5:     0x7047d26dd084 - std::panicking::default_hook::ha6ce9de3458bcdda
   6:     0x7047d17a486f - std[c1d7bd3f58de7430]::panicking::update_hook::<alloc[29d5ad3c4a91d383]::boxed::Box<rustc_driver_impl[b3d9015aed309aa5]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x7047d26dd968 - std::panicking::rust_panic_with_hook::haf1d2e00d64b82f1
   8:     0x7047d17de321 - std[c1d7bd3f58de7430]::panicking::begin_panic::<rustc_errors[a2cc27f529684419]::ExplicitBug>::{closure#0}
   9:     0x7047d17d13c6 - std[c1d7bd3f58de7430]::sys::backtrace::__rust_end_short_backtrace::<std[c1d7bd3f58de7430]::panicking::begin_panic<rustc_errors[a2cc27f529684419]::ExplicitBug>::{closure#0}, !>
  10:     0x7047d17ccad9 - std[c1d7bd3f58de7430]::panicking::begin_panic::<rustc_errors[a2cc27f529684419]::ExplicitBug>
  11:     0x7047d17e7bb1 - <rustc_errors[a2cc27f529684419]::diagnostic::BugAbort as rustc_errors[a2cc27f529684419]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7047d1e0ba54 - rustc_middle[99056c3c142edfd1]::util::bug::opt_span_bug_fmt::<rustc_span[fbdd09955dfcae25]::span_encoding::Span>::{closure#0}
  13:     0x7047d1df17ca - rustc_middle[99056c3c142edfd1]::ty::context::tls::with_opt::<rustc_middle[99056c3c142edfd1]::util::bug::opt_span_bug_fmt<rustc_span[fbdd09955dfcae25]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7047d1df165b - rustc_middle[99056c3c142edfd1]::ty::context::tls::with_context_opt::<rustc_middle[99056c3c142edfd1]::ty::context::tls::with_opt<rustc_middle[99056c3c142edfd1]::util::bug::opt_span_bug_fmt<rustc_span[fbdd09955dfcae25]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7047cf3cce60 - rustc_middle[99056c3c142edfd1]::util::bug::bug_fmt
  16:     0x7047cf94826a - rustc_middle[99056c3c142edfd1]::ty::util::needs_drop_components_with_async
  17:     0x7047d31ebeb7 - rustc_ty_utils[7eb78ab09d37383f]::needs_drop::needs_drop_raw
  18:     0x7047d31eba8f - rustc_query_impl[a128c9efc091a24e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a128c9efc091a24e]::query_impl::needs_drop_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 1usize]>>
  19:     0x7047d31eaebf - rustc_query_system[a5b010e784c9cc4f]::query::plumbing::try_execute_query::<rustc_query_impl[a128c9efc091a24e]::DynamicConfig<rustc_query_system[a5b010e784c9cc4f]::query::caches::DefaultCache<rustc_middle[99056c3c142edfd1]::ty::ParamEnvAnd<rustc_middle[99056c3c142edfd1]::ty::Ty>, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a128c9efc091a24e]::plumbing::QueryCtxt, false>
  20:     0x7047d31eab0e - rustc_query_impl[a128c9efc091a24e]::query_impl::needs_drop_raw::get_query_non_incr::__rust_end_short_backtrace
  21:     0x7047d37a04a2 - rustc_mir_build[624742ab29f03d50]::build::mir_build
  22:     0x7047d2e04f06 - rustc_mir_transform[72b720a2bb6a9bbb]::mir_built
  23:     0x7047d2e04ec9 - rustc_query_impl[a128c9efc091a24e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a128c9efc091a24e]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 8usize]>>
  24:     0x7047d31a94ba - rustc_query_system[a5b010e784c9cc4f]::query::plumbing::try_execute_query::<rustc_query_impl[a128c9efc091a24e]::DynamicConfig<rustc_query_system[a5b010e784c9cc4f]::query::caches::VecCache<rustc_span[fbdd09955dfcae25]::def_id::LocalDefId, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a128c9efc091a24e]::plumbing::QueryCtxt, false>
  25:     0x7047d31a8fcd - rustc_query_impl[a128c9efc091a24e]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7047cf4dc4e3 - rustc_mir_build[624742ab29f03d50]::check_unsafety::check_unsafety
  27:     0x7047d3633fe7 - rustc_query_impl[a128c9efc091a24e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a128c9efc091a24e]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 0usize]>>
  28:     0x7047d3634298 - rustc_query_system[a5b010e784c9cc4f]::query::plumbing::try_execute_query::<rustc_query_impl[a128c9efc091a24e]::DynamicConfig<rustc_query_system[a5b010e784c9cc4f]::query::caches::VecCache<rustc_span[fbdd09955dfcae25]::def_id::LocalDefId, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[a128c9efc091a24e]::plumbing::QueryCtxt, false>
  29:     0x7047d3633f17 - rustc_query_impl[a128c9efc091a24e]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7047d31a2d47 - rustc_interface[89dec4b9d675c708]::passes::run_required_analyses
  31:     0x7047d3b0f51e - rustc_interface[89dec4b9d675c708]::passes::analysis
  32:     0x7047d3b0f4f1 - rustc_query_impl[a128c9efc091a24e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a128c9efc091a24e]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 1usize]>>
  33:     0x7047d3c9252e - rustc_query_system[a5b010e784c9cc4f]::query::plumbing::try_execute_query::<rustc_query_impl[a128c9efc091a24e]::DynamicConfig<rustc_query_system[a5b010e784c9cc4f]::query::caches::SingleCache<rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a128c9efc091a24e]::plumbing::QueryCtxt, false>
  34:     0x7047d3c9220f - rustc_query_impl[a128c9efc091a24e]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7047d3b1f55e - rustc_interface[89dec4b9d675c708]::interface::run_compiler::<core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>, rustc_driver_impl[b3d9015aed309aa5]::run_compiler::{closure#0}>::{closure#1}
  36:     0x7047d3bea350 - std[c1d7bd3f58de7430]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[89dec4b9d675c708]::util::run_in_thread_with_globals<rustc_interface[89dec4b9d675c708]::util::run_in_thread_pool_with_globals<rustc_interface[89dec4b9d675c708]::interface::run_compiler<core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>, rustc_driver_impl[b3d9015aed309aa5]::run_compiler::{closure#0}>::{closure#1}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>::{closure#0}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>
  37:     0x7047d3bea9ba - <<std[c1d7bd3f58de7430]::thread::Builder>::spawn_unchecked_<rustc_interface[89dec4b9d675c708]::util::run_in_thread_with_globals<rustc_interface[89dec4b9d675c708]::util::run_in_thread_pool_with_globals<rustc_interface[89dec4b9d675c708]::interface::run_compiler<core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>, rustc_driver_impl[b3d9015aed309aa5]::run_compiler::{closure#0}>::{closure#1}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>::{closure#0}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>::{closure#1} as core[d0cd706d8d014919]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7047d3beadab - std::sys::pal::unix::thread::Thread::new::thread_start::h6a16a471557e53ce
  39:     0x7047d533639d - <unknown>
  40:     0x7047d53bb49c - <unknown>
  41:                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 (c4f717650 2024-10-01) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [needs_drop_raw] computing whether `Wrap` needs drop
#1 [mir_built] building MIR for `i`
end of query stack
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0601`.

@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 Oct 1, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 1, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 4, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Oct 12, 2024
@bors bors closed this as completed in 6a66a27 Jan 31, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 31, 2025
Rollup merge of rust-lang#136180 - lukas-code:typed-valtree, r=oli-obk

Introduce a wrapper for "typed valtrees" and properly check the type before extracting the value

This PR adds a new wrapper type `ty::Value` to replace the tuple `(Ty, ty::ValTree)` and become the new canonical representation of type-level constant values.

The value extraction methods `try_to_bits`/`try_to_bool`/`try_to_target_usize` are moved to this new type. For `try_to_bits` in particular, this avoids some redundant matches on `ty::ConstKind::Value`. Furthermore, these methods and will now properly check the type before extracting the value, which fixes some ICEs.

The name `ty::Value` was chosen to be consistent with `ty::Expr`.

Commit 1 should be non-functional and commit 2 adds the type check.

---

fixes rust-lang#131102
supercedes rust-lang#136130

r? `@oli-obk`
cc `@FedericoBruzzone` `@BoxyUwU`
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Jan 31, 2025
Introduce a wrapper for "typed valtrees" and properly check the type before extracting the value

This PR adds a new wrapper type `ty::Value` to replace the tuple `(Ty, ty::ValTree)` and become the new canonical representation of type-level constant values.

The value extraction methods `try_to_bits`/`try_to_bool`/`try_to_target_usize` are moved to this new type. For `try_to_bits` in particular, this avoids some redundant matches on `ty::ConstKind::Value`. Furthermore, these methods and will now properly check the type before extracting the value, which fixes some ICEs.

The name `ty::Value` was chosen to be consistent with `ty::Expr`.

Commit 1 should be non-functional and commit 2 adds the type check.

---

fixes rust-lang/rust#131102
supercedes rust-lang/rust#136130

r? `@oli-obk`
cc `@FedericoBruzzone` `@BoxyUwU`
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) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
3 participants