Skip to content

ICE expected ConstKind::Value, got {const error} #150457

@matthiaskrgr

Description

@matthiaskrgr

Code

#![feature(transmutability)]
#![feature(min_generic_const_args)]

use std::mem::{Assume, TransmuteFrom};

struct W<'a>(&'a ());

fn test<'a>()
where
    W<'a>: TransmuteFrom<
        (),
        {
            Assume {
                alignment: const { true },
                lifetimes: const { true },
                safety: const { true },
                validity: true, // boom
            }
        },
    >,
{
}

fn main() {
    test()
}

Meta

rustc --version --verbose:

rustc 1.94.0-nightly (7b5cde737 2025-12-27)
binary: rustc
commit-hash: 7b5cde7370b82fecf700071dda98c3fbc7d41fae
commit-date: 2025-12-27
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8

Error output

warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> a.rs:2:12
  |
2 | #![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

error: complex const arguments must be placed inside of a `const` block
  --> a.rs:17:27
   |
17 |                 validity: true, // boom
   |                           ^^^^
Backtrace

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


thread 'rustc' (3293447) panicked at /rustc-dev/7b5cde7370b82fecf700071dda98c3fbc7d41fae/compiler/rustc_middle/src/ty/consts.rs:258:18:
Box<dyn Any>
stack backtrace:
   0:     0x7fe9bba53393 - <<std[d04b43a2428f6e7c]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[5301abcae13ad7a]::fmt::Display>::fmt
   1:     0x7fe9bc010b88 - core[5301abcae13ad7a]::fmt::write
   2:     0x7fe9bba69aa6 - <std[d04b43a2428f6e7c]::sys::stdio::unix::Stderr as std[d04b43a2428f6e7c]::io::Write>::write_fmt
   3:     0x7fe9bba29c48 - std[d04b43a2428f6e7c]::panicking::default_hook::{closure#0}
   4:     0x7fe9bba472d3 - std[d04b43a2428f6e7c]::panicking::default_hook
   5:     0x7fe9baa21aca - std[d04b43a2428f6e7c]::panicking::update_hook::<alloc[966711e2d4248474]::boxed::Box<rustc_driver_impl[d4ed2211832a1e45]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fe9bba475b2 - std[d04b43a2428f6e7c]::panicking::panic_with_hook
   7:     0x7fe9baa5e371 - std[d04b43a2428f6e7c]::panicking::begin_panic::<rustc_errors[cb139601f36bb398]::ExplicitBug>::{closure#0}
   8:     0x7fe9baa4e866 - std[d04b43a2428f6e7c]::sys::backtrace::__rust_end_short_backtrace::<std[d04b43a2428f6e7c]::panicking::begin_panic<rustc_errors[cb139601f36bb398]::ExplicitBug>::{closure#0}, !>
   9:     0x7fe9baa4be3c - std[d04b43a2428f6e7c]::panicking::begin_panic::<rustc_errors[cb139601f36bb398]::ExplicitBug>
  10:     0x7fe9baa7c2b1 - <rustc_errors[cb139601f36bb398]::diagnostic::BugAbort as rustc_errors[cb139601f36bb398]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7fe9bb02b659 - rustc_middle[b12d616c0d1b1d17]::util::bug::opt_span_bug_fmt::<rustc_span[41c12b187d0c00e0]::span_encoding::Span>::{closure#0}
  12:     0x7fe9bb02b7e2 - rustc_middle[b12d616c0d1b1d17]::ty::context::tls::with_opt::<rustc_middle[b12d616c0d1b1d17]::util::bug::opt_span_bug_fmt<rustc_span[41c12b187d0c00e0]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7fe9bb01c6db - rustc_middle[b12d616c0d1b1d17]::ty::context::tls::with_context_opt::<rustc_middle[b12d616c0d1b1d17]::ty::context::tls::with_opt<rustc_middle[b12d616c0d1b1d17]::util::bug::opt_span_bug_fmt<rustc_span[41c12b187d0c00e0]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7fe9b8afb2b4 - rustc_middle[b12d616c0d1b1d17]::util::bug::bug_fmt
  15:     0x7fe9bb03ae5d - <rustc_middle[b12d616c0d1b1d17]::ty::consts::Const>::to_value
  16:     0x7fe9bb96bae0 - <rustc_transmute[a12e57d9e66745af]::Assume>::from_const
  17:     0x7fe9bd04651a - <rustc_trait_selection[7ed3222c48c013c]::traits::select::SelectionContext>::confirm_candidate
  18:     0x7fe9bc0a4f28 - <rustc_trait_selection[7ed3222c48c013c]::traits::select::SelectionContext>::evaluate_candidate::{closure#0}
  19:     0x7fe9bc0c5e76 - <rustc_trait_selection[7ed3222c48c013c]::traits::select::SelectionContext>::candidate_from_obligation::{closure#0}::{closure#0}
  20:     0x7fe9bd2cfadc - <rustc_trait_selection[7ed3222c48c013c]::traits::select::SelectionContext>::poly_select::{closure#0}
  21:     0x7fe9bc7adc86 - <rustc_trait_selection[7ed3222c48c013c]::traits::fulfill::FulfillProcessor as rustc_data_structures[6f877b1072984333]::obligation_forest::ObligationProcessor>::process_obligation
  22:     0x7fe9bc0045a4 - <rustc_data_structures[6f877b1072984333]::obligation_forest::ObligationForest<rustc_trait_selection[7ed3222c48c013c]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[7ed3222c48c013c]::traits::fulfill::FulfillProcessor>
  23:     0x7fe9bc974632 - <rustc_trait_selection[7ed3222c48c013c]::traits::fulfill::FulfillmentContext<rustc_trait_selection[7ed3222c48c013c]::traits::FulfillmentError> as rustc_infer[f63cdcb0b0c4914b]::traits::engine::TraitEngine<rustc_trait_selection[7ed3222c48c013c]::traits::FulfillmentError>>::evaluate_obligations_error_on_ambiguity
  24:     0x7fe9bc96c96f - rustc_hir_analysis[f780883f01c706ba]::check::wfcheck::check_item_fn
  25:     0x7fe9bc9d3786 - rustc_hir_analysis[f780883f01c706ba]::check::check::check_item_type
  26:     0x7fe9bc9cf776 - rustc_hir_analysis[f780883f01c706ba]::check::wfcheck::check_well_formed
  27:     0x7fe9bc9cf757 - rustc_query_impl[7dbdc15bcc8f2d5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7dbdc15bcc8f2d5]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b12d616c0d1b1d17]::query::erase::Erased<[u8; 1usize]>>
  28:     0x7fe9bc9cefcd - rustc_query_system[ff548912004eb624]::query::plumbing::try_execute_query::<rustc_query_impl[7dbdc15bcc8f2d5]::DynamicConfig<rustc_data_structures[6f877b1072984333]::vec_cache::VecCache<rustc_span[41c12b187d0c00e0]::def_id::LocalDefId, rustc_middle[b12d616c0d1b1d17]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[ff548912004eb624]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[7dbdc15bcc8f2d5]::plumbing::QueryCtxt, false>
  29:     0x7fe9bc9cead6 - rustc_query_impl[7dbdc15bcc8f2d5]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7fe9bc9cc270 - rustc_hir_analysis[f780883f01c706ba]::check::wfcheck::check_type_wf
  31:     0x7fe9bc9cc15d - rustc_query_impl[7dbdc15bcc8f2d5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7dbdc15bcc8f2d5]::query_impl::check_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b12d616c0d1b1d17]::query::erase::Erased<[u8; 1usize]>>
  32:     0x7fe9bd1cdf88 - rustc_query_system[ff548912004eb624]::query::plumbing::try_execute_query::<rustc_query_impl[7dbdc15bcc8f2d5]::DynamicConfig<rustc_query_system[ff548912004eb624]::query::caches::SingleCache<rustc_middle[b12d616c0d1b1d17]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[7dbdc15bcc8f2d5]::plumbing::QueryCtxt, false>
  33:     0x7fe9bd1cdd4e - rustc_query_impl[7dbdc15bcc8f2d5]::query_impl::check_type_wf::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7fe9bc7f8174 - rustc_hir_analysis[f780883f01c706ba]::check_crate
  35:     0x7fe9bcee059b - rustc_interface[84bae928b5c4a14c]::passes::analysis
  36:     0x7fe9bcee01f5 - rustc_query_impl[7dbdc15bcc8f2d5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7dbdc15bcc8f2d5]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b12d616c0d1b1d17]::query::erase::Erased<[u8; 0usize]>>
  37:     0x7fe9bd1cf766 - rustc_query_system[ff548912004eb624]::query::plumbing::try_execute_query::<rustc_query_impl[7dbdc15bcc8f2d5]::DynamicConfig<rustc_query_system[ff548912004eb624]::query::caches::SingleCache<rustc_middle[b12d616c0d1b1d17]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[7dbdc15bcc8f2d5]::plumbing::QueryCtxt, false>
  38:     0x7fe9bd1cf336 - rustc_query_impl[7dbdc15bcc8f2d5]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  39:     0x7fe9bd3cf614 - <rustc_interface[84bae928b5c4a14c]::passes::create_and_enter_global_ctxt<core[5301abcae13ad7a]::option::Option<rustc_interface[84bae928b5c4a14c]::queries::Linker>, rustc_driver_impl[d4ed2211832a1e45]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[5301abcae13ad7a]::ops::function::FnOnce<(&rustc_session[34b11767d146bd]::session::Session, rustc_middle[b12d616c0d1b1d17]::ty::context::CurrentGcx, alloc[966711e2d4248474]::sync::Arc<rustc_data_structures[6f877b1072984333]::jobserver::Proxy>, &std[d04b43a2428f6e7c]::sync::once_lock::OnceLock<rustc_middle[b12d616c0d1b1d17]::ty::context::GlobalCtxt>, &rustc_data_structures[6f877b1072984333]::sync::worker_local::WorkerLocal<rustc_middle[b12d616c0d1b1d17]::arena::Arena>, &rustc_data_structures[6f877b1072984333]::sync::worker_local::WorkerLocal<rustc_hir[bd2e92b33866e02d]::Arena>, rustc_driver_impl[d4ed2211832a1e45]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  40:     0x7fe9bd1f2358 - rustc_interface[84bae928b5c4a14c]::interface::run_compiler::<(), rustc_driver_impl[d4ed2211832a1e45]::run_compiler::{closure#0}>::{closure#1}
  41:     0x7fe9bd1926ce - std[d04b43a2428f6e7c]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[84bae928b5c4a14c]::util::run_in_thread_with_globals<rustc_interface[84bae928b5c4a14c]::util::run_in_thread_pool_with_globals<rustc_interface[84bae928b5c4a14c]::interface::run_compiler<(), rustc_driver_impl[d4ed2211832a1e45]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  42:     0x7fe9bd1924a0 - <std[d04b43a2428f6e7c]::thread::lifecycle::spawn_unchecked<rustc_interface[84bae928b5c4a14c]::util::run_in_thread_with_globals<rustc_interface[84bae928b5c4a14c]::util::run_in_thread_pool_with_globals<rustc_interface[84bae928b5c4a14c]::interface::run_compiler<(), rustc_driver_impl[d4ed2211832a1e45]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[5301abcae13ad7a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7fe9bd197df8 - <std[d04b43a2428f6e7c]::sys::thread::unix::Thread>::new::thread_start
  44:     0x7fe9b6a9698b - <unknown>
  45:     0x7fe9b6b1a9cc - <unknown>
  46:                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: please attach the file at `/tmp/im2/rustc-ice-2025-12-28T10_41_12-3293429.txt` to your bug report

note: rustc 1.94.0-nightly (7b5cde737 2025-12-27) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_well_formed] checking that `test` is well-formed
#1 [check_type_wf] checking that types are well-formed
#2 [analysis] running analysis passes on crate `a`
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted

since #149114

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-min_generic_const_args`#![feature(min_generic_const_args)]`F-transmutability`#![feature(transmutability)]`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