Enable pedantic clippy lints in serde_derive
This commit is contained in:
parent
ab62cd3b28
commit
62557731c3
@ -553,7 +553,7 @@ fn deserialize_seq(
|
||||
.count();
|
||||
let expecting = format!("tuple of {} elements", deserialized_count);
|
||||
|
||||
let mut index_in_seq = 0usize;
|
||||
let mut index_in_seq = 0_usize;
|
||||
let let_values = vars.clone().zip(fields).map(|(var, field)| {
|
||||
if field.attrs.skip_deserializing() {
|
||||
let default = Expr(expr_is_missing(field, cattrs));
|
||||
@ -1946,9 +1946,7 @@ fn deserialize_identifier(
|
||||
value_as_borrowed_str_content,
|
||||
value_as_bytes_content,
|
||||
value_as_borrowed_bytes_content,
|
||||
) = if !collect_other_fields {
|
||||
(None, None, None, None)
|
||||
} else {
|
||||
) = if collect_other_fields {
|
||||
(
|
||||
Some(quote! {
|
||||
let __value = _serde::private::de::Content::String(__value.to_string());
|
||||
@ -1963,6 +1961,8 @@ fn deserialize_identifier(
|
||||
let __value = _serde::private::de::Content::Bytes(__value);
|
||||
}),
|
||||
)
|
||||
} else {
|
||||
(None, None, None, None)
|
||||
};
|
||||
|
||||
let fallthrough_arm = if let Some(fallthrough) = fallthrough {
|
||||
@ -1977,7 +1977,7 @@ fn deserialize_identifier(
|
||||
}
|
||||
};
|
||||
|
||||
let variant_indices = 0u64..;
|
||||
let variant_indices = 0_u64..;
|
||||
let fallthrough_msg = format!("{} index 0 <= i < {}", index_expecting, fields.len());
|
||||
let visit_other = if collect_other_fields {
|
||||
quote! {
|
||||
|
@ -777,9 +777,7 @@ impl Field {
|
||||
};
|
||||
|
||||
let variant_borrow = attrs
|
||||
.map(|variant| &variant.borrow)
|
||||
.unwrap_or(&None)
|
||||
.as_ref()
|
||||
.map_or(None, |variant| variant.borrow.as_ref())
|
||||
.map(|borrow| vec![Meta(borrow.clone())]);
|
||||
|
||||
for meta_items in field
|
||||
|
@ -23,9 +23,22 @@
|
||||
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.48")]
|
||||
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
||||
// Whitelisted clippy lints
|
||||
#![cfg_attr(
|
||||
feature = "cargo-clippy",
|
||||
allow(enum_variant_names, redundant_field_names, too_many_arguments, used_underscore_binding)
|
||||
allow(
|
||||
enum_variant_names, redundant_field_names, too_many_arguments, used_underscore_binding,
|
||||
cyclomatic_complexity
|
||||
)
|
||||
)]
|
||||
// Whitelisted clippy_pedantic lints
|
||||
#![cfg_attr(
|
||||
feature = "cargo-clippy",
|
||||
allow(
|
||||
items_after_statements, doc_markdown, stutter, similar_names, use_self, single_match_else,
|
||||
enum_glob_use, match_same_arms, filter_map, cast_possible_truncation
|
||||
)
|
||||
)]
|
||||
// The `quote!` macro requires deep recursion.
|
||||
#![recursion_limit = "512"]
|
||||
|
@ -18,8 +18,6 @@ use internals::{attr, Ctxt};
|
||||
use pretend;
|
||||
use try;
|
||||
|
||||
use std::u32;
|
||||
|
||||
pub fn expand_derive_serialize(input: &syn::DeriveInput) -> Result<Tokens, String> {
|
||||
let ctxt = Ctxt::new();
|
||||
let cont = Container::from_ast(&ctxt, input);
|
||||
@ -250,7 +248,7 @@ fn serialize_tuple_struct(
|
||||
}
|
||||
|
||||
fn serialize_struct(params: &Parameters, fields: &[Field], cattrs: &attr::Container) -> Fragment {
|
||||
assert!(fields.len() as u64 <= u64::from(u32::MAX));
|
||||
assert!(fields.len() as u64 <= u64::from(u32::max_value()));
|
||||
|
||||
if cattrs.has_flatten() {
|
||||
serialize_struct_as_map(params, fields, cattrs)
|
||||
@ -333,7 +331,7 @@ fn serialize_struct_as_map(
|
||||
}
|
||||
|
||||
fn serialize_enum(params: &Parameters, variants: &[Variant], cattrs: &attr::Container) -> Fragment {
|
||||
assert!(variants.len() as u64 <= u64::from(u32::MAX));
|
||||
assert!(variants.len() as u64 <= u64::from(u32::max_value()));
|
||||
|
||||
let self_var = params.self_var;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user