{"id":"62ae11a4100c9aa9","repo":"rust-lang/rust","slug":"unexpected-const-kind","errorCode":null,"errorMessage":"unexpected const kind: {:?}","messagePattern":"unexpected const kind: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_next_trait_solver/src/solve/mod.rs","lineNumber":239,"sourceCode":"                // error in that case is unnecessary noise. This may change in the future once\n                // evaluation failures are allowed to impact selection, e.g. generic const\n                // expressions in impl headers or `where`-clauses.\n\n                // FIXME(generic_const_exprs): Implement handling for generic\n                // const expressions here.\n                if let Some(_normalized) = self.evaluate_const(param_env, alias_const)? {\n                    self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)\n                } else {\n                    self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)\n                }\n            }\n\n            // We can freely ICE here as:\n            // - `Param` gets replaced with a placeholder during canonicalization\n            // - `Bound` cannot exist as we don't have a binder around the self Type\n            // - `Expr` is part of `feature(generic_const_exprs)` and is not implemented yet\n            ty::ConstKind::Param(_) | ty::ConstKind::Bound(_, _) | ty::ConstKind::Expr(_) => {\n                panic!(\"unexpected const kind: {:?}\", ct)\n            }\n        }\n    }\n\n    #[instrument(level = \"trace\", skip(self), ret)]\n    fn compute_const_arg_has_type_goal(\n        &mut self,\n        goal: Goal<I, (I::Const, I::Ty)>,\n    ) -> QueryResultOrRerunNonErased<I> {\n        let (ct, ty) = goal.predicate;\n        let ct = self.structurally_normalize_const(goal.param_env, ct)?;\n\n        let ct_ty = match ct.kind() {\n            ty::ConstKind::Infer(_) => {\n                return self\n                    .evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)\n                    .map_err(Into::into);\n            }","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_next_trait_solver/src/solve/mod.rs#L221-L257","documentation":"compute_const_evaluatable_goal only accepts Alias(rigid)/Placeholder/Value/Error/Infer const kinds. Param, Bound, and Expr are all declared unreachable: Param is rewritten to Placeholder during canonicalization, Bound cannot exist without an enclosing binder around the self type, and Expr belongs to the unimplemented generic_const_exprs feature. Reaching this panic means one of those invariants was violated.","triggerScenarios":"Triggered in compute_const_evaluatable_goal (compiler/rustc_next_trait_solver/src/solve/mod.rs:202) when the const argument's kind is ConstKind::Param (canonicalization skipped), ConstKind::Bound (binder leaked into the self type), or ConstKind::Expr (generic_const_exprs const expression reached evaluation).","commonSituations":"ICE on const-generic code under -Znext-solver. Param case points to a canonicalization regression; Bound case to a binder-handling bug; Expr case to use of generic_const_exprs, which the new solver does not yet support.","solutions":["Report the ICE with the {:?} const printed by the panic and a minimal repro.","If the panic mentions an Expr const, stop using #![feature(generic_const_exprs)] under -Znext-solver (see error 299).","If it mentions a Param, audit canonicalization to confirm params are rewritten to placeholders before goal evaluation.","Disable -Znext-solver as a workaround."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Only a closed set of const kinds reaches the new solver safely. Reject everything else\n// at the source before it is handed to rustc.\nfn const_kind_allowed(k: &ConstKind) -> bool {\n    matches!(k, ConstKind::Param(_) | ConstKind::Value(_) | ConstKind::Error(_))\n}","typeGuard":"enum RigidConst { Value(i128), Param(&'static str) }\nimpl RigidConst { fn from_kind(k: &ConstKind) -> Option<Self> {\n    match k { ConstKind::Value(v) => Some(Self::Value(*v)), ConstKind::Param(p) => Some(Self::Param(p)), _ => None }\n}}","tryCatchPattern":"use std::panic::{catch_unwind, AssertUnwindSafe};\nlet c = catch_unwind(AssertUnwindSafe(|| classify_const(kind)));\nc.unwrap_or(ConstClassification::Error)","preventionTips":["Never construct const values via `ConstKind::Infer` or `ConstKind::Unevaluated` in macros or proc-macro output that feeds the new solver.","Treat every `const {}` block as a potential source of an unsupported kind; test it on stable first, then on next-solver.","Keep a deny-list of unsupported const kinds in your crate's docs so contributors don't reach for them."],"tags":["rust","rustc","trait-solver","ice","next-solver","const-generics","generic-const-exprs"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}