Skip to content

Commit

Permalink
Merge pull request 36 from mathstuf:formatter-name-collision
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 27, 2019
2 parents b2b3bae + 5ae5b4e commit 12404e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions impl/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,16 @@ impl ToTokens for Display<'_> {
if self.was_shorthand && fmt.value() == "{}" {
let arg = args.clone().into_iter().nth(1).unwrap();
tokens.extend(quote! {
std::fmt::Display::fmt(#arg, formatter)
std::fmt::Display::fmt(#arg, __formatter)
});
} else if self.was_shorthand && fmt.value() == "{:?}" {
let arg = args.clone().into_iter().nth(1).unwrap();
tokens.extend(quote! {
std::fmt::Debug::fmt(#arg, formatter)
std::fmt::Debug::fmt(#arg, __formatter)
});
} else {
tokens.extend(quote! {
write!(formatter, #fmt #args)
write!(__formatter, #fmt #args)
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions impl/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn impl_struct(input: Struct) -> TokenStream {
let pat = fields_pat(&input.fields);
quote! {
impl #impl_generics std::fmt::Display for #ty #ty_generics #where_clause {
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
fn fmt(&self, __formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
#[allow(unused_variables)]
let Self #pat = self;
#display
Expand Down Expand Up @@ -230,7 +230,7 @@ fn impl_enum(input: Enum) -> TokenStream {
});
Some(quote! {
impl #impl_generics std::fmt::Display for #ty #ty_generics #where_clause {
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
fn fmt(&self, __formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
#[allow(unused_variables)]
match #void_deref self {
#(#arms,)*
Expand Down

0 comments on commit 12404e4

Please sign in to comment.