Skip to content

[ICE]: shouldn't have created a ValTree for pattern_type!(u32 is 0..=999999999) #162336

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: --edition=2024
#![feature(generic_const_args)]
use core::time::Duration;
const TOO_LARGE_FACTOR: f64 = Duration::MAX.as_nanos() as f64;

original:

#![feature(generic_const_args, min_generic_const_args)]
use core::time::Duration;
const TOO_LARGE_FACTOR: f64 = Duration::MAX.as_nanos() as f64;
fn main() {}

Version information

rustc 1.100.0-nightly (0f819a160 2026-09-05)
binary: rustc
commit-hash: 0f819a1602c3814642aa63799b43772b7bb456e8
commit-date: 2026-09-05
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.1

Possibly related line of code:

ecx.write_discriminant(variant_idx, place).unwrap();
}
debug!("dump of place after writing discriminant:");
dump_place(ecx, place);
}
_ => bug!("shouldn't have created a ValTree for {:?}", ty),
}
}
fn dump_place<'tcx>(ecx: &CompileTimeInterpCx<'tcx>, place: &MPlaceTy<'tcx>) {
trace!("{:?}", ecx.dump_place(&PlaceTy::from(place.clone())));
}

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2024

Program output

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

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

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.qlZXSZnOsYFO/rustc_testrunner_tmpdir_reporting.7Ot4pTl3LGuS/mvce.rs:3:63
  |
3 | const TOO_LARGE_FACTOR: f64 = Duration::MAX.as_nanos() as f64;
  |                                                               ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.qlZXSZnOsYFO/rustc_testrunner_tmpdir_reporting.7Ot4pTl3LGuS/mvce.rs`

error: internal compiler error: /rustc-dev/0f819a1602c3814642aa63799b43772b7bb456e8/compiler/rustc_const_eval/src/const_eval/valtrees.rs:479:14: shouldn't have created a ValTree for pattern_type!(u32 is 0..=999999999)


thread 'rustc' (820812) panicked at /rustc-dev/0f819a1602c3814642aa63799b43772b7bb456e8/compiler/rustc_const_eval/src/const_eval/valtrees.rs:479:14:
Box<dyn Any>
stack backtrace:
   0:     0x7f0c06cc54e6 - <<std[739b682464b2cb4f]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[d997ca8b291862e0]::fmt::Display>::fmt
   1:     0x7f0c0740ba4f - core[d997ca8b291862e0]::fmt::write
   2:     0x7f0c06cda5cc - <std[739b682464b2cb4f]::sys::stdio::unix::Stderr as core[d997ca8b291862e0]::io::write::Write>::write_fmt
   3:     0x7f0c06c97d8a - std[739b682464b2cb4f]::panicking::default_hook::{closure#0}
   4:     0x7f0c06cb97e3 - std[739b682464b2cb4f]::panicking::default_hook
   5:     0x7f0c05c0943f - std[739b682464b2cb4f]::panicking::update_hook::<alloc[cfd194cf86e92e23]::boxed::Box<rustc_driver_impl[4b133f65db23c9ab]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f0c06cb9c82 - std[739b682464b2cb4f]::panicking::panic_with_hook
   7:     0x7f0c05c37ca4 - std[739b682464b2cb4f]::panicking::begin_panic::<rustc_errors[d96522ad5d42be40]::ExplicitBug>::{closure#0}
   8:     0x7f0c05c3077e - std[739b682464b2cb4f]::sys::backtrace::__rust_end_short_backtrace::<std[739b682464b2cb4f]::panicking::begin_panic<rustc_errors[d96522ad5d42be40]::ExplicitBug>::{closure#0}, !>
   9:     0x7f0c05c2e81e - std[739b682464b2cb4f]::panicking::begin_panic::<rustc_errors[d96522ad5d42be40]::ExplicitBug>
  10:     0x7f0c05c43571 - <rustc_errors[d96522ad5d42be40]::diagnostic::BugAbort as rustc_errors[d96522ad5d42be40]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f0c061e6659 - rustc_middle[d333a51e0864de4]::util::bug::opt_span_bug_fmt::<rustc_span[e9d5129d271bd047]::span_encoding::Span>::{closure#0}
  12:     0x7f0c061e6a52 - rustc_middle[d333a51e0864de4]::ty::context::tls::with_opt::<rustc_middle[d333a51e0864de4]::util::bug::opt_span_bug_fmt<rustc_span[e9d5129d271bd047]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7f0c061d17b0 - rustc_middle[d333a51e0864de4]::ty::context::tls::with_context_opt::<rustc_middle[d333a51e0864de4]::ty::context::tls::with_opt<rustc_middle[d333a51e0864de4]::util::bug::opt_span_bug_fmt<rustc_span[e9d5129d271bd047]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7f0c02ea1fa4 - rustc_middle[d333a51e0864de4]::util::bug::bug_fmt
  15:     0x7f0c07b3ecce - rustc_const_eval[e1978c296a42a7e9]::const_eval::valtrees::valtree_into_mplace
  16:     0x7f0c07b3ea8a - rustc_const_eval[e1978c296a42a7e9]::const_eval::valtrees::valtree_into_mplace
  17:     0x7f0c07b3ea8a - rustc_const_eval[e1978c296a42a7e9]::const_eval::valtrees::valtree_into_mplace
  18:     0x7f0c0466634e - rustc_const_eval[e1978c296a42a7e9]::const_eval::valtrees::valtree_to_const_value
  19:     0x7f0c08009c2b - <rustc_const_eval[e1978c296a42a7e9]::provide::{closure#1} as core[d997ca8b291862e0]::ops::function::FnOnce<(rustc_middle[d333a51e0864de4]::ty::context::TyCtxt, rustc_middle[d333a51e0864de4]::ty::consts::valtree::Value)>>::call_once
  20:     0x7f0c08009bdc - rustc_query_impl[483fff85713b0294]::query_vtables::valtree_to_const_val::invoke_provider_fn::__rust_begin_short_backtrace
  21:     0x7f0c08009454 - rustc_query_impl[483fff85713b0294]::execution::try_execute_query::<rustc_middle[d333a51e0864de4]::query::caches::DefaultCache<rustc_middle[d333a51e0864de4]::ty::consts::valtree::Value, rustc_middle[d333a51e0864de4]::query::erase::ErasedData<[u8; 24usize]>>, false>
  22:     0x7f0c0800917e - rustc_query_impl[483fff85713b0294]::query_vtables::valtree_to_const_val::execute_query_non_incr::__rust_end_short_backtrace
  23:     0x7f0c07bf9c02 - <rustc_middle[d333a51e0864de4]::mir::consts::Const>::eval
  24:     0x7f0c07bf90f1 - <rustc_const_eval[e1978c296a42a7e9]::interpret::eval_context::InterpCx<rustc_const_eval[e1978c296a42a7e9]::const_eval::machine::CompileTimeMachine>>::push_stack_frame_raw
  25:     0x7f0c04b77db0 - rustc_const_eval[e1978c296a42a7e9]::const_eval::eval_queries::eval_to_allocation_raw_provider
  26:     0x7f0c07426196 - rustc_query_impl[483fff85713b0294]::query_vtables::eval_to_allocation_raw::invoke_provider_fn::__rust_begin_short_backtrace
  27:     0x7f0c08374ba6 - rustc_query_impl[483fff85713b0294]::execution::try_execute_query::<rustc_middle[d333a51e0864de4]::query::caches::DefaultCache<rustc_middle[d333a51e0864de4]::ty::PseudoCanonicalInput<rustc_middle[d333a51e0864de4]::mir::interpret::GlobalId>, rustc_middle[d333a51e0864de4]::query::erase::ErasedData<[u8; 24usize]>>, false>
  28:     0x7f0c08374127 - rustc_query_impl[483fff85713b0294]::query_vtables::eval_to_allocation_raw::execute_query_non_incr::__rust_end_short_backtrace
  29:     0x7f0c08370bbd - rustc_const_eval[e1978c296a42a7e9]::const_eval::eval_queries::eval_to_const_value_raw_provider
  30:     0x7f0c08370834 - rustc_query_impl[483fff85713b0294]::query_vtables::eval_to_const_value_raw::invoke_provider_fn::__rust_begin_short_backtrace
  31:     0x7f0c083745d5 - rustc_query_impl[483fff85713b0294]::execution::try_execute_query::<rustc_middle[d333a51e0864de4]::query::caches::DefaultCache<rustc_middle[d333a51e0864de4]::ty::PseudoCanonicalInput<rustc_middle[d333a51e0864de4]::mir::interpret::GlobalId>, rustc_middle[d333a51e0864de4]::query::erase::ErasedData<[u8; 24usize]>>, false>
  32:     0x7f0c0837416d - rustc_query_impl[483fff85713b0294]::query_vtables::eval_to_const_value_raw::execute_query_non_incr::__rust_end_short_backtrace
  33:     0x7f0c083716f2 - rustc_const_eval[e1978c296a42a7e9]::const_eval::eval_queries::eval_to_const_value_raw_provider
  34:     0x7f0c08370834 - rustc_query_impl[483fff85713b0294]::query_vtables::eval_to_const_value_raw::invoke_provider_fn::__rust_begin_short_backtrace
  35:     0x7f0c083745d5 - rustc_query_impl[483fff85713b0294]::execution::try_execute_query::<rustc_middle[d333a51e0864de4]::query::caches::DefaultCache<rustc_middle[d333a51e0864de4]::ty::PseudoCanonicalInput<rustc_middle[d333a51e0864de4]::mir::interpret::GlobalId>, rustc_middle[d333a51e0864de4]::query::erase::ErasedData<[u8; 24usize]>>, false>
  36:     0x7f0c0837416d - rustc_query_impl[483fff85713b0294]::query_vtables::eval_to_const_value_raw::execute_query_non_incr::__rust_end_short_backtrace
  37:     0x7f0c07bb52a5 - <rustc_middle[d333a51e0864de4]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[b601ba688d898738]::check_crate::{closure#1}>::{closure#0}
  38:     0x7f0c07bb3f36 - rustc_hir_analysis[b601ba688d898738]::check_crate
  39:     0x7f0c07ac4a88 - rustc_interface[69481172a0b187c3]::passes::analysis
  40:     0x7f0c085dc9ca - rustc_query_impl[483fff85713b0294]::execution::try_execute_query::<rustc_middle[d333a51e0864de4]::query::caches::SingleCache<rustc_middle[d333a51e0864de4]::query::erase::ErasedData<[u8; 0usize]>>, false>
  41:     0x7f0c085dc753 - rustc_query_impl[483fff85713b0294]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
  42:     0x7f0c0879eae4 - rustc_interface[69481172a0b187c3]::interface::run_compiler::<(), rustc_driver_impl[4b133f65db23c9ab]::run_compiler::{closure#0}>::{closure#2}
  43:     0x7f0c08803164 - std[739b682464b2cb4f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[69481172a0b187c3]::util::run_in_thread_with_globals<rustc_interface[69481172a0b187c3]::util::run_in_thread_pool_with_globals<rustc_interface[69481172a0b187c3]::interface::run_compiler<(), rustc_driver_impl[4b133f65db23c9ab]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  44:     0x7f0c08802f0b - <std[739b682464b2cb4f]::thread::lifecycle::spawn_unchecked<rustc_interface[69481172a0b187c3]::util::run_in_thread_with_globals<rustc_interface[69481172a0b187c3]::util::run_in_thread_pool_with_globals<rustc_interface[69481172a0b187c3]::interface::run_compiler<(), rustc_driver_impl[4b133f65db23c9ab]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[d997ca8b291862e0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7f0c08800947 - <std[739b682464b2cb4f]::sys::thread::unix::Thread>::new::thread_start
  46:     0x7f0c018980a2 - <unknown>
  47:     0x7f0c0192080c - <unknown>
  48:                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.100.0-nightly (0f819a160 2026-09-05) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dump-mir-dir=dir

query stack during panic:
#0 [valtree_to_const_val] converting type-level constant value to MIR constant value
#1 [eval_to_allocation_raw] const-evaluating + checking `TOO_LARGE_FACTOR`
#2 [eval_to_const_value_raw] simplifying constant for the type system `TOO_LARGE_FACTOR`
#3 [eval_to_const_value_raw] simplifying constant for the type system `TOO_LARGE_FACTOR`
#4 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

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

@rustbot label +F-generic_const_args +F-min_generic_const_args

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.F-gca_const_items`#![feature(gca_const_items)]` (previously: `generic_const_args`)F-gca_min_const_items`#![feature(gca_min_const_items)]` (previously: `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.T-typesRelevant to the types 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