diff --git a/rinja_derive/src/generator.rs b/rinja_derive/src/generator.rs index b0069268..f7124c24 100644 --- a/rinja_derive/src/generator.rs +++ b/rinja_derive/src/generator.rs @@ -3007,11 +3007,13 @@ fn is_copyable_within_op(expr: &Expr<'_>, within_op: bool) -> bool { } /// Returns `true` if this is an `Attr` where the `obj` is `"self"`. -pub(crate) fn is_attr_self(expr: &Expr<'_>) -> bool { - match expr { - Expr::Attr(obj, _) if matches!(***obj, Expr::Var("self")) => true, - Expr::Attr(obj, _) if matches!(***obj, Expr::Attr(..)) => is_attr_self(obj), - _ => false, +pub(crate) fn is_attr_self(mut expr: &Expr<'_>) -> bool { + loop { + match expr { + Expr::Attr(obj, _) if matches!(***obj, Expr::Var("self")) => return true, + Expr::Attr(obj, _) if matches!(***obj, Expr::Attr(..)) => expr = obj, + _ => return false, + } } }