{"record":{"id":"c8ace451f9978498","repo":"rust-lang/rust","slug":"self-generic-param-is-not-found-while-expected","errorCode":null,"errorMessage":"`Self` generic param is not found while expected","messagePattern":"`Self` generic param is not found while expected","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_ast_lowering/src/delegation/generics.rs","lineNumber":219,"sourceCode":"\n    pub(super) fn is_trait_impl(&self) -> bool {\n        match self {\n            HirOrTyGenerics::Ty(ty) => ty.trait_impl,\n            HirOrTyGenerics::Hir(hir) => hir.trait_impl,\n        }\n    }\n\n    pub(super) fn find_self_param(&self) -> &'hir hir::GenericParam<'hir> {\n        match self {\n            HirOrTyGenerics::Ty(_) => {\n                bug!(\"accessed ty-level generics while searching for uplifted `Self` param\")\n            }\n            HirOrTyGenerics::Hir(hir) => hir\n                .data\n                .params\n                .iter()\n                .find(|p| p.name.ident().name == kw::SelfUpper)\n                .expect(\"`Self` generic param is not found while expected\"),\n        }\n    }\n\n    pub(crate) fn pos(&self) -> GenericsPosition {\n        match self {\n            HirOrTyGenerics::Ty(ty) => ty.pos,\n            HirOrTyGenerics::Hir(hir) => hir.pos,\n        }\n    }\n}\n\nimpl<'hir> GenericsGenerationResult<'hir> {\n    fn new(generics: DelegationGenerics<TyGenerics<'hir>>) -> GenericsGenerationResult<'hir> {\n        GenericsGenerationResult {\n            generics: HirOrTyGenerics::Ty(generics),\n            args_segment_id: HirId::INVALID,\n            use_for_sig_inheritance: false,\n        }","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_ast_lowering/src/delegation/generics.rs#L201-L237","documentation":"Internal delegation-feature invariant (delegation/generics.rs:219). find_self_param() searches the HIR generic params for one named SelfUpper and expects to find it. It only runs when the delegation resolver decided a Self param should be generated (free-context delegation into a trait). A panic means the expected uplifted Self param is missing from the parent's HIR generics.","triggerScenarios":"Using the unstable `reuse`/delegation syntax where a free-standing delegate targets a trait method and generate_self is true, but the lowered parent generics lack a Self param.","commonSituations":"Experimental nightly code using fn delegation; a compiler bug in the delegation lowering pass; mixing delegation with unusual generic contexts.","solutions":["File a rustc ICE with the minimized delegation repro (this is an unstable feature).","Avoid the delegation syntax that targets trait methods from free context; delegate to inherent/method fns instead.","Try a different nightly; bisect with cargo bisect-rustc.","Remove explicit generic args on the delegation path to simplify resolution."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["This is an ICE in the unstable delegation feature; avoid delegating to trait methods from free context.","File a rustc issue with the minimized delegation repro.","Bisect with cargo bisect-rustc and pin to a working nightly.","Prefer delegating to inherent methods until the feature stabilizes."],"tags":["rust","delegation","compiler-internal","ice"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}