{"id":"b1cd1c3895102aa2","repo":"rust-lang/rust","slug":"unexpected-orig-value-ct","errorCode":null,"errorMessage":"unexpected orig_value: {ct:?}","messagePattern":"unexpected orig_value: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs","lineNumber":871,"sourceCode":"    ) -> GoalStalledOn<I> {\n        // Remove the canonicalized universal vars, since we only care about stalled existentials.\n        let mut sub_roots = ThinVec::new();\n        stalled_vars.retain(|arg| match arg.kind() {\n            // Lifetimes can never stall goals.\n            ty::GenericArgKind::Lifetime(_) => false,\n            ty::GenericArgKind::Type(ty) => match ty.kind() {\n                ty::Infer(ty::TyVar(vid)) => {\n                    sub_roots.push(self.delegate.sub_unification_table_root_var(vid));\n                    true\n                }\n                ty::Infer(_) => true,\n                ty::Param(_) | ty::Placeholder(_) => false,\n                _ => unreachable!(\"unexpected orig_value: {ty:?}\"),\n            },\n            ty::GenericArgKind::Const(ct) => match ct.kind() {\n                ty::ConstKind::Infer(_) => true,\n                ty::ConstKind::Param(_) | ty::ConstKind::Placeholder(_) => false,\n                _ => unreachable!(\"unexpected orig_value: {ct:?}\"),\n            },\n        });\n\n        GoalStalledOn {\n            stalled_vars,\n            sub_roots,\n            stalled_certainty: certainty,\n            opaques: GoalStalledOnOpaques::Yes {\n                num_opaques_in_storage: canonical_goal\n                    .canonical\n                    .value\n                    .predefined_opaques_in_body\n                    .len(),\n                previously_succeeded_in_erased,\n            },\n        }\n    }\n","sourceCodeStart":853,"sourceCodeEnd":889,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs#L853-L889","documentation":"Const-typed counterpart of the orig_value invariant in EvalCtxt::build_stalled_on. When categorizing stalled const generic args, the only legal ConstKinds are Infer (stalls), and Param/Placeholder (no-op). Any other ConstKind (Value, Alias, Error, Bound, Expr) reaching this point means an unexpected const survived into the stalled-variable set, breaking the assumption that stalled consts are inference variables.","triggerScenarios":"Hit when build_stalled_on in compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:868 processes a GenericArgKind::Const whose kind is not Infer/Param/Placeholder — e.g. an unevaluated Alias const or a Value const improperly retained in stalled_vars.","commonSituations":"ICE triggered while solving const-dependent goals (array lengths, const generics) under -Znext-solver. Usually a compiler regression in const handling or canonicalization rather than a user-code defect.","solutions":["Report the ICE with the {ct:?} const printed by the panic message.","Reduce the test case to a minimal const-generic example and attach it to the rustc issue.","Disable -Znext-solver to unblock the build.","If developing the solver, check that const orig_values are normalized/evaluated before stalled-vars are computed so only Infer consts remain."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Reject unevaluated/bare const values before they reach the solver.\nfn const_arg_is_evaluable(ct: &ConstExpr) -> bool {\n    matches!(ct, ConstExpr::Lit(_) | ConstExpr::Path(_))\n}\n// use in a build.rs / lint pass over generic arguments","typeGuard":"trait RigidConstArg { fn is_rigid(&self) -> bool; }\nimpl RigidConstArg for ConstValue {\n    fn is_rigid(&self) -> bool { !matches!(self.kind, ConstKind::Unevaluated(_) | ConstKind::Infer(_)) }\n}","tryCatchPattern":"use std::panic::{catch_unwind, AssertUnwindSafe};\nlet v = catch_unwind(AssertUnwindSafe(|| compute_const(ct)));\nv.unwrap_or_else(|_| ConstValue::zero_sized_fallback())","preventionTips":["Materialize every const generic argument to a concrete value at the call site — never pass an unevaluated const expression.","Avoid `const` generics whose value depends on another generic parameter (the classic `orig_value` mismatch source).","Add a unit test that builds the crate with `-Zminimal-versions` to catch const-shape regressions."],"tags":["rust","rustc","trait-solver","ice","next-solver","const-generics","canonicalization"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}