rust-lang/rust · critical
expected inherent alias, found {kind:?}
Error message
expected inherent alias, found {kind:?} What it means
Same function as 324 (`normalize_inherent_associated_term`), but this is the catch-all arm: `inherent.kind` matched neither `InherentTy` nor `InherentConst`. The `kind => panic!("expected inherent alias, found {kind:?}")` (line 76) fires when the dispatcher sent a non-inherent alias term (e.g. ProjectionTy, FreeTy, OpaqueTy, Weak) to the inherent-alias handler — a dispatch/routing bug in the solver.
Source
Thrown at compiler/rustc_next_trait_solver/src/solve/project_goals/inherent.rs:76
let inherent = cx.type_of(def_id.into()).instantiate(cx, inherent_args);
let inherent = self.normalize(GoalSource::Misc, goal.param_env, inherent)?;
inherent.into()
}
ty::AliasTermKind::InherentConst { def_id } if cx.is_type_const(def_id.into()) => {
let inherent = cx.const_of_item(def_id.into()).instantiate(cx, inherent_args);
let inherent = self.normalize(GoalSource::Misc, goal.param_env, inherent)?;
inherent.into()
}
ty::AliasTermKind::InherentConst { .. } => {
// FIXME(gca): This is dead code at the moment. It should eventually call
// self.evaluate_const like projected consts do in consider_impl_candidate in
// normalizes_to/mod.rs. However, how generic args are represented for IACs is up in
// the air right now.
// Will self.evaluate_const eventually take the inherent_args or the impl_args form
// of args? It might be either.
panic!("References to inherent associated consts should have been blocked");
}
kind => panic!("expected inherent alias, found {kind:?}"),
};
self.push_const_arg_has_type_goal(
goal.param_env,
goal.predicate.projection_term,
normalized,
)?;
self.eq(goal.param_env, goal.predicate.term, normalized)?;
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
}
}
View on GitHub (pinned to 22057b88b0)
Solutions
- Report at https://github.com/rust-lang/rust/issues with the `{kind:?}` from the panic.
- Disable `-Znext-solver` and `inherent_associated_types`.
- Isolate the IAT from other alias kinds and re-test.
- `rustup update nightly`.
Example fix
// before — IAT alongside opaque/weak aliases confusing dispatch
type Weak = Foo; // weak alias
impl T { type Proj = Weak; } // inherent alias
// after — keep IAT self-contained
impl T { type Proj = Foo; } Defensive patterns
Strategy: validation
Validate before calling
// The solver expected an inherent alias but found a different kind.
// Validate that alias types passed to it are truly inherent aliases
// (defined on an impl block of a concrete type, not a trait).
struct Wrap<T>(T);
impl Wrap<i32> {
type Item = i32; // inherent associated type (unstable)
}
// GOOD: <Wrap<i32>>::Item
// BAD: passing a trait alias where an inherent alias is expected
fn check_inherent_alias<T>() -> bool { false } Type guard
// Distinguish inherent aliases from trait aliases at the source level.
// Inherent aliases are defined in `impl ConcreteType` blocks,
// trait aliases are defined in `trait Foo { type Bar; }`.
// Always quote the concrete impl block when projecting:
type Good = <Wrap<i32> as /* nothing */>::Item;
// If the compiler cannot find the inherent alias, add the impl block
// to the same crate or enable the feature flag. Prevention
- Keep inherent associated types inside the impl block of a concrete (non-trait) type; do not mix with trait aliases.
- Avoid cross-crate references to inherent aliases while the feature is unstable.
- Run `cargo +nightly check` after every change to impl blocks that define inherent aliases.
When it happens
Trigger: A projection term whose `AliasTermKind` is not `InherentTy`/`InherentConst` is dispatched to `normalize_inherent_associated_term`, under `-Znext-solver` with `inherent_associated_types` enabled.
Common situations: Nightly IAT users after changes to alias-kind dispatch, or when mixing IATs with other alias kinds (opaque, weak, free) in the same crate, confusing the routing.
Related errors
- References to inherent associated consts should have been bl
- we never retry stalled queries if the parent was erased
- this never happens at the root, we're never in erased mode h
- unexpected orig_value: {ty:?}
- unexpected orig_value: {ct:?}
AI-assisted analysis of rust-lang/rust@22057b88b0 (2026-08-03).
Data as JSON: /data/errors/43c46ef50eae4f31.json.
Report an issue: GitHub.