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

  1. Report at https://github.com/rust-lang/rust/issues with the `{kind:?}` from the panic.
  2. Disable `-Znext-solver` and `inherent_associated_types`.
  3. Isolate the IAT from other alias kinds and re-test.
  4. `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

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


AI-assisted analysis of rust-lang/rust@22057b88b0 (2026-08-03). Data as JSON: /data/errors/43c46ef50eae4f31.json. Report an issue: GitHub.