mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-27 12:17:56 +00:00
Resolve redundant_field_names lint in serde_derive
This commit is contained in:
@@ -156,7 +156,7 @@ pub fn with_bound(
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mut visitor = FindTyParams {
|
let mut visitor = FindTyParams {
|
||||||
all_type_params: all_type_params,
|
all_type_params,
|
||||||
relevant_type_params: HashSet::new(),
|
relevant_type_params: HashSet::new(),
|
||||||
associated_type_usage: Vec::new(),
|
associated_type_usage: Vec::new(),
|
||||||
};
|
};
|
||||||
@@ -271,7 +271,7 @@ pub fn with_lifetime_bound(generics: &syn::Generics, lifetime: &str) -> syn::Gen
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
syn::Generics {
|
syn::Generics {
|
||||||
params: params,
|
params,
|
||||||
..generics.clone()
|
..generics.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,11 +134,11 @@ impl Parameters {
|
|||||||
let has_getter = cont.data.has_getter();
|
let has_getter = cont.data.has_getter();
|
||||||
|
|
||||||
Parameters {
|
Parameters {
|
||||||
local: local,
|
local,
|
||||||
this: this,
|
this,
|
||||||
generics: generics,
|
generics,
|
||||||
borrowed: borrowed,
|
borrowed,
|
||||||
has_getter: has_getter,
|
has_getter,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,8 +110,8 @@ impl<'a> Container<'a> {
|
|||||||
|
|
||||||
let mut item = Container {
|
let mut item = Container {
|
||||||
ident: item.ident.clone(),
|
ident: item.ident.clone(),
|
||||||
attrs: attrs,
|
attrs,
|
||||||
data: data,
|
data,
|
||||||
generics: &item.generics,
|
generics: &item.generics,
|
||||||
original: item,
|
original: item,
|
||||||
};
|
};
|
||||||
@@ -148,9 +148,9 @@ fn enum_from_ast<'a>(
|
|||||||
struct_from_ast(cx, &variant.fields, Some(&attrs), container_default);
|
struct_from_ast(cx, &variant.fields, Some(&attrs), container_default);
|
||||||
Variant {
|
Variant {
|
||||||
ident: variant.ident.clone(),
|
ident: variant.ident.clone(),
|
||||||
attrs: attrs,
|
attrs,
|
||||||
style: style,
|
style,
|
||||||
fields: fields,
|
fields,
|
||||||
original: variant,
|
original: variant,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ struct Attr<'c, T> {
|
|||||||
impl<'c, T> Attr<'c, T> {
|
impl<'c, T> Attr<'c, T> {
|
||||||
fn none(cx: &'c Ctxt, name: Symbol) -> Self {
|
fn none(cx: &'c Ctxt, name: Symbol) -> Self {
|
||||||
Attr {
|
Attr {
|
||||||
cx: cx,
|
cx,
|
||||||
name: name,
|
name,
|
||||||
tokens: TokenStream::new(),
|
tokens: TokenStream::new(),
|
||||||
value: None,
|
value: None,
|
||||||
}
|
}
|
||||||
@@ -101,8 +101,8 @@ struct VecAttr<'c, T> {
|
|||||||
impl<'c, T> VecAttr<'c, T> {
|
impl<'c, T> VecAttr<'c, T> {
|
||||||
fn none(cx: &'c Ctxt, name: Symbol) -> Self {
|
fn none(cx: &'c Ctxt, name: Symbol) -> Self {
|
||||||
VecAttr {
|
VecAttr {
|
||||||
cx: cx,
|
cx,
|
||||||
name: name,
|
name,
|
||||||
first_dup_tokens: TokenStream::new(),
|
first_dup_tokens: TokenStream::new(),
|
||||||
values: Vec::new(),
|
values: Vec::new(),
|
||||||
}
|
}
|
||||||
@@ -176,7 +176,7 @@ impl Name {
|
|||||||
serialize_renamed: ser_renamed,
|
serialize_renamed: ser_renamed,
|
||||||
deserialize: de_name.unwrap_or(source_name),
|
deserialize: de_name.unwrap_or(source_name),
|
||||||
deserialize_renamed: de_renamed,
|
deserialize_renamed: de_renamed,
|
||||||
deserialize_aliases: deserialize_aliases,
|
deserialize_aliases,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -716,7 +716,7 @@ fn decide_tag(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TagType::Internal { tag: tag }
|
TagType::Internal { tag }
|
||||||
}
|
}
|
||||||
(Some((untagged_tokens, _)), Some((tag_tokens, _)), None) => {
|
(Some((untagged_tokens, _)), Some((tag_tokens, _)), None) => {
|
||||||
cx.error_spanned_by(
|
cx.error_spanned_by(
|
||||||
@@ -747,10 +747,7 @@ fn decide_tag(
|
|||||||
);
|
);
|
||||||
TagType::External
|
TagType::External
|
||||||
}
|
}
|
||||||
(None, Some((_, tag)), Some((_, content))) => TagType::Adjacent {
|
(None, Some((_, tag)), Some((_, content))) => TagType::Adjacent { tag, content },
|
||||||
tag: tag,
|
|
||||||
content: content,
|
|
||||||
},
|
|
||||||
(Some((untagged_tokens, _)), Some((tag_tokens, _)), Some((content_tokens, _))) => {
|
(Some((untagged_tokens, _)), Some((tag_tokens, _)), Some((content_tokens, _))) => {
|
||||||
cx.error_spanned_by(
|
cx.error_spanned_by(
|
||||||
untagged_tokens,
|
untagged_tokens,
|
||||||
@@ -1383,7 +1380,7 @@ impl Field {
|
|||||||
let expr = syn::ExprPath {
|
let expr = syn::ExprPath {
|
||||||
attrs: Vec::new(),
|
attrs: Vec::new(),
|
||||||
qself: None,
|
qself: None,
|
||||||
path: path,
|
path,
|
||||||
};
|
};
|
||||||
deserialize_with.set_if_none(expr);
|
deserialize_with.set_if_none(expr);
|
||||||
} else if is_cow(&field.ty, is_slice_u8) {
|
} else if is_cow(&field.ty, is_slice_u8) {
|
||||||
@@ -1400,7 +1397,7 @@ impl Field {
|
|||||||
let expr = syn::ExprPath {
|
let expr = syn::ExprPath {
|
||||||
attrs: Vec::new(),
|
attrs: Vec::new(),
|
||||||
qself: None,
|
qself: None,
|
||||||
path: path,
|
path,
|
||||||
};
|
};
|
||||||
deserialize_with.set_if_none(expr);
|
deserialize_with.set_if_none(expr);
|
||||||
}
|
}
|
||||||
@@ -1420,7 +1417,7 @@ impl Field {
|
|||||||
deserialize_with: deserialize_with.get(),
|
deserialize_with: deserialize_with.get(),
|
||||||
ser_bound: ser_bound.get(),
|
ser_bound: ser_bound.get(),
|
||||||
de_bound: de_bound.get(),
|
de_bound: de_bound.get(),
|
||||||
borrowed_lifetimes: borrowed_lifetimes,
|
borrowed_lifetimes,
|
||||||
getter: getter.get(),
|
getter: getter.get(),
|
||||||
flatten: flatten.get(),
|
flatten: flatten.get(),
|
||||||
transparent: false,
|
transparent: false,
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
clippy::cognitive_complexity,
|
clippy::cognitive_complexity,
|
||||||
clippy::enum_variant_names,
|
clippy::enum_variant_names,
|
||||||
clippy::needless_pass_by_value,
|
clippy::needless_pass_by_value,
|
||||||
clippy::redundant_field_names,
|
|
||||||
clippy::too_many_arguments,
|
clippy::too_many_arguments,
|
||||||
clippy::trivially_copy_pass_by_ref,
|
clippy::trivially_copy_pass_by_ref,
|
||||||
clippy::used_underscore_binding,
|
clippy::used_underscore_binding,
|
||||||
|
|||||||
+10
-13
@@ -106,10 +106,10 @@ impl Parameters {
|
|||||||
let generics = build_generics(cont);
|
let generics = build_generics(cont);
|
||||||
|
|
||||||
Parameters {
|
Parameters {
|
||||||
self_var: self_var,
|
self_var,
|
||||||
this: this,
|
this,
|
||||||
generics: generics,
|
generics,
|
||||||
is_remote: is_remote,
|
is_remote,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -538,17 +538,17 @@ fn serialize_externally_tagged_variant(
|
|||||||
}
|
}
|
||||||
Style::Tuple => serialize_tuple_variant(
|
Style::Tuple => serialize_tuple_variant(
|
||||||
TupleVariant::ExternallyTagged {
|
TupleVariant::ExternallyTagged {
|
||||||
type_name: type_name,
|
type_name,
|
||||||
variant_index: variant_index,
|
variant_index,
|
||||||
variant_name: variant_name,
|
variant_name,
|
||||||
},
|
},
|
||||||
params,
|
params,
|
||||||
&variant.fields,
|
&variant.fields,
|
||||||
),
|
),
|
||||||
Style::Struct => serialize_struct_variant(
|
Style::Struct => serialize_struct_variant(
|
||||||
StructVariant::ExternallyTagged {
|
StructVariant::ExternallyTagged {
|
||||||
variant_index: variant_index,
|
variant_index,
|
||||||
variant_name: variant_name,
|
variant_name,
|
||||||
},
|
},
|
||||||
params,
|
params,
|
||||||
&variant.fields,
|
&variant.fields,
|
||||||
@@ -614,10 +614,7 @@ fn serialize_internally_tagged_variant(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Style::Struct => serialize_struct_variant(
|
Style::Struct => serialize_struct_variant(
|
||||||
StructVariant::InternallyTagged {
|
StructVariant::InternallyTagged { tag, variant_name },
|
||||||
tag: tag,
|
|
||||||
variant_name: variant_name,
|
|
||||||
},
|
|
||||||
params,
|
params,
|
||||||
&variant.fields,
|
&variant.fields,
|
||||||
&type_name,
|
&type_name,
|
||||||
|
|||||||
Reference in New Issue
Block a user