Skip to content

[ICE]: expected int of size 1, but got size 8 #152683

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(min_generic_const_args)]
#![feature(generic_const_parameter_types)]
fn foo<const N: usize, const A: [u8; N]>() {}

fn bar() {
    foo::<_, { [3, 5, 8u64] }>();
}

original:

#![feature(const_generics)]

fn foo<const N: usize, const A: [u8; N]>() {}

fn bar() {
    foo::<_, { [3, 5, 8u64] }>();
}

Version information

rustc 1.95.0-nightly (873b4beb0 2026-02-15)
binary: rustc
commit-hash: 873b4beb0cc726493b94c8ef21f68795c04fbbc1
commit-date: 2026-02-15
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0

Possibly related line of code:

}
}
#[inline]
pub fn to_bits(self, target_size: Size) -> u128 {
self.try_to_bits(target_size).unwrap_or_else(|size| {
bug!("expected int of size {}, but got size {}", target_size.bytes(), size.bytes())
})
}
/// Extracts the bits from the scalar without checking the size.
#[inline]
pub fn to_bits_unchecked(self) -> u128 {

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(min_generic_const_args) -Zcrate-attr=feature(generic_const_parameter_types)

Program output

warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:12
  |
1 | #![feature(min_generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: the feature `generic_const_parameter_types` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:12
  |
1 | #![feature(generic_const_parameter_types)]
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #137626 <https://github.com/rust-lang/rust/issues/137626> for more information

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.rmw1TKwC6TYJ/rustc_testrunner_tmpdir_reporting.UJ6V59fDFPuL/mvce.rs:5:2
  |
5 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.rmw1TKwC6TYJ/rustc_testrunner_tmpdir_reporting.UJ6V59fDFPuL/mvce.rs`

error: `[u8; N]` is forbidden as the type of a const generic parameter
 --> /tmp/icemaker_global_tempdir.rmw1TKwC6TYJ/rustc_testrunner_tmpdir_reporting.UJ6V59fDFPuL/mvce.rs:1:33
  |
1 | fn foo<const N: usize, const A: [u8; N]>() {}
  |                                 ^^^^^^^
  |
  = note: the only supported types are integers, `bool`, and `char`
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
  |
1 + #![feature(adt_const_params)]
  |

error: internal compiler error: /rustc-dev/873b4beb0cc726493b94c8ef21f68795c04fbbc1/compiler/rustc_middle/src/ty/consts/int.rs:285:13: expected int of size 1, but got size 8


thread 'rustc' (639673) panicked at /rustc-dev/873b4beb0cc726493b94c8ef21f68795c04fbbc1/compiler/rustc_middle/src/ty/consts/int.rs:285:13:
Box<dyn Any>
stack backtrace:
   0:     0x7fc3fd7d449b - <<std[e84040df3bd3b365]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[6c6f0f72ed298c38]::fmt::Display>::fmt
   1:     0x7fc3fde110e0 - core[6c6f0f72ed298c38]::fmt::write
   2:     0x7fc3fd7eb716 - <std[e84040df3bd3b365]::sys::stdio::unix::Stderr as std[e84040df3bd3b365]::io::Write>::write_fmt
   3:     0x7fc3fd7aa548 - std[e84040df3bd3b365]::panicking::default_hook::{closure#0}
   4:     0x7fc3fd7c7903 - std[e84040df3bd3b365]::panicking::default_hook
   5:     0x7fc3fc790f8f - std[e84040df3bd3b365]::panicking::update_hook::<alloc[d9717d1773e7bcdb]::boxed::Box<rustc_driver_impl[1d3373f79f63c38d]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fc3fd7c7be2 - std[e84040df3bd3b365]::panicking::panic_with_hook
   7:     0x7fc3fc7c4ef1 - std[e84040df3bd3b365]::panicking::begin_panic::<rustc_errors[aa9f523260d7f0cb]::ExplicitBug>::{closure#0}
   8:     0x7fc3fc7bdda6 - std[e84040df3bd3b365]::sys::backtrace::__rust_end_short_backtrace::<std[e84040df3bd3b365]::panicking::begin_panic<rustc_errors[aa9f523260d7f0cb]::ExplicitBug>::{closure#0}, !>
   9:     0x7fc3fc7bdb0b - std[e84040df3bd3b365]::panicking::begin_panic::<rustc_errors[aa9f523260d7f0cb]::ExplicitBug>
  10:     0x7fc3fc7d0481 - <rustc_errors[aa9f523260d7f0cb]::diagnostic::BugAbort as rustc_errors[aa9f523260d7f0cb]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7fc3fcd9c439 - rustc_middle[11be9ef6dd95cb79]::util::bug::opt_span_bug_fmt::<rustc_span[8943e0009ed5ffe4]::span_encoding::Span>::{closure#0}
  12:     0x7fc3fcd9c5c2 - rustc_middle[11be9ef6dd95cb79]::ty::context::tls::with_opt::<rustc_middle[11be9ef6dd95cb79]::util::bug::opt_span_bug_fmt<rustc_span[8943e0009ed5ffe4]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7fc3fcd8d41b - rustc_middle[11be9ef6dd95cb79]::ty::context::tls::with_context_opt::<rustc_middle[11be9ef6dd95cb79]::ty::context::tls::with_opt<rustc_middle[11be9ef6dd95cb79]::util::bug::opt_span_bug_fmt<rustc_span[8943e0009ed5ffe4]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7fc3fa35fd94 - rustc_middle[11be9ef6dd95cb79]::util::bug::bug_fmt
  15:     0x7fc3fcddbf5d - <core[6c6f0f72ed298c38]::iter::adapters::GenericShunt<core[6c6f0f72ed298c38]::iter::adapters::map::Map<core[6c6f0f72ed298c38]::slice::iter::Iter<rustc_middle[11be9ef6dd95cb79]::ty::consts::Const>, <rustc_middle[11be9ef6dd95cb79]::ty::consts::valtree::Value>::try_to_raw_bytes::{closure#0}>, core[6c6f0f72ed298c38]::option::Option<core[6c6f0f72ed298c38]::convert::Infallible>> as core[6c6f0f72ed298c38]::iter::traits::iterator::Iterator>::next
  16:     0x7fc3fcdacf57 - <rustc_middle[11be9ef6dd95cb79]::ty::consts::valtree::Value>::try_to_raw_bytes
  17:     0x7fc3fce2c7ce - <rustc_middle[11be9ef6dd95cb79]::ty::print::pretty::FmtPrinter as rustc_middle[11be9ef6dd95cb79]::ty::print::pretty::PrettyPrinter>::pretty_print_const_valtree
  18:     0x7fc3fc97578f - <rustc_middle[11be9ef6dd95cb79]::ty::generic_args::GenericArg as rustc_middle[11be9ef6dd95cb79]::ty::print::Print<rustc_middle[11be9ef6dd95cb79]::ty::print::pretty::FmtPrinter>>::print
  19:     0x7fc3fd5d3a7a - <rustc_trait_selection[df9ef241cd28f90b]::error_reporting::TypeErrCtxt>::emit_inference_failure_err
  20:     0x7fc3fd5ac651 - <rustc_trait_selection[df9ef241cd28f90b]::error_reporting::TypeErrCtxt>::maybe_report_ambiguity
  21:     0x7fc3fc07ec0f - <rustc_trait_selection[df9ef241cd28f90b]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
  22:     0x7fc3feb87bed - rustc_hir_typeck[2234c10747a7efa7]::typeck_with_inspect::{closure#0}
  23:     0x7fc3feb7d2f2 - rustc_query_impl[761ff2116f6b567]::query_impl::typeck::invoke_provider_fn::__rust_begin_short_backtrace
  24:     0x7fc3fe8450fe - rustc_query_impl[761ff2116f6b567]::execution::try_execute_query::<rustc_data_structures[be2354717932db16]::vec_cache::VecCache<rustc_span[8943e0009ed5ffe4]::def_id::LocalDefId, rustc_middle[11be9ef6dd95cb79]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[11be9ef6dd95cb79]::dep_graph::graph::DepNodeIndex>, {rustc_query_impl[761ff2116f6b567]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}, false>
  25:     0x7fc3fe844cc9 - rustc_query_impl[761ff2116f6b567]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7fc3fe83e608 - <rustc_middle[11be9ef6dd95cb79]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[21cab81ddb5349c4]::check_crate::{closure#2}>::{closure#0}
  27:     0x7fc3fe83e02e - rustc_hir_analysis[21cab81ddb5349c4]::check_crate
  28:     0x7fc3fe841c96 - rustc_interface[ffa26b8aee337d6b]::passes::analysis
  29:     0x7fc3ff069a19 - rustc_query_impl[761ff2116f6b567]::execution::try_execute_query::<rustc_middle[11be9ef6dd95cb79]::query::caches::SingleCache<rustc_middle[11be9ef6dd95cb79]::query::erase::ErasedData<[u8; 0usize]>>, {rustc_query_impl[761ff2116f6b567]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}, false>
  30:     0x7fc3ff069754 - rustc_query_impl[761ff2116f6b567]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7fc3ff13a667 - <rustc_interface[ffa26b8aee337d6b]::passes::create_and_enter_global_ctxt<core[6c6f0f72ed298c38]::option::Option<rustc_interface[ffa26b8aee337d6b]::queries::Linker>, rustc_driver_impl[1d3373f79f63c38d]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[6c6f0f72ed298c38]::ops::function::FnOnce<(&rustc_session[e077b3088d2cab4d]::session::Session, rustc_middle[11be9ef6dd95cb79]::ty::context::CurrentGcx, alloc[d9717d1773e7bcdb]::sync::Arc<rustc_data_structures[be2354717932db16]::jobserver::Proxy>, &std[e84040df3bd3b365]::sync::once_lock::OnceLock<rustc_middle[11be9ef6dd95cb79]::ty::context::GlobalCtxt>, &rustc_data_structures[be2354717932db16]::sync::worker_local::WorkerLocal<rustc_middle[11be9ef6dd95cb79]::arena::Arena>, &rustc_data_structures[be2354717932db16]::sync::worker_local::WorkerLocal<rustc_hir[e6f1d3e8b67d381c]::Arena>, rustc_driver_impl[1d3373f79f63c38d]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  32:     0x7fc3ff047ad0 - rustc_interface[ffa26b8aee337d6b]::interface::run_compiler::<(), rustc_driver_impl[1d3373f79f63c38d]::run_compiler::{closure#0}>::{closure#1}
  33:     0x7fc3ff0307be - std[e84040df3bd3b365]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[ffa26b8aee337d6b]::util::run_in_thread_with_globals<rustc_interface[ffa26b8aee337d6b]::util::run_in_thread_pool_with_globals<rustc_interface[ffa26b8aee337d6b]::interface::run_compiler<(), rustc_driver_impl[1d3373f79f63c38d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  34:     0x7fc3ff030ea0 - <std[e84040df3bd3b365]::thread::lifecycle::spawn_unchecked<rustc_interface[ffa26b8aee337d6b]::util::run_in_thread_with_globals<rustc_interface[ffa26b8aee337d6b]::util::run_in_thread_pool_with_globals<rustc_interface[ffa26b8aee337d6b]::interface::run_compiler<(), rustc_driver_impl[1d3373f79f63c38d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[6c6f0f72ed298c38]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7fc3ff031d2c - <std[e84040df3bd3b365]::sys::thread::unix::Thread>::new::thread_start
  36:     0x7fc3f8aa598b - <unknown>
  37:     0x7fc3f8b29a0c - <unknown>
  38:                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.95.0-nightly (873b4beb0 2026-02-15) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(min_generic_const_args) -Z crate-attr=feature(generic_const_parameter_types) -Z dump-mir-dir=dir

query stack during panic:
#0 [typeck] type-checking `bar`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 3 previous errors; 2 warnings emitted

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

@rustbot label +F-const_generics +F-min_generic_const_args +F-generic_const_parameter_types

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-adt_const_params`#![feature(adt_const_params)]`F-generic_const_parameter_types`#![feature(generic_const_parameter_types)]`F-min_generic_const_args`#![feature(min_generic_const_args)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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