{"id":"43c46ef50eae4f31","repo":"rust-lang/rust","slug":"expected-inherent-alias-found-kind","errorCode":null,"errorMessage":"expected inherent alias, found {kind:?}","messagePattern":"expected inherent alias, found (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_next_trait_solver/src/solve/project_goals/inherent.rs","lineNumber":76,"sourceCode":"                let inherent = cx.type_of(def_id.into()).instantiate(cx, inherent_args);\n                let inherent = self.normalize(GoalSource::Misc, goal.param_env, inherent)?;\n                inherent.into()\n            }\n            ty::AliasTermKind::InherentConst { def_id } if cx.is_type_const(def_id.into()) => {\n                let inherent = cx.const_of_item(def_id.into()).instantiate(cx, inherent_args);\n                let inherent = self.normalize(GoalSource::Misc, goal.param_env, inherent)?;\n                inherent.into()\n            }\n            ty::AliasTermKind::InherentConst { .. } => {\n                // FIXME(gca): This is dead code at the moment. It should eventually call\n                // self.evaluate_const like projected consts do in consider_impl_candidate in\n                // normalizes_to/mod.rs. However, how generic args are represented for IACs is up in\n                // the air right now.\n                // Will self.evaluate_const eventually take the inherent_args or the impl_args form\n                // of args? It might be either.\n                panic!(\"References to inherent associated consts should have been blocked\");\n            }\n            kind => panic!(\"expected inherent alias, found {kind:?}\"),\n        };\n\n        self.push_const_arg_has_type_goal(\n            goal.param_env,\n            goal.predicate.projection_term,\n            normalized,\n        )?;\n        self.eq(goal.param_env, goal.predicate.term, normalized)?;\n        self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)\n    }\n}\n","sourceCodeStart":58,"sourceCodeEnd":88,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_next_trait_solver/src/solve/project_goals/inherent.rs#L58-L88","documentation":"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.","triggerScenarios":"A projection term whose `AliasTermKind` is not `InherentTy`/`InherentConst` is dispatched to `normalize_inherent_associated_term`, under `-Znext-solver` with `inherent_associated_types` enabled.","commonSituations":"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.","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`."],"exampleFix":"// before — IAT alongside opaque/weak aliases confusing dispatch\ntype Weak = Foo; // weak alias\nimpl T { type Proj = Weak; } // inherent alias\n// after — keep IAT self-contained\nimpl T { type Proj = Foo; }","handlingStrategy":"validation","validationCode":"// The solver expected an inherent alias but found a different kind.\n// Validate that alias types passed to it are truly inherent aliases\n// (defined on an impl block of a concrete type, not a trait).\nstruct Wrap<T>(T);\nimpl Wrap<i32> {\n    type Item = i32; // inherent associated type (unstable)\n}\n// GOOD: <Wrap<i32>>::Item\n// BAD:  passing a trait alias where an inherent alias is expected\nfn check_inherent_alias<T>() -> bool { false }","typeGuard":"// Distinguish inherent aliases from trait aliases at the source level.\n// Inherent aliases are defined in `impl ConcreteType` blocks,\n// trait aliases are defined in `trait Foo { type Bar; }`.\n// Always quote the concrete impl block when projecting:\ntype Good = <Wrap<i32> as /* nothing */>::Item;\n// If the compiler cannot find the inherent alias, add the impl block\n// to the same crate or enable the feature flag.","tryCatchPattern":null,"preventionTips":["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."],"tags":["rustc","trait-solver","next-solver","ice","inherent-associated-types","alias-dispatch"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}