{"record":{"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/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_public/src/unstable/convert/stable/mir.rs#L903-L939","documentation":"Produced by the `Stable` impl for `mir::interpret::ErrorHandled` (mir.rs:921), which converts rustc's internal constant-evaluation error type into a stable `Error` by formatting it with Debug. `ErrorHandled` represents any error surfaced during const evaluation — either `TooGeneric` (the constant depends on parameters that are not yet known) or `Reported` (a concrete evaluation error already emitted as a diagnostic).","triggerScenarios":"Any rustc_public query that triggers constant evaluation — e.g. `try_const_eval`, `eval_initializer` on a static, or reading an evaluated const in MIR — when rustc records an `ErrorHandled` rather than a value.","commonSituations":"Reading the initializer of a static that fails const evaluation; evaluating an intrinsic that cannot be const-folded; encountering a constant that depends on generic parameters still in scope (TooGeneric) inside a query that expected a monomorphized value.","solutions":["Inspect the formatted message: `TooGeneric` means you must monomorphize/instantiate before evaluating; `Reported(...)` means look at the upstream rustc diagnostic for the root cause.","Guard evaluation behind a check that the relevant item is fully monomorphized.","Fix the source of the const-eval error (e.g. forbidden operation in a const context) shown in the compiler diagnostic."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// ErrorHandled is a propagated error; handle at the query boundary.\nlet alloc = match static_def.eval_initializer() {\n    Ok(a) => a,\n    Err(e) => {\n        // e is \"{self:?}\" of ErrorHandled; check for TooGeneric vs Reported\n        if e.to_string().contains(\"TooGeneric\") {\n            // needs full monomorphization before eval\n        }\n        return Err(e);\n    }\n};","preventionTips":["Ensure items are fully monomorphized before const-evaluating them.","Treat any Reported const-eval error as a real upstream diagnostic to fix."],"tags":["rustc-public","const-eval","mir","error-handling"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}