Clean up formatvar identifier construction

This commit is contained in:
David Tolnay 2024-11-08 13:07:02 -05:00
parent 17fa0d290a
commit 24e7f87d0d
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82

View file

@ -90,12 +90,10 @@ impl Display<'_> {
}
_ => continue,
};
let mut formatvar = match &member {
MemberUnraw::Unnamed(index) => IdentUnraw::new(format_ident!("__field{}", index)),
MemberUnraw::Named(ident) => {
IdentUnraw::new(format_ident!("__field_{}", ident.to_string()))
}
};
let mut formatvar = IdentUnraw::new(match &member {
MemberUnraw::Unnamed(index) => format_ident!("__field{}", index),
MemberUnraw::Named(ident) => format_ident!("__field_{}", ident.to_string()),
});
while user_named_args.contains(&formatvar) {
formatvar = IdentUnraw::new(format_ident!("_{}", formatvar.to_string()));
}