Skip to content

[ICE]: expected branch, got Leaf #162392

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(macroless_generic_const_args)]
#![feature(generic_const_args)]
const TUPLE: (&'static str, &'static str) = ("a", true);
fn main() {
    TUPLE;
}

original:

#![feature(macroless_generic_const_args)]
#![feature(generic_const_args, min_generic_const_args)]
const TUPLE: (&'static str, &'static str) = ("a", true);
fn main() {
    TUPLE;
}

Version information

rustc 1.100.0-nightly (da47efd27 2026-09-06)
binary: rustc
commit-hash: da47efd27287edb02eed0b5a178a165c8f258e37
commit-date: 2026-09-06
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.1

Possibly related line of code:

/// Converts to a `ValTreeKind::Branch` value, `panic`'ing
/// if this valtree is some other kind.
#[inline]
pub fn to_branch(&self) -> I::Consts {
match self {
ValTreeKind::Branch(branch) => *branch,
ValTreeKind::Leaf(..) => panic!("expected branch, got {:?}", self),
}
}
/// Attempts to convert to a `ValTreeKind::Leaf` value.
pub fn try_to_leaf(&self) -> Option<I::ScalarInt> {
match self {

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

Program output

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

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

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.BxFyzlIakPYN/rustc_testrunner_tmpdir_reporting.ZoQ9TkLdcYq6/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_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.BxFyzlIakPYN/rustc_testrunner_tmpdir_reporting.ZoQ9TkLdcYq6/mvce.rs:2:12
  |
2 | #![feature(generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #151972 <https://github.com/rust-lang/rust/issues/151972> for more information

error[E0658]: use of unstable library feature `unsized_const_params`
 --> /tmp/icemaker_global_tempdir.BxFyzlIakPYN/rustc_testrunner_tmpdir_reporting.ZoQ9TkLdcYq6/mvce.rs:3:1
  |
3 | const TUPLE: (&'static str, &'static str) = ("a", true);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: add `#![feature(unsized_const_params)]` to the crate attributes to enable
  = note: this compiler was built on 2026-09-06; consider upgrading it if it is out of date
  = note: required for `str` to implement `ConstParamTy_`
  = note: 2 redundant requirements hidden
  = note: required for `(&'static str, &'static str)` to implement `ConstParamTy_`


thread 'rustc' (2696937) panicked at /rustc-dev/da47efd27287edb02eed0b5a178a165c8f258e37/compiler/rustc_type_ir/src/const_kind.rs:279:38:
expected branch, got Leaf(0x01)
stack backtrace:
   0:     0x7fc310cbde86 - <<std[7b8d936ff0591b4d]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[1338a38dbbf8640b]::fmt::Display>::fmt
   1:     0x7fc31140829d - core[1338a38dbbf8640b]::fmt::write
   2:     0x7fc310cd2f5c - <std[7b8d936ff0591b4d]::sys::stdio::unix::Stderr as core[1338a38dbbf8640b]::io::write::Write>::write_fmt
   3:     0x7fc310c9072a - std[7b8d936ff0591b4d]::panicking::default_hook::{closure#0}
   4:     0x7fc310cb2183 - std[7b8d936ff0591b4d]::panicking::default_hook
   5:     0x7fc30fbfc55f - std[7b8d936ff0591b4d]::panicking::update_hook::<alloc[c8046bf86c4c1cc9]::boxed::Box<rustc_driver_impl[542a485098bab399]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fc310cb2622 - std[7b8d936ff0591b4d]::panicking::panic_with_hook
   7:     0x7fc310c907e2 - std[7b8d936ff0591b4d]::panicking::panic_handler::{closure#0}
   8:     0x7fc310c87659 - std[7b8d936ff0591b4d]::sys::backtrace::__rust_end_short_backtrace::<std[7b8d936ff0591b4d]::panicking::panic_handler::{closure#0}, !>
   9:     0x7fc310c923bd - __rustc[e24c0e0bed34fbce]::rust_begin_unwind
  10:     0x7fc30d9a3e8c - core[1338a38dbbf8640b]::panicking::panic_fmt
  11:     0x7fc311adfb1c - rustc_const_eval[74340a00061fdc10]::const_eval::valtrees::create_valtree_place
  12:     0x7fc311ad4ecd - rustc_const_eval[74340a00061fdc10]::const_eval::valtrees::valtree_to_ref
  13:     0x7fc311ad55af - rustc_const_eval[74340a00061fdc10]::const_eval::valtrees::valtree_into_mplace
  14:     0x7fc311ad534a - rustc_const_eval[74340a00061fdc10]::const_eval::valtrees::valtree_into_mplace
  15:     0x7fc30e49276b - rustc_const_eval[74340a00061fdc10]::const_eval::valtrees::valtree_to_const_value
  16:     0x7fc312757aeb - <rustc_const_eval[74340a00061fdc10]::provide::{closure#1} as core[1338a38dbbf8640b]::ops::function::FnOnce<(rustc_middle[3307db12b2d0bcfe]::ty::context::TyCtxt, rustc_middle[3307db12b2d0bcfe]::ty::consts::valtree::Value)>>::call_once
  17:     0x7fc312757a9c - rustc_query_impl[a795fc8e0dec0451]::query_vtables::valtree_to_const_val::invoke_provider_fn::__rust_begin_short_backtrace
  18:     0x7fc312757314 - rustc_query_impl[a795fc8e0dec0451]::execution::try_execute_query::<rustc_middle[3307db12b2d0bcfe]::query::caches::DefaultCache<rustc_middle[3307db12b2d0bcfe]::ty::consts::valtree::Value, rustc_middle[3307db12b2d0bcfe]::query::erase::ErasedData<[u8; 24usize]>>, false>
  19:     0x7fc31275703e - rustc_query_impl[a795fc8e0dec0451]::query_vtables::valtree_to_const_val::execute_query_non_incr::__rust_end_short_backtrace
  20:     0x7fc31202132c - <rustc_mir_transform[5ffca57c3928c519]::known_panics_lint::ConstPropagator as rustc_middle[3307db12b2d0bcfe]::mir::visit::Visitor>::visit_assign
  21:     0x7fc312019a8e - <rustc_mir_transform[5ffca57c3928c519]::known_panics_lint::ConstPropagator as rustc_middle[3307db12b2d0bcfe]::mir::visit::Visitor>::visit_body
  22:     0x7fc312014a6a - <rustc_mir_transform[5ffca57c3928c519]::known_panics_lint::KnownPanicsLint as rustc_mir_transform[5ffca57c3928c519]::pass_manager::MirLint>::run_lint
  23:     0x7fc3114185ba - rustc_mir_transform[5ffca57c3928c519]::run_analysis_to_runtime_passes
  24:     0x7fc311db4089 - rustc_mir_transform[5ffca57c3928c519]::mir_drops_elaborated_and_const_checked
  25:     0x7fc311bc7b35 - rustc_query_impl[a795fc8e0dec0451]::execution::try_execute_query::<rustc_data_structures[a20bf6f691e5a6d4]::vec_cache::VecCache<rustc_span[be290dbee5d4923]::def_id::LocalDefId, rustc_middle[3307db12b2d0bcfe]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[3307db12b2d0bcfe]::dep_graph::graph::DepNodeIndex>, false>
  26:     0x7fc311bc7667 - rustc_query_impl[a795fc8e0dec0451]::query_vtables::mir_drops_elaborated_and_const_checked::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7fc311bca516 - <rustc_middle[3307db12b2d0bcfe]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[55d539fc721ed361]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  28:     0x7fc311bc964e - rustc_interface[55d539fc721ed361]::passes::analysis
  29:     0x7fc31263084a - rustc_query_impl[a795fc8e0dec0451]::execution::try_execute_query::<rustc_middle[3307db12b2d0bcfe]::query::caches::SingleCache<rustc_middle[3307db12b2d0bcfe]::query::erase::ErasedData<[u8; 0usize]>>, false>
  30:     0x7fc31263062b - rustc_query_impl[a795fc8e0dec0451]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
  31:     0x7fc31271f78c - rustc_interface[55d539fc721ed361]::interface::run_compiler::<(), rustc_driver_impl[542a485098bab399]::run_compiler::{closure#0}>::{closure#2}
  32:     0x7fc31282f564 - std[7b8d936ff0591b4d]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[55d539fc721ed361]::util::run_in_thread_with_globals<rustc_interface[55d539fc721ed361]::util::run_in_thread_pool_with_globals<rustc_interface[55d539fc721ed361]::interface::run_compiler<(), rustc_driver_impl[542a485098bab399]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  33:     0x7fc31282f30b - <std[7b8d936ff0591b4d]::thread::lifecycle::spawn_unchecked<rustc_interface[55d539fc721ed361]::util::run_in_thread_with_globals<rustc_interface[55d539fc721ed361]::util::run_in_thread_pool_with_globals<rustc_interface[55d539fc721ed361]::interface::run_compiler<(), rustc_driver_impl[542a485098bab399]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[1338a38dbbf8640b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x7fc31282cd47 - <std[7b8d936ff0591b4d]::sys::thread::unix::Thread>::new::thread_start
  35:     0x7fc30b8980a2 - <unknown>
  36:     0x7fc30b92080c - <unknown>
  37:                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 (da47efd27 2026-09-06) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [valtree_to_const_val] converting type-level constant value to MIR constant value
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `main`
#2 [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 E0658`.

@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

    C-bugCategory: This is a bug.F-generic_const_args`#![feature(generic_const_args)]`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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions