Eliminate unneeded use of Spanned trait on single tokens

This commit is contained in:
David Tolnay 2023-03-13 14:13:41 -07:00
parent f729af95d1
commit 490dc0102b
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82

View file

@ -528,15 +528,15 @@ fn type_parameter_of_option(ty: &Type) -> Option<&Type> {
fn spanned_error_trait(input: &DeriveInput) -> TokenStream {
let vis_span = match &input.vis {
Visibility::Public(vis) => Some(vis.pub_token.span()),
Visibility::Crate(vis) => Some(vis.crate_token.span()),
Visibility::Restricted(vis) => Some(vis.pub_token.span()),
Visibility::Public(vis) => Some(vis.pub_token.span),
Visibility::Crate(vis) => Some(vis.crate_token.span),
Visibility::Restricted(vis) => Some(vis.pub_token.span),
Visibility::Inherited => None,
};
let data_span = match &input.data {
Data::Struct(data) => data.struct_token.span(),
Data::Enum(data) => data.enum_token.span(),
Data::Union(data) => data.union_token.span(),
Data::Struct(data) => data.struct_token.span,
Data::Enum(data) => data.enum_token.span,
Data::Union(data) => data.union_token.span,
};
let first_span = vis_span.unwrap_or(data_span);
let last_span = input.ident.span();