{"record":{"id":"dca2127bad253c97","repo":"rust-lang/rust","slug":"coroutine-lowered-from-gen-fn-should-be-in-fn","errorCode":null,"errorMessage":"coroutine lowered from gen fn should be in fn","messagePattern":"coroutine lowered from gen fn should be in fn","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_borrowck/src/diagnostics/region_name.rs","lineNumber":871,"sourceCode":"                    )) => \" of gen block\",\n\n                    hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(\n                        hir::CoroutineDesugaring::Gen,\n                        hir::CoroutineSource::Closure,\n                    ))\n                    | hir::ClosureKind::CoroutineClosure(hir::CoroutineDesugaring::Gen) => {\n                        \" of gen closure\"\n                    }\n\n                    hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(\n                        hir::CoroutineDesugaring::Gen,\n                        hir::CoroutineSource::Fn,\n                    )) => {\n                        let parent_item =\n                            tcx.hir_node_by_def_id(tcx.hir_get_parent_item(mir_hir_id).def_id);\n                        let output = &parent_item\n                            .fn_decl()\n                            .expect(\"coroutine lowered from gen fn should be in fn\")\n                            .output;\n                        span = output.span();\n                        \" of gen function\"\n                    }\n\n                    hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(\n                        hir::CoroutineDesugaring::AsyncGen,\n                        hir::CoroutineSource::Block,\n                    )) => \" of async gen block\",\n\n                    hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(\n                        hir::CoroutineDesugaring::AsyncGen,\n                        hir::CoroutineSource::Closure,\n                    ))\n                    | hir::ClosureKind::CoroutineClosure(hir::CoroutineDesugaring::AsyncGen) => {\n                        \" of async gen closure\"\n                    }\n","sourceCodeStart":853,"sourceCodeEnd":889,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_borrowck/src/diagnostics/region_name.rs#L853-L889","documentation":"region_name.rs:871: the gen-fn analogue of error 258. For a coroutine desugared from a `gen fn` (CoroutineDesugaring::Gen, CoroutineSource::Fn), the diagnostic does parent_item.fn_decl().expect(\"coroutine lowered from gen fn should be in fn\"). The invariant: a gen-fn coroutine's parent is always an fn with a declaration.","triggerScenarios":"Region-naming for a borrowck error inside a gen fn (unstable gen blocks/fns feature) where the parent item unexpectedly lacks a fn_decl.","commonSituations":"A nightly ICE with the unstable gen-fn feature when reporting a lifetime/borrow error inside the generator.","solutions":["File a rustc ICE with the minimized gen fn repro (note the unstable feature).","Avoid the gen-fn form that triggers the region-naming path (rewrite as a gen block or iterator).","Bisect with cargo bisect-rustc across nightlies.","Pin to a known-good nightly."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat as a borrowck diagnostic ICE on the unstable gen-fn feature; report with a minimized repro.","Avoid gen-fn forms that trigger region-naming; rewrite as gen blocks or iterators.","Bisect with cargo bisect-rustc across nightlies.","Pin to a known-good nightly when using gen fn."],"tags":["rust","borrowck","gen","coroutine","ice"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}