{"record":{"id":"04f8780ff1443e8b","repo":"rust-lang/rust","slug":"immutable-unnamed-local","errorCode":null,"errorMessage":"immutable unnamed local","messagePattern":"immutable unnamed local","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs","lineNumber":91,"sourceCode":"                access_place={:?}, span={:?}, the_place_err={:?}, error_access={:?}, location={:?},\\\n            )\",\n            access_place, span, the_place_err, error_access, location,\n        );\n\n        let mut err;\n        let item_msg;\n        let reason;\n        let mut opt_source = None;\n        let access_place_desc = self.describe_any_place(access_place.as_ref());\n        debug!(\"report_mutability_error: access_place_desc={:?}\", access_place_desc);\n\n        match the_place_err {\n            PlaceRef { local, projection: [] } => {\n                item_msg = access_place_desc;\n                if access_place.as_local().is_some() {\n                    reason = \", as it is not declared as mutable\".to_string();\n                } else {\n                    let name = self.local_name(local).expect(\"immutable unnamed local\");\n                    reason = format!(\", as `{name}` is not declared as mutable\");\n                }\n            }\n\n            PlaceRef {\n                local,\n                projection: [proj_base @ .., ProjectionElem::Field(upvar_index, _)],\n            } => {\n                debug_assert!(is_closure_like(\n                    Place::ty_from(local, proj_base, self.body, self.infcx.tcx).ty\n                ));\n\n                let imm_borrow_derefed = self.upvars[upvar_index.index()]\n                    .place\n                    .deref_tys()\n                    .any(|ty| matches!(ty.kind(), ty::Ref(.., hir::Mutability::Not)));\n\n                // If the place is immutable then:","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs#L73-L109","documentation":"mutability_errors.rs:91: while reporting a mutability error on a local, for a local that is not the direct access place, the diagnostic does self.local_name(local).expect(\"immutable unnamed local\"). The invariant: a local reachable here has a user-visible name. Compiler-generated temporaries or unnamed locals are not expected on this path.","triggerScenarios":"Borrowck builds a mutability diagnostic for an unnamed/compiler-generated local that reaches the non-access-place branch, where local_name() returns None.","commonSituations":"An ICE inside borrowck's diagnostic emitter, typically a regression when reporting `cannot assign`-style errors for synthetic temporaries; not triggered by ordinary source.","solutions":["File a rustc ICE with the minimized code that produces the mutability error.","Rewrite the expression so the offending place is a named binding (bind the temporary to a let).","Bisect across nightlies with cargo bisect-rustc.","Try stable vs nightly to confirm a regression."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat as a borrowck diagnostic ICE; report with the minimized code that produces the mutability error.","Bind compiler-generated temporaries to a named `let` to give the place a user-visible name.","Bisect with cargo bisect-rustc and compare stable vs nightly.","Pin to a known-good toolchain until fixed."],"tags":["rust","borrowck","diagnostics","ice"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}