Check infinite recursion as soon as Display bound is known

This commit is contained in:
David Tolnay 2024-11-08 13:16:48 -05:00
parent 8a77dea3ae
commit f4d5c2a5de
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82

View file

@ -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 {