{"id":"7ea0919e4689b84e","repo":"rust-lang/rust","slug":"self","errorCode":null,"errorMessage":"{self:?}","messagePattern":"\\{self:\\?\\}","errorType":"exception","errorClass":"bridge::Error","httpStatus":null,"severity":"error","filePath":"compiler/rustc_public/src/unstable/convert/stable/mir.rs","lineNumber":921,"sourceCode":"                let ty = ty.stable(tables, cx);\n                MirConst::new(ConstantKind::ZeroSized, ty, id)\n            }\n            mir::Const::Val(val, ty) => {\n                let ty = cx.lift(ty);\n                let val = cx.lift(val);\n                let kind = ConstantKind::Allocated(alloc::new_allocation(ty, val, tables, cx));\n                let ty = ty.stable(tables, cx);\n                MirConst::new(kind, ty, id)\n            }\n        }\n    }\n}\n\nimpl<'tcx> Stable<'tcx> for mir::interpret::ErrorHandled {\n    type T = Error;\n\n    fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {\n        bridge::Error::new(format!(\"{self:?}\"))\n    }\n}\n\nimpl<'tcx> Stable<'tcx> for MonoItem<'tcx> {\n    type T = crate::mir::mono::MonoItem;\n\n    fn stable<'cx>(\n        &self,\n        tables: &mut Tables<'cx, BridgeTys>,\n        cx: &CompilerCtxt<'cx, BridgeTys>,\n    ) -> Self::T {\n        use crate::mir::mono::MonoItem as StableMonoItem;\n        match self {\n            MonoItem::Fn(instance) => StableMonoItem::Fn(instance.stable(tables, cx)),\n            MonoItem::Static(def_id) => StableMonoItem::Static(tables.static_def(*def_id)),\n            MonoItem::GlobalAsm(item_id) => StableMonoItem::GlobalAsm(opaque(item_id)),\n        }\n    }","sourceCodeStart":903,"sourceCodeEnd":939,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_public/src/unstable/convert/stable/mir.rs#L903-L939","documentation":"Produced by the `Stable` impl for rustc's `mir::interpret::ErrorHandled` in compiler/rustc_public/src/unstable/convert/stable/mir.rs:921. When a MIR constant failed to evaluate inside the compiler (a `TooGeneric`, `Reported`, or other const-eval error), rustc_public surfaces it as an opaque `Error` whose message is the debug rendering of the original error. This is a pass-through of an internal constant-evaluation failure rather than a rustc_public bug.","triggerScenarios":"Stabilizing MIR that contains a constant which the compiler could not evaluate under the current typing environment: a `TooGeneric` const, a const that errored and was `Reported` to the user, or an opaque evaluation failure. Walking a function body and converting each `mir::Const`/`ErrorHandled` through the stable layer.","commonSituations":"Inspecting generic crates where constants depend on unconstrained generic parameters. Reading MIR for items whose const-eval produced errors already reported by rustc. Using a typing environment that is not fully monomorphized, so constants cannot be reduced to a value.","solutions":["Provide a fully monomorphized typing environment before stabilizing MIR so generic constants can be evaluated.","Treat `ErrorHandled` as expected for generic/non-mono code and skip or record the item rather than failing.","Filter out items whose constants are `TooGeneric` before entering the stable conversion path."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// ErrorHandled is opaque by design: it surfaces during const evaluation\n// (TooGeneric / Reported / InspectionOverflow) and the Debug string is the\n// only payload. Catch, classify heuristically, and degrade gracefully.\nfn eval_or_fallback(c: &MirConst) -> Allocation {\n    match try_eval(c) {\n        Ok(alloc) => alloc,\n        Err(e) => {\n            let msg = e.to_string();\n            if msg.contains(\"TooGeneric\") {\n                // provide monomorphized args / a concrete typing env, then retry\n                return default_allocation(c.ty());\n            }\n            if msg.contains(\"Reported\") || msg.contains(\"Overflow\") {\n                // upstream const-eval reported an error; skip this constant\n                return default_allocation(c.ty());\n            }\n            return default_allocation(c.ty());\n        }\n    }\n}","preventionTips":["This error is a propagated compiler-internal `ErrorHandled`; you cannot pre-validate it away. Always handle the `Result` and never `.unwrap()` on const evaluation.","Ensure the surrounding context is fully monomorphized and that any `GenericArgs` are concrete — `TooGeneric` is the most common trigger.","Classify by substring on the Debug message (`TooGeneric`, `Reported`, `Overflow`) to choose between retry-with-args and skip; keep a fallback allocation keyed on the const's type.","Do not surface the raw Debug string to end users; map it to an actionable message in your tool's vocabulary."],"tags":["rust","mir","const-eval","stable-conversion"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}