Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display: avoid using formatter #36

Merged
merged 1 commit into from
Oct 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, _thiserror_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, _thiserror_formatter)
});
} else {
tokens.extend(quote! {
write!(formatter, #fmt #args)
write!(_thiserror_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, _thiserror_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, _thiserror_formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
#[allow(unused_variables)]
match #void_deref self {
#(#arms,)*
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
//! }
//! #
//! # impl Display for MyError {
//! # fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
//! # fn fmt(&self, _thiserror_formatter: &mut fmt::Formatter) -> fmt::Result {
//! # unimplemented!()
//! # }
//! # }
Expand Down