Skip to content

[ICE]: AliasConst::type_of got InherentSelf - args should always be InherentImpl at this point #162147

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(
    min_generic_const_args,
    ,
    inherent_associated_types,
    min_adt_const_params,
    
)]

struct ThreeTypes<T1, T2, T3>(T1, T2, T3);

impl<T1, T2, > ThreeTypes<T1, T2, T3> {
    type const INHERENT;
}

struct Struct<const O: [u32; 0]>;

fn f() -> Struct<{ core::direct_const_arg!(ThreeTypes::<u8, u16, u32>::INHERENT) }> {
    Struct
}

original:

// Arrays where the expanded result is a `Res::ConstParam`
#![feature(
    min_generic_const_args,
    generic_const_parameter_types,
    inherent_associated_types,
    min_adt_const_params,
    const_param_ty_trait
)]

struct ThreeTypes<T1, T2, T3>(T1, T2, T3);

impl<T1, T2, T3: std::marker::ConstParamTy_> ThreeTypes<T1, T2, T3> {
    type const INHERENT: [T3; 0] = [];
}

struct Struct<const O: [u32; 0]>;

fn f() -> Struct<{ core::direct_const_arg!(ThreeTypes::<u8, u16, u32>::INHERENT) }> {
    Struct
}

fn main() {}

Version information

rustc 1.100.0-nightly (a4330234a 2026-09-01)
binary: rustc
commit-hash: a4330234a776684c36428d001721d0320d24dd77
commit-date: 2026-09-01
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.0

Possibly related line of code:

}
pub fn type_of(self, interner: I) -> ty::Unnormalized<I, I::Ty> {
let def_id = match self.kind {
ty::AliasConstKind::Projection { def_id } => def_id.into(),
ty::AliasConstKind::InherentSelf { .. } => {
panic!(
"AliasConst::type_of got InherentSelf - args should always be InherentImpl at this point"
)
}
ty::AliasConstKind::InherentImpl { def_id } => def_id.into(),
ty::AliasConstKind::Free { def_id } => def_id.into(),
ty::AliasConstKind::Anon { def_id } => def_id.into(),

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

Program output

error: expected identifier, found `,`
 --> /tmp/icemaker_global_tempdir.7DwGo6G3YZjD/rustc_testrunner_tmpdir_reporting.67hEa4Btt0Vt/mvce.rs:4:5
  |
4 |     ,
  |     ^ expected identifier
  |
help: remove this comma
  |
4 -     ,
  |

error: associated constant in `impl` without body
  --> /tmp/icemaker_global_tempdir.7DwGo6G3YZjD/rustc_testrunner_tmpdir_reporting.67hEa4Btt0Vt/mvce.rs:13:5
   |
13 |     type const INHERENT;
   |     ^^^^^^^^^^^^^^^^^^^-
   |                        |
   |                        help: provide a definition for the constant: `= <expr>;`

error[E0425]: cannot find type `T3` in this scope
  --> /tmp/icemaker_global_tempdir.7DwGo6G3YZjD/rustc_testrunner_tmpdir_reporting.67hEa4Btt0Vt/mvce.rs:12:35
   |
12 | impl<T1, T2, > ThreeTypes<T1, T2, T3> {
   |                                   ^^ not found in this scope
   |
note: similarly named type parameter `T1` defined here
  --> /tmp/icemaker_global_tempdir.7DwGo6G3YZjD/rustc_testrunner_tmpdir_reporting.67hEa4Btt0Vt/mvce.rs:12:6
   |
12 | impl<T1, T2, > ThreeTypes<T1, T2, T3> {
   |      ^^
help: a type parameter with a similar name exists
   |
12 - impl<T1, T2, > ThreeTypes<T1, T2, T3> {
12 + impl<T1, T2, > ThreeTypes<T1, T2, T1> {
   |
help: you might be missing a type parameter
   |
12 | impl<T1, T2, T3, > ThreeTypes<T1, T2, T3> {
   |            ++++

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.7DwGo6G3YZjD/rustc_testrunner_tmpdir_reporting.67hEa4Btt0Vt/mvce.rs:3:5
  |
3 |     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

warning: the feature `inherent_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.7DwGo6G3YZjD/rustc_testrunner_tmpdir_reporting.67hEa4Btt0Vt/mvce.rs:5:5
  |
5 |     inherent_associated_types,
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.7DwGo6G3YZjD/rustc_testrunner_tmpdir_reporting.67hEa4Btt0Vt/mvce.rs:20:2
   |
20 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.7DwGo6G3YZjD/rustc_testrunner_tmpdir_reporting.67hEa4Btt0Vt/mvce.rs`

error: missing type for `const` item
  --> /tmp/icemaker_global_tempdir.7DwGo6G3YZjD/rustc_testrunner_tmpdir_reporting.67hEa4Btt0Vt/mvce.rs:13:24
   |
13 |     type const INHERENT;
   |                        ^
   |
help: provide a type for the item
   |
13 |     type const INHERENT: <type>;
   |                        ++++++++


thread 'rustc' (3838553) panicked at /rustc-dev/a4330234a776684c36428d001721d0320d24dd77/compiler/rustc_type_ir/src/const_kind.rs:85:17:
AliasConst::type_of got InherentSelf - args should always be InherentImpl at this point
stack backtrace:
   0:     0x7fbe9a687576 - <<std[30cbc90d73eb2f7]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[37d23c544a63de81]::fmt::Display>::fmt
   1:     0x7fbe9ac1138f - core[37d23c544a63de81]::fmt::write
   2:     0x7fbe9a69c64c - <std[30cbc90d73eb2f7]::sys::stdio::unix::Stderr as core[37d23c544a63de81]::io::write::Write>::write_fmt
   3:     0x7fbe9a659e4a - std[30cbc90d73eb2f7]::panicking::default_hook::{closure#0}
   4:     0x7fbe9a67b8a3 - std[30cbc90d73eb2f7]::panicking::default_hook
   5:     0x7fbe995f1d8f - std[30cbc90d73eb2f7]::panicking::update_hook::<alloc[1ae459ecdd033a44]::boxed::Box<rustc_driver_impl[42633c3e3ce72fef]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fbe9a67bd42 - std[30cbc90d73eb2f7]::panicking::panic_with_hook
   7:     0x7fbe9a659f34 - std[30cbc90d73eb2f7]::panicking::panic_handler::{closure#0}
   8:     0x7fbe9a651b09 - std[30cbc90d73eb2f7]::sys::backtrace::__rust_end_short_backtrace::<std[30cbc90d73eb2f7]::panicking::panic_handler::{closure#0}, !>
   9:     0x7fbe9a65badd - __rustc[78778d388752f3b1]::rust_begin_unwind
  10:     0x7fbe9745636c - core[37d23c544a63de81]::panicking::panic_fmt
  11:     0x7fbe9a4a6b0c - <rustc_type_ir[740cb680109dbe18]::ty::alias::Alias<rustc_middle[a86b7b2986aebea0]::ty::context::TyCtxt, rustc_type_ir[740cb680109dbe18]::const_kind::AliasConstKind<rustc_middle[a86b7b2986aebea0]::ty::context::TyCtxt>>>::type_of
  12:     0x7fbe9cfa1ecb - <rustc_next_trait_solver[1853f23884fbb7e4]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[dd61d12ef2e98b62]::solve::delegate::SolverDelegate, rustc_middle[a86b7b2986aebea0]::ty::context::TyCtxt>>::push_const_arg_has_type_goal.cold
  13:     0x7fbe9ba49bff - <rustc_next_trait_solver[1853f23884fbb7e4]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[dd61d12ef2e98b62]::solve::delegate::SolverDelegate, rustc_middle[a86b7b2986aebea0]::ty::context::TyCtxt>>::evaluate_goal_no_fast_paths
  14:     0x7fbe9acda5af - <rustc_trait_selection[dd61d12ef2e98b62]::solve::delegate::SolverDelegate as rustc_next_trait_solver[1853f23884fbb7e4]::solve::eval_ctxt::SolverDelegateEvalExt>::evaluate_root_goal
  15:     0x7fbe9acda1a1 - <rustc_next_trait_solver[1853f23884fbb7e4]::normalize::NormalizationFolder<rustc_infer[ba9256cec691e9f9]::infer::InferCtxt, rustc_middle[a86b7b2986aebea0]::ty::context::TyCtxt, rustc_trait_selection[dd61d12ef2e98b62]::solve::normalize::normalize_with_universes<rustc_middle[a86b7b2986aebea0]::ty::Ty>::{closure#0}>>::normalize_alias_term
  16:     0x7fbe9bb0bb62 - <rustc_next_trait_solver[1853f23884fbb7e4]::normalize::NormalizationFolder<rustc_infer[ba9256cec691e9f9]::infer::InferCtxt, rustc_middle[a86b7b2986aebea0]::ty::context::TyCtxt, rustc_trait_selection[dd61d12ef2e98b62]::solve::normalize::normalize_with_universes<rustc_middle[a86b7b2986aebea0]::ty::Ty>::{closure#0}> as rustc_type_ir[740cb680109dbe18]::fold::FallibleTypeFolder<rustc_middle[a86b7b2986aebea0]::ty::context::TyCtxt>>::try_fold_const::{closure#0}
  17:     0x7fbe9bb0b687 - <&rustc_middle[a86b7b2986aebea0]::ty::list::RawList<(), rustc_middle[a86b7b2986aebea0]::ty::generic_args::GenericArg> as rustc_type_ir[740cb680109dbe18]::fold::TypeFoldable<rustc_middle[a86b7b2986aebea0]::ty::context::TyCtxt>>::try_fold_with::<rustc_next_trait_solver[1853f23884fbb7e4]::normalize::NormalizationFolder<rustc_infer[ba9256cec691e9f9]::infer::InferCtxt, rustc_middle[a86b7b2986aebea0]::ty::context::TyCtxt, rustc_trait_selection[dd61d12ef2e98b62]::solve::normalize::normalize_with_universes<rustc_middle[a86b7b2986aebea0]::ty::Ty>::{closure#0}>>
  18:     0x7fbe9bb0ae2b - <rustc_next_trait_solver[1853f23884fbb7e4]::normalize::NormalizationFolder<rustc_infer[ba9256cec691e9f9]::infer::InferCtxt, rustc_middle[a86b7b2986aebea0]::ty::context::TyCtxt, rustc_trait_selection[dd61d12ef2e98b62]::solve::normalize::normalize_with_universes<rustc_middle[a86b7b2986aebea0]::ty::Ty>::{closure#0}> as rustc_type_ir[740cb680109dbe18]::fold::FallibleTypeFolder<rustc_middle[a86b7b2986aebea0]::ty::context::TyCtxt>>::try_fold_ty::{closure#0}
  19:     0x7fbe9b44bb48 - <rustc_hir_analysis[e3348fb73159a1b9]::check::wfcheck::WfCheckingCtxt>::deeply_normalize::<rustc_middle[a86b7b2986aebea0]::ty::Ty>
  20:     0x7fbe9b44dca3 - rustc_hir_analysis[e3348fb73159a1b9]::check::wfcheck::check_fn_or_method
  21:     0x7fbe9b4466df - rustc_hir_analysis[e3348fb73159a1b9]::check::wfcheck::check_item_fn
  22:     0x7fbe9be2ad55 - rustc_hir_analysis[e3348fb73159a1b9]::check::check::check_item_type
  23:     0x7fbe9be1dff2 - rustc_hir_analysis[e3348fb73159a1b9]::check::wfcheck::check_well_formed
  24:     0x7fbe9be1dfd3 - rustc_query_impl[97c88ea65335a4b0]::query_vtables::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  25:     0x7fbe9be1d5fb - rustc_query_impl[97c88ea65335a4b0]::execution::try_execute_query::<rustc_data_structures[2f5d70850e22934]::vec_cache::VecCache<rustc_span[b1cb78db3bb7e75b]::def_id::LocalDefId, rustc_middle[a86b7b2986aebea0]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[a86b7b2986aebea0]::dep_graph::graph::DepNodeIndex>, false>
  26:     0x7fbe9be1d395 - rustc_query_impl[97c88ea65335a4b0]::query_vtables::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7fbe9be1a816 - rustc_hir_analysis[e3348fb73159a1b9]::check::wfcheck::check_type_wf
  28:     0x7fbe9be1a711 - rustc_query_impl[97c88ea65335a4b0]::query_vtables::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  29:     0x7fbe9be038c9 - rustc_query_impl[97c88ea65335a4b0]::execution::try_execute_query::<rustc_middle[a86b7b2986aebea0]::query::caches::SingleCache<rustc_middle[a86b7b2986aebea0]::query::erase::ErasedData<[u8; 1usize]>>, false>
  30:     0x7fbe9be036ad - rustc_query_impl[97c88ea65335a4b0]::query_vtables::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  31:     0x7fbe9b427fa4 - rustc_hir_analysis[e3348fb73159a1b9]::check_crate
  32:     0x7fbe9b98003c - rustc_interface[a3585332d3a3ff1e]::passes::analysis
  33:     0x7fbe9be051ca - rustc_query_impl[97c88ea65335a4b0]::execution::try_execute_query::<rustc_middle[a86b7b2986aebea0]::query::caches::SingleCache<rustc_middle[a86b7b2986aebea0]::query::erase::ErasedData<[u8; 0usize]>>, false>
  34:     0x7fbe9be04f6b - rustc_query_impl[97c88ea65335a4b0]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
  35:     0x7fbe9bf5a659 - rustc_interface[a3585332d3a3ff1e]::interface::run_compiler::<(), rustc_driver_impl[42633c3e3ce72fef]::run_compiler::{closure#0}>::{closure#2}
  36:     0x7fbe9bfad7c2 - std[30cbc90d73eb2f7]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a3585332d3a3ff1e]::util::run_in_thread_with_globals<rustc_interface[a3585332d3a3ff1e]::util::run_in_thread_pool_with_globals<rustc_interface[a3585332d3a3ff1e]::interface::run_compiler<(), rustc_driver_impl[42633c3e3ce72fef]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  37:     0x7fbe9bfad56d - <std[30cbc90d73eb2f7]::thread::lifecycle::spawn_unchecked<rustc_interface[a3585332d3a3ff1e]::util::run_in_thread_with_globals<rustc_interface[a3585332d3a3ff1e]::util::run_in_thread_pool_with_globals<rustc_interface[a3585332d3a3ff1e]::interface::run_compiler<(), rustc_driver_impl[42633c3e3ce72fef]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[37d23c544a63de81]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7fbe9bfb5ec7 - <std[30cbc90d73eb2f7]::sys::thread::unix::Thread>::new::thread_start
  39:     0x7fbe952980a2 - <unknown>
  40:     0x7fbe9532080c - <unknown>
  41:                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 (a4330234a 2026-09-01) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_well_formed] checking that `f` 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 5 previous errors; 2 warnings emitted

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

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-inherent_associated_types`#![feature(inherent_associated_types)]`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.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions