Skip to content

[ICE]: expected ConstKind::Value, got AliasConst / got {const error} #162389

Open

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

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

const C_INNER: (*const u8, u8) = (C, 0);
fn foo2(x: *const u8) {
    match (x, 1) {
        C_INNER => {}
    };
}

original:

#![feature(macroless_generic_const_args)]
#![feature(generic_const_args, min_generic_const_args)]

const C: *const u8 = &0;
const C_INNER: (*const u8, u8) = (C, 0);
fn foo2(x: *const u8) {
    match (x, 1) {
        C_INNER => {}
    };
}

fn main() {}

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:

}
/// Panics if `self.kind != ty::ConstKind::Value`.
pub fn to_value(self) -> ty::Value<'tcx> {
match self.kind() {
ty::ConstKind::Value(cv) => cv,
_ => bug!("expected ConstKind::Value, got {:?}", self.kind()),
}
}
/// Attempts to convert to a value.
///
/// Note that this does not normalize the constant.

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

Program output

error[E0425]: cannot find value `C` in this scope
 --> /tmp/icemaker_global_tempdir.5ErorvnDhU35/rustc_testrunner_tmpdir_reporting.pgzBU5UhoO9P/mvce.rs:4:35
  |
4 | const C_INNER: (*const u8, u8) = (C, 0);
  |                                   ^ not found in this scope

error: `generic_const_args` requires `min_generic_const_args` to be enabled
 --> /tmp/icemaker_global_tempdir.5ErorvnDhU35/rustc_testrunner_tmpdir_reporting.pgzBU5UhoO9P/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.5ErorvnDhU35/rustc_testrunner_tmpdir_reporting.pgzBU5UhoO9P/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.5ErorvnDhU35/rustc_testrunner_tmpdir_reporting.pgzBU5UhoO9P/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.5ErorvnDhU35/rustc_testrunner_tmpdir_reporting.pgzBU5UhoO9P/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[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.5ErorvnDhU35/rustc_testrunner_tmpdir_reporting.pgzBU5UhoO9P/mvce.rs:9:2
  |
9 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.5ErorvnDhU35/rustc_testrunner_tmpdir_reporting.pgzBU5UhoO9P/mvce.rs`

error[E0741]: `(*const u8, u8)` can't be used as a const parameter type
 --> /tmp/icemaker_global_tempdir.5ErorvnDhU35/rustc_testrunner_tmpdir_reporting.pgzBU5UhoO9P/mvce.rs:4:16
  |
4 | const C_INNER: (*const u8, u8) = (C, 0);
  |                ^^^^^^^^^^^^^^^
  |
  = note: `*const u8` must implement `ConstParamTy_`, but it does not

error: internal compiler error: /rustc-dev/da47efd27287edb02eed0b5a178a165c8f258e37/compiler/rustc_middle/src/ty/consts.rs:256:18: expected ConstKind::Value, got {const error}


thread 'rustc' (2310463) panicked at /rustc-dev/da47efd27287edb02eed0b5a178a165c8f258e37/compiler/rustc_middle/src/ty/consts.rs:256:18:
Box<dyn Any>
stack backtrace:
   0:     0x7f30c98bde86 - <<std[7b8d936ff0591b4d]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[1338a38dbbf8640b]::fmt::Display>::fmt
   1:     0x7f30ca00829d - core[1338a38dbbf8640b]::fmt::write
   2:     0x7f30c98d2f5c - <std[7b8d936ff0591b4d]::sys::stdio::unix::Stderr as core[1338a38dbbf8640b]::io::write::Write>::write_fmt
   3:     0x7f30c989072a - std[7b8d936ff0591b4d]::panicking::default_hook::{closure#0}
   4:     0x7f30c98b2183 - std[7b8d936ff0591b4d]::panicking::default_hook
   5:     0x7f30c87fc55f - std[7b8d936ff0591b4d]::panicking::update_hook::<alloc[c8046bf86c4c1cc9]::boxed::Box<rustc_driver_impl[542a485098bab399]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f30c98b2622 - std[7b8d936ff0591b4d]::panicking::panic_with_hook
   7:     0x7f30c882ae04 - std[7b8d936ff0591b4d]::panicking::begin_panic::<rustc_errors[a20f047156ee2e30]::ExplicitBug>::{closure#0}
   8:     0x7f30c8823916 - std[7b8d936ff0591b4d]::sys::backtrace::__rust_end_short_backtrace::<std[7b8d936ff0591b4d]::panicking::begin_panic<rustc_errors[a20f047156ee2e30]::ExplicitBug>::{closure#0}, !>
   9:     0x7f30c88238cb - std[7b8d936ff0591b4d]::panicking::begin_panic::<rustc_errors[a20f047156ee2e30]::ExplicitBug>
  10:     0x7f30c88366d1 - <rustc_errors[a20f047156ee2e30]::diagnostic::BugAbort as rustc_errors[a20f047156ee2e30]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f30c8ddc9b9 - rustc_middle[3307db12b2d0bcfe]::util::bug::opt_span_bug_fmt::<rustc_span[be290dbee5d4923]::span_encoding::Span>::{closure#0}
  12:     0x7f30c8ddcdf2 - rustc_middle[3307db12b2d0bcfe]::ty::context::tls::with_opt::<rustc_middle[3307db12b2d0bcfe]::util::bug::opt_span_bug_fmt<rustc_span[be290dbee5d4923]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7f30c8dc8060 - rustc_middle[3307db12b2d0bcfe]::ty::context::tls::with_context_opt::<rustc_middle[3307db12b2d0bcfe]::ty::context::tls::with_opt<rustc_middle[3307db12b2d0bcfe]::util::bug::opt_span_bug_fmt<rustc_span[be290dbee5d4923]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7f30c5aa21c4 - rustc_middle[3307db12b2d0bcfe]::util::bug::bug_fmt
  15:     0x7f30c8df981a - <rustc_middle[3307db12b2d0bcfe]::ty::consts::Const>::to_value
  16:     0x7f30cb20e0e6 - <rustc_mir_build[5b5ed771c07fcc6e]::thir::pattern::const_to_pat::ConstToPat>::valtree_to_pat
  17:     0x7f30cb20ce45 - <rustc_mir_build[5b5ed771c07fcc6e]::thir::pattern::PatCtxt>::const_to_pat
  18:     0x7f30ca7f19a7 - <rustc_mir_build[5b5ed771c07fcc6e]::thir::pattern::PatCtxt>::lower_pat_expr
  19:     0x7f30ca7f35ec - <rustc_mir_build[5b5ed771c07fcc6e]::thir::pattern::PatCtxt>::lower_pattern
  20:     0x7f30ca7f2454 - rustc_mir_build[5b5ed771c07fcc6e]::thir::pattern::pat_from_hir::{closure#0}
  21:     0x7f30ca7fb230 - <rustc_mir_build[5b5ed771c07fcc6e]::thir::cx::ThirBuildCx>::mirror_expr
  22:     0x7f30ca7f83e6 - <rustc_mir_build[5b5ed771c07fcc6e]::thir::cx::ThirBuildCx>::mirror_block
  23:     0x7f30ca7fa2ae - <rustc_mir_build[5b5ed771c07fcc6e]::thir::cx::ThirBuildCx>::mirror_expr
  24:     0x7f30ca7e67d4 - rustc_mir_build[5b5ed771c07fcc6e]::thir::cx::thir_body
  25:     0x7f30ca7e5b12 - rustc_query_impl[a795fc8e0dec0451]::query_vtables::thir_body::invoke_provider_fn::__rust_begin_short_backtrace
  26:     0x7f30ca6821cc - 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; 16usize]>, rustc_middle[3307db12b2d0bcfe]::dep_graph::graph::DepNodeIndex>, false>
  27:     0x7f30ca681ba7 - rustc_query_impl[a795fc8e0dec0451]::query_vtables::thir_body::execute_query_non_incr::__rust_end_short_backtrace
  28:     0x7f30ca7dd94d - rustc_mir_build[5b5ed771c07fcc6e]::check_unsafety::check_unsafety
  29:     0x7f30ca7cb6d1 - 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; 0usize]>, rustc_middle[3307db12b2d0bcfe]::dep_graph::graph::DepNodeIndex>, false>
  30:     0x7f30ca7cb455 - rustc_query_impl[a795fc8e0dec0451]::query_vtables::check_unsafety::execute_query_non_incr::__rust_end_short_backtrace
  31:     0x7f30ca7ca253 - <rustc_middle[3307db12b2d0bcfe]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[55d539fc721ed361]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  32:     0x7f30ca7c964e - rustc_interface[55d539fc721ed361]::passes::analysis
  33:     0x7f30cb23084a - rustc_query_impl[a795fc8e0dec0451]::execution::try_execute_query::<rustc_middle[3307db12b2d0bcfe]::query::caches::SingleCache<rustc_middle[3307db12b2d0bcfe]::query::erase::ErasedData<[u8; 0usize]>>, false>
  34:     0x7f30cb23062b - rustc_query_impl[a795fc8e0dec0451]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
  35:     0x7f30cb31f78c - rustc_interface[55d539fc721ed361]::interface::run_compiler::<(), rustc_driver_impl[542a485098bab399]::run_compiler::{closure#0}>::{closure#2}
  36:     0x7f30cb42f564 - 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}, ()>
  37:     0x7f30cb42f30b - <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}
  38:     0x7f30cb42cd47 - <std[7b8d936ff0591b4d]::sys::thread::unix::Thread>::new::thread_start
  39:     0x7f30c44980a2 - <unknown>
  40:     0x7f30c452080c - <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.100.0-nightly (da47efd27 2026-09-06) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [thir_body] building THIR for `foo2`
#1 [check_unsafety] unsafety-checking `foo2`
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 6 previous errors; 2 warnings emitted

Some errors have detailed explanations: E0425, E0601, E0741.
For more information about an error, try `rustc --explain E0425`.

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

Activity

  1. added
    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.
    C-bugCategory: This is a bug.
    on Sep 6, 2026
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 6, 2026
  3. rustbot commented on Sep 6, 2026

    @rustbot
    Collaborator

    Error: Unknown labels: F-macroless_generic_const_args

    Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip.

  4. added
    F-gca_min_const_items`#![feature(gca_min_const_items)]` (previously: `min_generic_const_args`)
    F-gca_const_items`#![feature(gca_const_items)]` (previously: `generic_const_args`)
    on Sep 6, 2026
  5. lsunsi commented on Sep 8, 2026

    @lsunsi
    Contributor

    searched nightlies: from nightly-2026-01-01 to nightly-2026-09-08
    regressed nightly: nightly-2026-09-06
    searched commit range: 0ed41eb...f248f40
    regressed commit: 0f819a1

    bisected with cargo-bisect-rustc v0.6.11

    Host triple: x86_64-unknown-linux-gnu
    Reproduce with:

    cargo bisect-rustc --start=2026-01-01 --end=2026-09-08 --regress=ice --without-cargo
  6. lsunsi commented on Sep 8, 2026

    @lsunsi
    Contributor

    It's the same commit of the related issue

  7. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Oct 7, 2026
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-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.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions