Skip to content

Commit

Permalink
Touch up PR 258
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 19, 2023
1 parent 4850c6f commit c9fe739
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
17 changes: 11 additions & 6 deletions impl/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ fn impl_struct(input: Struct) -> TokenStream {
error_inferred_bounds.insert(only_field.ty, quote!(std::error::Error));
}
let member = &only_field.member;
Some(quote_spanned! {
transparent_attr.span => std::error::Error::source(self.#member.as_dyn_error())
Some(quote_spanned! {transparent_attr.span=>
std::error::Error::source(self.#member.as_dyn_error())
})
} else if let Some(source_field) = input.source_field() {
let source = &source_field.member;
Expand All @@ -43,8 +43,9 @@ fn impl_struct(input: Struct) -> TokenStream {
} else {
None
};
let dyn_error =
quote_spanned!(source_field.source_span() => self.#source #asref.as_dyn_error());
let dyn_error = quote_spanned! {source_field.source_span()=>
self.#source #asref.as_dyn_error()
};
Some(quote! {
::core::option::Option::Some(#dyn_error)
})
Expand Down Expand Up @@ -200,7 +201,9 @@ fn impl_enum(input: Enum) -> TokenStream {
error_inferred_bounds.insert(only_field.ty, quote!(std::error::Error));
}
let member = &only_field.member;
let source = quote_spanned!(transparent_attr.span => std::error::Error::source(transparent.as_dyn_error()));
let source = quote_spanned! {transparent_attr.span=>
std::error::Error::source(transparent.as_dyn_error())
};
quote! {
#ty::#ident {#member: transparent} => #source,
}
Expand All @@ -216,7 +219,9 @@ fn impl_enum(input: Enum) -> TokenStream {
None
};
let varsource = quote!(source);
let dyn_error = quote_spanned!(source_field.source_span()=> #varsource #asref.as_dyn_error());
let dyn_error = quote_spanned! {source_field.source_span()=>
#varsource #asref.as_dyn_error()
};
quote! {
#ty::#ident {#source: #varsource, ..} => ::core::option::Option::Some(#dyn_error),
}
Expand Down
3 changes: 2 additions & 1 deletion impl/src/prop.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::ast::{Enum, Field, Struct, Variant};
use proc_macro2::Span;
use syn::{spanned::Spanned, Member, Type};
use syn::spanned::Spanned;
use syn::{Member, Type};

impl Struct<'_> {
pub(crate) fn from_field(&self) -> Option<&Field> {
Expand Down

0 comments on commit c9fe739

Please sign in to comment.