Skip to content

ICE unexpected DefKind for const alias to resolve to: Ctor(Struct, Const) #148953

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(min_generic_const_args)]
struct S;
impl S {
    #[type_const]
    const N: S = S;
}

original:

#![feature(min_generic_const_args)]
struct S;
impl S {
    #[type_const]
    const N: S = S;
}
pub fn main() {}

Version information

rustc 1.93.0-nightly (c91009892 2025-11-14)
binary: rustc
commit-hash: c91009892b4cd1776d4c9d85793166612195a03d
commit-date: 2025-11-14
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.5

Possibly related line of code:

&mut self.universes,
ct,
|ct| super::evaluate_const(self.selcx.infcx, ct, self.param_env),
)
}
kind => {
unreachable!("unexpected `DefKind` for const alias to resolve to: {:?}", kind)
}
};
// We re-fold the normalized const as the `ty` field on `ConstKind::Value` may be
// unnormalized after const evaluation returns.
ct.super_fold_with(self)

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

Program output

warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.wStjeEpq9h9m/rustc_testrunner_tmpdir_reporting.A15k88BBszU2/mvce.rs:1:12
  |
1 | #![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[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.wStjeEpq9h9m/rustc_testrunner_tmpdir_reporting.A15k88BBszU2/mvce.rs:6:2
  |
6 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.wStjeEpq9h9m/rustc_testrunner_tmpdir_reporting.A15k88BBszU2/mvce.rs`


thread 'rustc' (3706774) panicked at compiler/rustc_trait_selection/src/traits/normalize.rs:474:17:
internal error: entered unreachable code: unexpected `DefKind` for const alias to resolve to: Ctor(Struct, Const)
stack backtrace:
   0:     0x7fdf1df24173 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h6a5c624d464fa678
   1:     0x7fdf1e601d88 - core::fmt::write::hcd7baff1129f5a48
   2:     0x7fdf1ded9736 - std::io::Write::write_fmt::h41ab9f2b71201a88
   3:     0x7fdf1def0aac - std::panicking::default_hook::{{closure}}::h2ac413f3765072ef
   4:     0x7fdf1def0603 - std::panicking::default_hook::hfd7bb8fab1f8d68b
   5:     0x7fdf1cf2f317 - std[679d48c1f609a32f]::panicking::update_hook::<alloc[4ab92568d40b45eb]::boxed::Box<rustc_driver_impl[91301aa791a6027f]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fdf1def0e62 - std::panicking::panic_with_hook::hdd1313f07dd59db2
   7:     0x7fdf1def0bf8 - std::panicking::panic_handler::{{closure}}::hb8ce0de48af20de1
   8:     0x7fdf1deeab59 - std::sys::backtrace::__rust_end_short_backtrace::h1f9597559e00626c
   9:     0x7fdf1decbc2d - __rustc[6200e4bf8384f687]::rust_begin_unwind
  10:     0x7fdf1ae5af3c - core::panicking::panic_fmt::h56cea9fa98793212
  11:     0x7fdf1e786fba - <rustc_trait_selection[cc384bab39185e43]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[51d789c965f2be58]::fold::TypeFolder<rustc_middle[3193b4a475045f9b]::ty::context::TyCtxt>>::fold_const
  12:     0x7fdf1d078367 - <rustc_infer[a4098c4d9951a433]::infer::at::At as rustc_trait_selection[cc384bab39185e43]::traits::normalize::NormalizeExt>::normalize::<rustc_middle[3193b4a475045f9b]::ty::consts::Const>
  13:     0x7fdf1d0eeaa1 - rustc_hir_analysis[4a8b4e076f3e1a54]::check::wfcheck::check_type_const
  14:     0x7fdf1ef1282a - rustc_hir_analysis[4a8b4e076f3e1a54]::check::wfcheck::enter_wf_checking_ctxt::<rustc_hir_analysis[4a8b4e076f3e1a54]::check::wfcheck::check_associated_item::{closure#0}>
  15:     0x7fdf1ede37e3 - rustc_hir_analysis[4a8b4e076f3e1a54]::check::check::check_item_type
  16:     0x7fdf1ede1d9c - rustc_hir_analysis[4a8b4e076f3e1a54]::check::wfcheck::check_well_formed
  17:     0x7fdf1ede1d61 - rustc_query_impl[8184a5616bb2d907]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8184a5616bb2d907]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3193b4a475045f9b]::query::erase::Erased<[u8; 1usize]>>
  18:     0x7fdf1ede162c - rustc_query_system[2d6f96cce5ccb8ff]::query::plumbing::try_execute_query::<rustc_query_impl[8184a5616bb2d907]::DynamicConfig<rustc_data_structures[6cc17db83c784504]::vec_cache::VecCache<rustc_span[501de4d049549587]::def_id::LocalDefId, rustc_middle[3193b4a475045f9b]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[2d6f96cce5ccb8ff]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[8184a5616bb2d907]::plumbing::QueryCtxt, false>
  19:     0x7fdf1ede1142 - rustc_query_impl[8184a5616bb2d907]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  20:     0x7fdf1edde848 - rustc_hir_analysis[4a8b4e076f3e1a54]::check::wfcheck::check_type_wf
  21:     0x7fdf1edde739 - rustc_query_impl[8184a5616bb2d907]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8184a5616bb2d907]::query_impl::check_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3193b4a475045f9b]::query::erase::Erased<[u8; 1usize]>>
  22:     0x7fdf1f656254 - rustc_query_system[2d6f96cce5ccb8ff]::query::plumbing::try_execute_query::<rustc_query_impl[8184a5616bb2d907]::DynamicConfig<rustc_query_system[2d6f96cce5ccb8ff]::query::caches::SingleCache<rustc_middle[3193b4a475045f9b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[8184a5616bb2d907]::plumbing::QueryCtxt, false>
  23:     0x7fdf1f656036 - rustc_query_impl[8184a5616bb2d907]::query_impl::check_type_wf::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7fdf1e8dc87a - rustc_hir_analysis[4a8b4e076f3e1a54]::check_crate
  25:     0x7fdf1e8e5077 - rustc_interface[79b32874b130099f]::passes::analysis
  26:     0x7fdf1e8e4d33 - rustc_query_impl[8184a5616bb2d907]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8184a5616bb2d907]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3193b4a475045f9b]::query::erase::Erased<[u8; 0usize]>>
  27:     0x7fdf1f65c7d4 - rustc_query_system[2d6f96cce5ccb8ff]::query::plumbing::try_execute_query::<rustc_query_impl[8184a5616bb2d907]::DynamicConfig<rustc_query_system[2d6f96cce5ccb8ff]::query::caches::SingleCache<rustc_middle[3193b4a475045f9b]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[8184a5616bb2d907]::plumbing::QueryCtxt, false>
  28:     0x7fdf1f65c40a - rustc_query_impl[8184a5616bb2d907]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7fdf1f8d6313 - <rustc_interface[79b32874b130099f]::passes::create_and_enter_global_ctxt<core[27292545e86084dd]::option::Option<rustc_interface[79b32874b130099f]::queries::Linker>, rustc_driver_impl[91301aa791a6027f]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[27292545e86084dd]::ops::function::FnOnce<(&rustc_session[f75d750e96f6b031]::session::Session, rustc_middle[3193b4a475045f9b]::ty::context::CurrentGcx, alloc[4ab92568d40b45eb]::sync::Arc<rustc_data_structures[6cc17db83c784504]::jobserver::Proxy>, &std[679d48c1f609a32f]::sync::once_lock::OnceLock<rustc_middle[3193b4a475045f9b]::ty::context::GlobalCtxt>, &rustc_data_structures[6cc17db83c784504]::sync::worker_local::WorkerLocal<rustc_middle[3193b4a475045f9b]::arena::Arena>, &rustc_data_structures[6cc17db83c784504]::sync::worker_local::WorkerLocal<rustc_hir[e91e01ab48700aa7]::Arena>, rustc_driver_impl[91301aa791a6027f]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  30:     0x7fdf1f723c05 - rustc_interface[79b32874b130099f]::interface::run_compiler::<(), rustc_driver_impl[91301aa791a6027f]::run_compiler::{closure#0}>::{closure#1}
  31:     0x7fdf1f6ada3a - std[679d48c1f609a32f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[79b32874b130099f]::util::run_in_thread_with_globals<rustc_interface[79b32874b130099f]::util::run_in_thread_pool_with_globals<rustc_interface[79b32874b130099f]::interface::run_compiler<(), rustc_driver_impl[91301aa791a6027f]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  32:     0x7fdf1f6ad728 - <<std[679d48c1f609a32f]::thread::Builder>::spawn_unchecked_<rustc_interface[79b32874b130099f]::util::run_in_thread_with_globals<rustc_interface[79b32874b130099f]::util::run_in_thread_pool_with_globals<rustc_interface[79b32874b130099f]::interface::run_compiler<(), rustc_driver_impl[91301aa791a6027f]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[27292545e86084dd]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7fdf1f6b35ef - std::sys::thread::unix::Thread::new::thread_start::h468da742cb4407a7
  34:     0x7fdf190969cb - <unknown>
  35:     0x7fdf1911aa0c - <unknown>
  36:                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.93.0-nightly (c91009892 2025-11-14) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.wStjeEpq9h9m/rustc_testrunner_tmpdir_reporting.A15k88BBszU2/mvce.rs:3:1: 3:7>::N` is well-formed
#1 [check_type_wf] checking that types are well-formed
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 1 previous error; 1 warning emitted

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

@rustbot label +F-min_generic_const_args

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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