From c9fe739272dee48b0dedc6114780e1ca63c42ad3 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 19 Oct 2023 10:37:00 -0700 Subject: [PATCH] Touch up PR 258 --- impl/src/expand.rs | 17 +++++++++++------ impl/src/prop.rs | 3 ++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/impl/src/expand.rs b/impl/src/expand.rs index 80a39789..394aafbc 100644 --- a/impl/src/expand.rs +++ b/impl/src/expand.rs @@ -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; @@ -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) }) @@ -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, } @@ -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), } diff --git a/impl/src/prop.rs b/impl/src/prop.rs index 62f269b3..e4d2f188 100644 --- a/impl/src/prop.rs +++ b/impl/src/prop.rs @@ -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> {