rust-lang/rust · error

must contain self type as `SelfTy` propagation kind is…

Error message

must contain self type as `SelfTy` propagation kind is specified

What it means

delegation/mod.rs:425: when self_ty_propagation_kind is SelfTy(id) and the lowered callee path is a QPath::Resolved(ty, _), the code expects ty to be Some via .expect("must contain self type as `SelfTy` propagation kind is specified"). The invariant: a propagation kind of SelfTy is only set when a self type was attached to the resolved path.

Solutions

  1. File a rustc ICE with the minimized delegation repro.
  2. Avoid delegation contexts that trigger SelfTy propagation (e.g. trait-impl delegation with return mapping).
  3. Try an alternate nightly and bisect.
  4. Simplify the delegation callee path to a plain inherent method.
Defensive patterns

Strategy: fallback

Prevention

When it happens

Trigger: Delegation lowering sets DelegationSelfTyPropagationKind::SelfTy on a resolved QPath whose type slot is None, an internal inconsistency in the delegation path lowering.

Common situations: Unstable fn-delegation code paths; a compiler bug where the propagation kind and the attached self type disagree.

Related errors


AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10). Data as JSON: /api/errors/dad17b5fc54551c7. Report an issue: GitHub.

Appendix: source

Thrown at compiler/rustc_ast_lowering/src/delegation/mod.rs:425

                            None => hir::Ty { kind, hir_id: self.next_id(), span },
                        };

                        Some(&*self.arena.alloc(ty))
                    }
                    _ => ty,
                };

                hir::QPath::Resolved(ty, self.arena.alloc(new_path))
            }
            hir::QPath::TypeRelative(..) => unreachable!("until inherent methods are supported"),
        };

        if let Some(hir::DelegationSelfTyPropagationKind::SelfTy(id)) =
            generics.self_ty_propagation_kind.as_mut()
        {
            *id = match new_path {
                hir::QPath::Resolved(ty, _) => {
                    ty.expect("must contain self type as `SelfTy` propagation kind is specified")
                }
                hir::QPath::TypeRelative(ty, _) => ty,
            }
            .hir_id;
        }

        let callee_path = self.arena.alloc(self.mk_expr(hir::ExprKind::Path(new_path), span));
        let args = self.arena.alloc_from_iter(args);
        let call = self.mk_expr(hir::ExprKind::Call(callee_path, args), span);

        let expr = if res.sig_mapping.map_return {
            let res = Res::SelfTyAlias {
                alias_to: res.parent.to_def_id(),
                is_trait_impl: self.tcx.def_kind(res.parent) == DefKind::Impl { of_trait: true },
            };

            let ident = Ident::new(kw::SelfUpper, span);
            let path = self.create_resolved_qpath(res, ident, span);

View on GitHub (pinned to 7088e4b63a)