{"id":"b5131a9c43f5d0bb","repo":"rust-lang/rust","slug":"not-implemented-b5131a","errorCode":null,"errorMessage":"not implemented","messagePattern":"not implemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_codegen_gcc/src/consts.rs","lineNumber":96,"sourceCode":"            .global_set_readonly();\n        self.const_globals.borrow_mut().insert(cv, global_value);\n        global_value\n    }\n\n    fn codegen_static(&mut self, def_id: DefId) {\n        let attrs = self.tcx.codegen_fn_attrs(def_id);\n\n        let Ok((value, alloc)) = codegen_static_initializer(self, def_id) else {\n            // Error has already been reported\n            return;\n        };\n        let alloc = alloc.inner();\n\n        // boolean SSA values are i1, but they have to be stored in i8 slots,\n        // otherwise some LLVM optimization passes don't work as expected\n        let val_llty = self.val_ty(value);\n        if val_llty == self.type_i1() {\n            unimplemented!();\n        };\n\n        let is_thread_local = attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL);\n        let global = self.get_static_inner(def_id, val_llty);\n\n        #[cfg(feature = \"master\")]\n        if global.to_rvalue().get_type() != val_llty {\n            global.to_rvalue().set_type(val_llty);\n        }\n\n        // NOTE: Alignment from attributes has already been applied to the allocation.\n        set_global_alignment(self, global, alloc.align);\n\n        global.global_set_initializer_rvalue(value);\n\n        // As an optimization, all shared statics which do not have interior\n        // mutability are placed into read-only memory.\n        if alloc.mutability.is_not() {","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_codegen_gcc/src/consts.rs#L78-L114","documentation":"`codegen_static` (consts.rs:83-97) reads a static initializer; if the value's LLVM type is `i1` (`val_llty == self.type_i1()`) it hits `unimplemented!()` at line 96. The comment at lines 92-93 explains: boolean SSA values are i1 but must be stored in i8 slots, otherwise LLVM optimization passes misbehave. rustc_codegen_gcc has not implemented the i1→i8 widening for static initializers, so any `static` of type `bool` (or an enum/struct whose initializer lowers to an i1) aborts codegen.","triggerScenarios":"Declaring a `static` item whose initializer evaluates to a boolean value, e.g. `static FLAG: bool = true;`, or a static of a type whose backend representation is `i1`. Reached via `codegen_static(def_id)` → the `val_llty == self.type_i1()` branch at consts.rs:95-97.","commonSituations":"Compiling a crate that defines a top-level `static` boolean (very common in feature-flag/config code). Not a config/env issue — it is a genuine missing-feature in rustc_codegen_gcc. Worked around in user code by avoiding i1 statics.","solutions":["Avoid i1 statics in the crate being compiled: change `static X: bool = ...;` to `const X: bool = ...;` or store as `u8`/`u32` (e.g. `static X: u8 = 1;`) and convert at use sites.","If you cannot edit the source, patch rustc_codegen_gcc's `codegen_static` to widen i1 initializers to i8 before storage (mirror the LLVM backend's behavior).","Track/file the upstream issue: this is a known unimplemented branch, not a runtime config problem."],"exampleFix":"// before (user code triggering consts.rs:96)\nstatic ENABLED: bool = true;\n\n// after\nconst ENABLED: bool = true;\n// or, if a static is required:\nstatic ENABLED: u8 = 1;","handlingStrategy":"fallback","validationCode":"// consts.rs:96 -> unimplemented!() when a static's value lowers to i1 (bool SSA).\n// Widen bool statics to i8 in source, or route the crate through LLVM.\n// In source: prefer `static FLAG: u8 = 1;` over `static FLAG: bool = true;`.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid `static`/`const` items whose final SSA value is a bare bool; store as u8/i8 and convert at use sites.","If one crate hits this, compile just that crate with the LLVM backend and keep the gcc backend for the rest of the graph.","Track the upstream FIXME at consts.rs:92-97 - i1 static storage is unimplemented by design, so the fix is avoidance, not a patch."],"tags":["rustc-codegen-gcc","statics","bool","unimplemented","codegen"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}