From dd29825217e0bb91a82687847509758f377c4ad8 Mon Sep 17 00:00:00 2001 From: hyd-dev Date: Wed, 12 May 2021 18:29:28 +0800 Subject: [PATCH] Allow only `unused_extern_crates` instead of the whole `rust_2018_idioms` lint group in `serde_derive`-generated code --- serde_derive/src/dummy.rs | 2 +- test_suite/tests/expand/de_enum.expanded.rs | 4 ++-- test_suite/tests/expand/default_ty_param.expanded.rs | 4 ++-- test_suite/tests/expand/generic_enum.expanded.rs | 4 ++-- test_suite/tests/expand/generic_struct.expanded.rs | 8 ++++---- test_suite/tests/expand/generic_tuple_struct.expanded.rs | 2 +- test_suite/tests/expand/lifetimes.expanded.rs | 4 ++-- test_suite/tests/expand/named_map.expanded.rs | 4 ++-- test_suite/tests/expand/named_tuple.expanded.rs | 4 ++-- test_suite/tests/expand/named_unit.expanded.rs | 4 ++-- test_suite/tests/expand/ser_enum.expanded.rs | 2 +- test_suite/tests/expand/void.expanded.rs | 4 ++-- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/serde_derive/src/dummy.rs b/serde_derive/src/dummy.rs index 9a4e5f08..29de2601 100644 --- a/serde_derive/src/dummy.rs +++ b/serde_derive/src/dummy.rs @@ -23,7 +23,7 @@ pub fn wrap_in_const( use #path as _serde; }, None => quote! { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; }, }; diff --git a/test_suite/tests/expand/de_enum.expanded.rs b/test_suite/tests/expand/de_enum.expanded.rs index 0aa879e7..4ea3b838 100644 --- a/test_suite/tests/expand/de_enum.expanded.rs +++ b/test_suite/tests/expand/de_enum.expanded.rs @@ -10,7 +10,7 @@ enum DeEnum { #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl _serde::Serialize for DeEnum @@ -265,7 +265,7 @@ const _: () = { #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl<'de, B, C, D> _serde::Deserialize<'de> for DeEnum diff --git a/test_suite/tests/expand/default_ty_param.expanded.rs b/test_suite/tests/expand/default_ty_param.expanded.rs index d24ce254..829e65e8 100644 --- a/test_suite/tests/expand/default_ty_param.expanded.rs +++ b/test_suite/tests/expand/default_ty_param.expanded.rs @@ -11,7 +11,7 @@ struct DefaultTyParam = i32> { #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl> _serde::Serialize for DefaultTyParam { @@ -49,7 +49,7 @@ const _: () = { #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl<'de, T: AssociatedType> _serde::Deserialize<'de> for DefaultTyParam { diff --git a/test_suite/tests/expand/generic_enum.expanded.rs b/test_suite/tests/expand/generic_enum.expanded.rs index d2d8658d..a4ad3109 100644 --- a/test_suite/tests/expand/generic_enum.expanded.rs +++ b/test_suite/tests/expand/generic_enum.expanded.rs @@ -8,7 +8,7 @@ pub enum GenericEnum { #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl _serde::Serialize for GenericEnum @@ -114,7 +114,7 @@ const _: () = { #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl<'de, T, U> _serde::Deserialize<'de> for GenericEnum diff --git a/test_suite/tests/expand/generic_struct.expanded.rs b/test_suite/tests/expand/generic_struct.expanded.rs index d57460c3..bb16dc3b 100644 --- a/test_suite/tests/expand/generic_struct.expanded.rs +++ b/test_suite/tests/expand/generic_struct.expanded.rs @@ -5,7 +5,7 @@ pub struct GenericStruct { #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl _serde::Serialize for GenericStruct @@ -42,7 +42,7 @@ const _: () = { #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl<'de, T> _serde::Deserialize<'de> for GenericStruct @@ -410,7 +410,7 @@ pub struct GenericNewTypeStruct(T); #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl _serde::Serialize for GenericNewTypeStruct @@ -435,7 +435,7 @@ const _: () = { #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl<'de, T> _serde::Deserialize<'de> for GenericNewTypeStruct diff --git a/test_suite/tests/expand/generic_tuple_struct.expanded.rs b/test_suite/tests/expand/generic_tuple_struct.expanded.rs index f387b6af..7012f9f4 100644 --- a/test_suite/tests/expand/generic_tuple_struct.expanded.rs +++ b/test_suite/tests/expand/generic_tuple_struct.expanded.rs @@ -3,7 +3,7 @@ pub struct GenericTupleStruct(T, U); #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl<'de, T, U> _serde::Deserialize<'de> for GenericTupleStruct diff --git a/test_suite/tests/expand/lifetimes.expanded.rs b/test_suite/tests/expand/lifetimes.expanded.rs index f8ec1df7..cf2f0081 100644 --- a/test_suite/tests/expand/lifetimes.expanded.rs +++ b/test_suite/tests/expand/lifetimes.expanded.rs @@ -8,7 +8,7 @@ enum Lifetimes<'a> { #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl<'a> _serde::Serialize for Lifetimes<'a> { @@ -95,7 +95,7 @@ const _: () = { #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl<'de, 'a> _serde::Deserialize<'de> for Lifetimes<'a> { diff --git a/test_suite/tests/expand/named_map.expanded.rs b/test_suite/tests/expand/named_map.expanded.rs index 1a621b57..e30ac34e 100644 --- a/test_suite/tests/expand/named_map.expanded.rs +++ b/test_suite/tests/expand/named_map.expanded.rs @@ -7,7 +7,7 @@ struct SerNamedMap<'a, 'b, A: 'a, B: 'b, C> { #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl<'a, 'b, A: 'a, B: 'b, C> _serde::Serialize for SerNamedMap<'a, 'b, A, B, C> @@ -63,7 +63,7 @@ struct DeNamedMap { #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl<'de, A, B, C> _serde::Deserialize<'de> for DeNamedMap diff --git a/test_suite/tests/expand/named_tuple.expanded.rs b/test_suite/tests/expand/named_tuple.expanded.rs index 707ca076..be083f63 100644 --- a/test_suite/tests/expand/named_tuple.expanded.rs +++ b/test_suite/tests/expand/named_tuple.expanded.rs @@ -3,7 +3,7 @@ struct SerNamedTuple<'a, 'b, A: 'a, B: 'b, C>(&'a A, &'b mut B, C); #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl<'a, 'b, A: 'a, B: 'b, C> _serde::Serialize for SerNamedTuple<'a, 'b, A, B, C> @@ -55,7 +55,7 @@ struct DeNamedTuple(A, B, C); #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl<'de, A, B, C> _serde::Deserialize<'de> for DeNamedTuple diff --git a/test_suite/tests/expand/named_unit.expanded.rs b/test_suite/tests/expand/named_unit.expanded.rs index 44329246..87876b77 100644 --- a/test_suite/tests/expand/named_unit.expanded.rs +++ b/test_suite/tests/expand/named_unit.expanded.rs @@ -3,7 +3,7 @@ struct NamedUnit; #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl _serde::Serialize for NamedUnit { @@ -21,7 +21,7 @@ const _: () = { #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl<'de> _serde::Deserialize<'de> for NamedUnit { diff --git a/test_suite/tests/expand/ser_enum.expanded.rs b/test_suite/tests/expand/ser_enum.expanded.rs index 40b45e07..b0a83ca3 100644 --- a/test_suite/tests/expand/ser_enum.expanded.rs +++ b/test_suite/tests/expand/ser_enum.expanded.rs @@ -13,7 +13,7 @@ where #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl<'a, B: 'a, C: 'a, D> _serde::Serialize for SerEnum<'a, B, C, D> diff --git a/test_suite/tests/expand/void.expanded.rs b/test_suite/tests/expand/void.expanded.rs index 65c3d2c6..35e6763d 100644 --- a/test_suite/tests/expand/void.expanded.rs +++ b/test_suite/tests/expand/void.expanded.rs @@ -3,7 +3,7 @@ enum Void {} #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl _serde::Serialize for Void { @@ -21,7 +21,7 @@ const _: () = { #[doc(hidden)] #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] const _: () = { - #[allow(rust_2018_idioms, clippy::useless_attribute)] + #[allow(unused_extern_crates, clippy::useless_attribute)] extern crate serde as _serde; #[automatically_derived] impl<'de> _serde::Deserialize<'de> for Void {