Skip to content

[ICE]: Enum discriminant referring to Self causes "... has parameters, but no args were provided in instantiate" #153756

@theemathas

Description

@theemathas

Code

#![feature(sized_hierarchy)]

use std::marker::PointeeSized;

#[repr(usize)]
enum What<T: PointeeSized> {
    X = size_of::<*mut Self>(),
    Y(*mut T)
}

Meta

Reproducible on the playground with version 1.96.0-nightly (2026-03-11 3b1b0ef4d80d3117924d)

Error output

thread 'rustc' (27) panicked at /rustc-dev/3b1b0ef4d80d3117924d91352c8b6ca528708b3c/compiler/rustc_type_ir/src/binder.rs:658:13:
Val(ZeroSized, FnDef(DefId(2:2522 ~ core[d6e6]::mem::size_of), [*mut What<T/#0>])) has parameters, but no args were provided in instantiate
Backtrace

stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_operand
   3: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_callee_and_args
   4: rustc_const_eval::const_eval::eval_queries::eval_to_allocation_raw_provider
      [... omitted 1 frame ...]
   5: rustc_const_eval::const_eval::eval_queries::eval_to_const_value_raw_provider
      [... omitted 1 frame ...]
   6: <rustc_middle::ty::context::TyCtxt>::const_eval_poly
   7: <rustc_middle::ty::adt::AdtDef>::eval_explicit_discr
   8: rustc_hir_analysis::check::check::check_item_type
   9: rustc_hir_analysis::check::wfcheck::check_well_formed
      [... omitted 1 frame ...]
  10: rustc_hir_analysis::check::wfcheck::check_type_wf
      [... omitted 1 frame ...]
  11: rustc_hir_analysis::check_crate
  12: rustc_interface::passes::analysis
  13: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
  14: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: please attach the file at `/playground/rustc-ice-2026-03-12T04_25_48-25.txt` to your bug report

note: rustc 1.96.0-nightly (3b1b0ef4d 2026-03-11) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `What::X::{constant#0}`
#1 [eval_to_const_value_raw] simplifying constant for the type system `What::X::{constant#0}`
#2 [check_well_formed] checking that `What` is well-formed
#3 [check_type_wf] checking that types are well-formed
#4 [analysis] running analysis passes on crate `playground`
end of query stack

Metadata

Metadata

Assignees

Labels

A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-enumArea: Enums (discriminated unions, or more generally ADTs (algebraic data types))C-bugCategory: This is a bug.F-sized_hierarchy`#![feature(sized_hierarchy)]`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
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions