rust-lang / rust-lang/rust

[ICE]: `ScalarInt has size 8 but expected 1`

Open
#161,508 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-generic_const_exprs F-min_generic_const_args I-ICE needs-triage T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

#![feature(macroless_generic_const_args)]
#![feature(generic_const_exprs)]

struct Foo<const B: bool>;
fn test<const N: usize>() -> Foo<{ N > 0 }> {
    test::<true>
}

original:

#![feature(macroless_generic_const_args)]
#![feature(generic_const_exprs)]
#![feature(min_generic_const_args)]

struct Foo<const B : bool>;
fn test<const N : usize>() ->Foo<{N > 0}> { test::<true> }
fn main() {}

Version information

rustc 1.100.0-nightly (8536f4de9 2026-08-22)
binary: rustc
commit-hash: 8536f4de90e5e781c06e584f8a88de860adc798b
commit-date: 2026-08-22
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.0

Possibly related line of code:
https://github.com/rust-lang/rust/blob/8536f4de90e5e781c06e584f8a88de860adc798b/compiler/rustc_middle/src/ty/consts/int.rs#L261-L273

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

Program output

error: `macroless_generic_const_args` requires `min_generic_const_args` to be enabled
 --> /tmp/icemaker_global_tempdir.z3xn6cNlkIRr/rustc_testrunner_tmpdir_reporting.8BSwG7Hva398/mvce.rs:1:12
  |
1 | #![feature(macroless_generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: enable all of these features

warning: `feature(generic_const_exprs)` is not supported with the next-generation trait solver
 --> /tmp/icemaker_global_tempdir.z3xn6cNlkIRr/rustc_testrunner_tmpdir_reporting.8BSwG7Hva398/mvce.rs:2:12
  |
2 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: `-Znext-solver=globally` is currently enabled by default for testing
  = note: reverted the setting to `-Znext-solver=coherence` for this crate
  = note: the currently stable trait solver will be used for this crate
  = note: see issues #160895 <https://github.com/rust-lang/rust/issues/160895> for more information

warning: the feature `macroless_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.z3xn6cNlkIRr/rustc_testrunner_tmpdir_reporting.8BSwG7Hva398/mvce.rs:1:12
  |
1 | #![feature(macroless_generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #159006 <https://github.com/rust-lang/rust/issues/159006> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.z3xn6cNlkIRr/rustc_testrunner_tmpdir_reporting.8BSwG7Hva398/mvce.rs:2:12
  |
2 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information

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


thread 'rustc' (3555206) panicked at /rustc-dev/8536f4de90e5e781c06e584f8a88de860adc798b/compiler/rustc_middle/src/ty/consts/int.rs:267:9:
assertion `left == right` failed: ScalarInt has size 8 but expected 1
  left: 1
 right: 8
stack backtrace:
   0:     0x7f33435ef966 - <<std[6a2a162ccd49bd24]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[34df38ed1aeeb409]::fmt::Display>::fmt
   1:     0x7f3343c0b063 - core[34df38ed1aeeb409]::fmt::write
   2:     0x7f3343604e4c - <std[6a2a162ccd49bd24]::sys::stdio::unix::Stderr as core[34df38ed1aeeb409]::io::write::Write>::write_fmt
   3:     0x7f33435c2bea - std[6a2a162ccd49bd24]::panicking::default_hook::{closure#0}
   4:     0x7f33435e3c03 - std[6a2a162ccd49bd24]::panicking::default_hook
   5:     0x7f334259f25a - std[6a2a162ccd49bd24]::panicking::update_hook::<alloc[d780ca98ca945870]::boxed::Box<rustc_driver_impl[914da1ef5f0db717]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f33435e40a2 - std[6a2a162ccd49bd24]::panicking::panic_with_hook
   7:     0x7f33435c2ca2 - std[6a2a162ccd49bd24]::panicking::panic_handler::{closure#0}
   8:     0x7f33435badd9 - std[6a2a162ccd49bd24]::sys::backtrace::__rust_end_short_backtrace::<std[6a2a162ccd49bd24]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f33435c46ad - __rustc[8236491043d97613]::rust_begin_unwind
  10:     0x7f334022f00c - core[34df38ed1aeeb409]::panicking::panic_fmt
  11:     0x7f3341f332b3 - core[34df38ed1aeeb409]::panicking::assert_failed_inner
  12:     0x7f3341f29205 - core[34df38ed1aeeb409]::panicking::assert_failed::<u64, u64>
  13:     0x7f3343cad53a - <rustc_const_eval[972a1eb05da00dbd]::interpret::eval_context::InterpCx<rustc_const_eval[972a1eb05da00dbd]::const_eval::machine::CompileTimeMachine>>::binary_op
  14:     0x7f3341709ff9 - <rustc_const_eval[972a1eb05da00dbd]::interpret::eval_context::InterpCx<rustc_const_eval[972a1eb05da00dbd]::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
  15:     0x7f3341702423 - rustc_const_eval[972a1eb05da00dbd]::const_eval::eval_queries::eval_to_allocation_raw_provider
  16:     0x7f3343c3bcd6 - rustc_query_impl[7883aff223ddbf83]::query_vtables::eval_to_allocation_raw::invoke_provider_fn::__rust_begin_short_backtrace
  17:     0x7f3344c5bdfa - rustc_query_impl[7883aff223ddbf83]::execution::try_execute_query::<rustc_middle[e13af1fab9e07cac]::query::caches::DefaultCache<rustc_middle[e13af1fab9e07cac]::ty::PseudoCanonicalInput<rustc_middle[e13af1fab9e07cac]::mir::interpret::GlobalId>, rustc_middle[e13af1fab9e07cac]::query::erase::ErasedData<[u8; 24usize]>>, false>
  18:     0x7f3344c5b367 - rustc_query_impl[7883aff223ddbf83]::query_vtables::eval_to_allocation_raw::execute_query_non_incr::__rust_end_short_backtrace
  19:     0x7f3340d4d8d6 - rustc_const_eval[972a1eb05da00dbd]::const_eval::valtrees::eval_to_valtree
  20:     0x7f33449a7fe6 - <rustc_const_eval[972a1eb05da00dbd]::provide::{closure#0} as core[34df38ed1aeeb409]::ops::function::FnOnce<(rustc_middle[e13af1fab9e07cac]::ty::context::TyCtxt, rustc_middle[e13af1fab9e07cac]::ty::PseudoCanonicalInput<rustc_middle[e13af1fab9e07cac]::mir::interpret::GlobalId>)>>::call_once
  21:     0x7f33449a7fa2 - rustc_query_impl[7883aff223ddbf83]::query_vtables::eval_to_valtree::invoke_provider_fn::__rust_begin_short_backtrace
  22:     0x7f33449a7676 - rustc_query_impl[7883aff223ddbf83]::execution::try_execute_query::<rustc_middle[e13af1fab9e07cac]::query::caches::DefaultCache<rustc_middle[e13af1fab9e07cac]::ty::PseudoCanonicalInput<rustc_middle[e13af1fab9e07cac]::mir::interpret::GlobalId>, rustc_middle[e13af1fab9e07cac]::query::erase::ErasedData<[u8; 16usize]>>, false>
  23:     0x7f33449a733f - rustc_query_impl[7883aff223ddbf83]::query_vtables::eval_to_valtree::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7f3343d3fef1 - <rustc_middle[e13af1fab9e07cac]::ty::context::TyCtxt>::const_eval_global_id_for_typeck
  25:     0x7f3343d3f9f2 - <rustc_middle[e13af1fab9e07cac]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
  26:     0x7f33433c11d8 - <rustc_trait_selection[c751c4991df8534b]::traits::fulfill::FulfillProcessor as rustc_data_structures[f27dd378dd25622a]::obligation_forest::ObligationProcessor>::process_obligation::{closure#0}
  27:     0x7f3343fffe33 - <rustc_trait_selection[c751c4991df8534b]::traits::fulfill::FulfillProcessor as rustc_data_structures[f27dd378dd25622a]::obligation_forest::ObligationProcessor>::process_obligation
  28:     0x7f3343ff2ba0 - <rustc_data_structures[f27dd378dd25622a]::obligation_forest::ObligationForest<rustc_trait_selection[c751c4991df8534b]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[c751c4991df8534b]::traits::fulfill::FulfillProcessor>
  29:     0x7f3343da76da - <rustc_trait_selection[c751c4991df8534b]::traits::engine::ObligationCtxt>::try_evaluate_obligations
  30:     0x7f3342895680 - <rustc_hir_typeck[794a63979e72c52d]::fn_ctxt::FnCtxt>::may_coerce
  31:     0x7f3342873b0e - <rustc_hir_typeck[794a63979e72c52d]::fn_ctxt::FnCtxt>::suggest_deref_ref_or_into
  32:     0x7f334286886f - <rustc_hir_typeck[794a63979e72c52d]::fn_ctxt::FnCtxt>::emit_type_mismatch_suggestions
  33:     0x7f3342863f1e - <rustc_hir_typeck[794a63979e72c52d]::fn_ctxt::FnCtxt>::emit_coerce_suggestions
  34:     0x7f33445e293e - <rustc_hir_typeck[794a63979e72c52d]::fn_ctxt::FnCtxt>::check_expr_block
  35:     0x7f33445e6692 - <rustc_hir_typeck[794a63979e72c52d]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  36:     0x7f3343d66861 - rustc_hir_typeck[794a63979e72c52d]::check::check_fn
  37:     0x7f33447184d8 - rustc_hir_typeck[794a63979e72c52d]::typeck_with_inspect::{closure#0}
  38:     0x7f3344716a4a - rustc_query_impl[7883aff223ddbf83]::query_vtables::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
  39:     0x7f33446f0f35 - rustc_query_impl[7883aff223ddbf83]::execution::try_execute_query::<rustc_data_structures[f27dd378dd25622a]::vec_cache::VecCache<rustc_span[e5991a1499837571]::def_id::LocalDefId, rustc_middle[e13af1fab9e07cac]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[e13af1fab9e07cac]::dep_graph::graph::DepNodeIndex>, false>
  40:     0x7f33446f0ba7 - rustc_query_impl[7883aff223ddbf83]::query_vtables::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
  41:     0x7f33444b8914 - rustc_hir_analysis[6c6705371eee3cd0]::check_crate
  42:     0x7f33446f243a - rustc_interface[4cb4cba335c0809d]::passes::analysis
  43:     0x7f3344e2ef4a - rustc_query_impl[7883aff223ddbf83]::execution::try_execute_query::<rustc_middle[e13af1fab9e07cac]::query::caches::SingleCache<rustc_middle[e13af1fab9e07cac]::query::erase::ErasedData<[u8; 0usize]>>, false>
  44:     0x7f3344e2ecd3 - rustc_query_impl[7883aff223ddbf83]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
  45:     0x7f3344fafb6b - rustc_interface[4cb4cba335c0809d]::interface::run_compiler::<(), rustc_driver_impl[914da1ef5f0db717]::run_compiler::{closure#0}>::{closure#2}
  46:     0x7f3344fda7e4 - std[6a2a162ccd49bd24]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[4cb4cba335c0809d]::util::run_in_thread_with_globals<rustc_interface[4cb4cba335c0809d]::util::run_in_thread_pool_with_globals<rustc_interface[4cb4cba335c0809d]::interface::run_compiler<(), rustc_driver_impl[914da1ef5f0db717]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  47:     0x7f3344fda5ad - <std[6a2a162ccd49bd24]::thread::lifecycle::spawn_unchecked<rustc_interface[4cb4cba335c0809d]::util::run_in_thread_with_globals<rustc_interface[4cb4cba335c0809d]::util::run_in_thread_pool_with_globals<rustc_interface[4cb4cba335c0809d]::interface::run_compiler<(), rustc_driver_impl[914da1ef5f0db717]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[34df38ed1aeeb409]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  48:     0x7f3344fd82c7 - <std[6a2a162ccd49bd24]::sys::thread::unix::Thread>::new::thread_start
  49:     0x7f333e297739 - <unknown>
  50:     0x7f333e31bedc - <unknown>
  51:                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: please make sure that you have updated to the latest nightly

note: rustc 1.100.0-nightly (8536f4de9 2026-08-22) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `test::{constant#0}`
#1 [eval_to_valtree] evaluating type-level constant
#2 [typeck_root] type-checking `test`
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 2 previous errors; 3 warnings emitted

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

@rustbot label +F-macroless_generic_const_args +F-generic_const_exprs +F-min_generic_const_args

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimized reproducer and run it using the nightly rustc command shown in the issue. Read compiler/rustc_middle/src/ty/consts/int.rs around lines 261-273, then trace the const-evaluation path shown in the backtrace. Done means this input no longer causes the ScalarInt size assertion or an internal compiler error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.