{"id":"b40f7b87b48844b0","repo":"rust-lang/rust","slug":"until-inherent-methods-are-supported","errorCode":null,"errorMessage":"until inherent methods are supported","messagePattern":"until inherent methods are supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_ast_lowering/src/delegation/mod.rs","lineNumber":416,"sourceCode":"                let ty = match generics.self_ty_propagation_kind {\n                    Some(hir::DelegationSelfTyPropagationKind::SelfParam) => {\n                        let self_param = generics.parent.generics.find_self_param();\n                        let path = self.create_generic_arg_path(self_param);\n                        let kind = hir::TyKind::Path(path);\n\n                        let ty = match ty {\n                            Some(ty) => hir::Ty { kind, ..ty.clone() },\n                            None => hir::Ty { kind, hir_id: self.next_id(), span },\n                        };\n\n                        Some(&*self.arena.alloc(ty))\n                    }\n                    _ => ty,\n                };\n\n                hir::QPath::Resolved(ty, self.arena.alloc(new_path))\n            }\n            hir::QPath::TypeRelative(..) => unreachable!(\"until inherent methods are supported\"),\n        };\n\n        if let Some(hir::DelegationSelfTyPropagationKind::SelfTy(id)) =\n            generics.self_ty_propagation_kind.as_mut()\n        {\n            *id = match new_path {\n                hir::QPath::Resolved(ty, _) => {\n                    ty.expect(\"must contain self type as `SelfTy` propagation kind is specified\")\n                }\n                hir::QPath::TypeRelative(ty, _) => ty,\n            }\n            .hir_id;\n        }\n\n        let callee_path = self.arena.alloc(self.mk_expr(hir::ExprKind::Path(new_path), span));\n        let args = self.arena.alloc_from_iter(args);\n        let call = self.mk_expr(hir::ExprKind::Call(callee_path, args), span);\n","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_ast_lowering/src/delegation/mod.rs#L398-L434","documentation":"unreachable! in delegation lowering when the resolved callee path is a hir::QPath::TypeRelative. The delegation feature currently only supports path-resolved (Resolved) callees — delegating through inherent methods on a type (TypeRelative) is intentionally unsupported, so this branch is marked unreachable until that support lands.","triggerScenarios":"Triggered with #![feature(delegation)] when a `reuse` item resolves to a type-relative path such as `reuse <Ty>::method` or `reuse Ty::method` where the lowering yields QPath::TypeRelative rather than QPath::Resolved. Indicates an unsupported (but syntactically accepted) delegation form reached lowering.","commonSituations":"Delegating through an inherent method or a type-relative path on nightly with `delegation`; this is a known unimplemented case. Users on stable never see it. Often hit when porting trait-delegation patterns that rely on inherent methods.","solutions":["Restructure the delegation so the callee resolves to a fully-qualified path: `reuse Trait::method as ...;` instead of an inherent or type-relative form.","If you need inherent-method delegation, track/follow the rust-lang/delegation RFC and wait for inherent-method support before using that form.","Replace `reuse` with an explicit forwarding fn in the meantime.","Report the use case on the delegation tracking issue so it informs the inherent-method support design."],"exampleFix":"// before (type-relative path — unsupported by delegation)\n#![feature(delegation)]\nimpl S { reuse S::inherent_method as alias; }\n// after — delegate via a trait path or write a forwarder manually\nimpl S {\n    fn alias(&self) { self.inherent_method() }\n}","handlingStrategy":"fallback","validationCode":"// QPath::TypeRelative in a delegation target is explicitly unsupported\n// (inherent methods on type-relative paths). Detect the shape statically:\nfn is_typ_relative(qpath: &hir::QPath<'_>) -> bool {\n    matches!(qpath, hir::QPath::TypeRelative(..))\n}\nif is_typ_relative(&delegation_qpath) {\n    return Err(\"delegation to an inherent method via a type-relative path is not yet supported\");\n}","typeGuard":"fn delegation_target_supported(qpath: &hir::QPath<'_>) -> bool {\n    matches!(qpath, hir::QPath::Resolved(..))\n}","tryCatchPattern":"let lowered = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| lower_delegation_qpath(qpath)));\nmatch lowered {\n    Ok(p) => p,\n    Err(_) => {\n        // Fallback: rewrite the delegation as an explicit method call.\n        return synthesize_explicit_method_call(&delegation);\n    }\n}","preventionTips":["Do not delegate to inherent methods reached through a `<Type as Trait>::method` or `Type::method` type-relative path; delegation currently only supports Resolved paths.","Route inherent-method delegation through a trait: define a trait with the method, implement it, and delegate to the trait method instead.","As a fallback, replace the `delegate` item with a hand-written forwarding fn whose body calls `self.inherent_method(...)` — functionally equivalent until inherent delegation stabilizes.","Track the nightly feature flag `delegation` and re-test the unsupported case each toolchain bump; the unreachable! may be lifted."],"tags":["rustc","ice","delegation","qpath","inherent-methods","nightly"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}