From f4d5c2a5de9a4ccbdda0bf63e5a626c5a251f760 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 8 Nov 2024 13:16:48 -0500 Subject: [PATCH] Check infinite recursion as soon as Display bound is known --- impl/src/fmt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/impl/src/fmt.rs b/impl/src/fmt.rs index 77b0dee..d2ab077 100644 --- a/impl/src/fmt.rs +++ b/impl/src/fmt.rs @@ -116,6 +116,7 @@ impl Display<'_> { Trait::Display } }; + infinite_recursive |= member == *"self" && bound == Trait::Display; if let Some(&field) = member_index.get(&member) { implied_bounds.insert((field, bound)); } @@ -128,7 +129,6 @@ impl Display<'_> { } out += &formatvar.to_string(); let local = formatvar.to_local(); - infinite_recursive |= member == *"self" && bound == Trait::Display; if macro_named_args.insert(member) { bindings.push((local, binding_value)); } else {