diff --git a/test_suite/tests/regression/issue2371.rs b/test_suite/tests/regression/issue2371.rs index 7668af1d..668ee5c7 100644 --- a/test_suite/tests/regression/issue2371.rs +++ b/test_suite/tests/regression/issue2371.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + use serde_derive::Deserialize; #[derive(Deserialize)] diff --git a/test_suite/tests/regression/issue2409.rs b/test_suite/tests/regression/issue2409.rs index cdfe4dc5..335344a2 100644 --- a/test_suite/tests/regression/issue2409.rs +++ b/test_suite/tests/regression/issue2409.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + use serde_derive::Deserialize; macro_rules! bug { diff --git a/test_suite/tests/regression/issue2844.rs b/test_suite/tests/regression/issue2844.rs index 3ad2012b..024e62fb 100644 --- a/test_suite/tests/regression/issue2844.rs +++ b/test_suite/tests/regression/issue2844.rs @@ -1,4 +1,4 @@ -#![allow(clippy::trivially_copy_pass_by_ref)] +#![allow(clippy::trivially_copy_pass_by_ref, dead_code)] use serde_derive::{Deserialize, Serialize}; diff --git a/test_suite/tests/regression/issue2846.rs b/test_suite/tests/regression/issue2846.rs index c5258a5b..4a6d3953 100644 --- a/test_suite/tests/regression/issue2846.rs +++ b/test_suite/tests/regression/issue2846.rs @@ -1,4 +1,4 @@ -#![allow(clippy::trivially_copy_pass_by_ref)] +#![allow(clippy::trivially_copy_pass_by_ref, dead_code)] use serde_derive::Deserialize; diff --git a/test_suite/tests/test_borrow.rs b/test_suite/tests/test_borrow.rs index a9eee455..6fcdd7c9 100644 --- a/test_suite/tests/test_borrow.rs +++ b/test_suite/tests/test_borrow.rs @@ -1,7 +1,10 @@ #![allow( clippy::derive_partial_eq_without_eq, clippy::items_after_statements, - clippy::used_underscore_binding + clippy::used_underscore_binding, + // We use lots of declarations inside function bodies to avoid conflicts, + // but they aren't used. We just want to make sure they compile. + dead_code, )] use serde::de::value::{BorrowedStrDeserializer, MapDeserializer}; diff --git a/test_suite/tests/test_gen.rs b/test_suite/tests/test_gen.rs index a92edb3a..2c038ae8 100644 --- a/test_suite/tests/test_gen.rs +++ b/test_suite/tests/test_gen.rs @@ -18,7 +18,10 @@ clippy::ptr_arg, clippy::too_many_lines, clippy::trivially_copy_pass_by_ref, - clippy::type_repetition_in_bounds + clippy::type_repetition_in_bounds, + // We use lots of declarations inside function bodies to avoid conflicts, + // but they aren't used. We just want to make sure they compile. + dead_code, )] #![deny(clippy::collection_is_never_read)] diff --git a/test_suite/tests/test_remote.rs b/test_suite/tests/test_remote.rs index d550af42..919b3e28 100644 --- a/test_suite/tests/test_remote.rs +++ b/test_suite/tests/test_remote.rs @@ -1,4 +1,4 @@ -#![allow(clippy::redundant_field_names)] +#![allow(clippy::redundant_field_names, dead_code)] use serde_derive::{Deserialize, Serialize}; diff --git a/test_suite/tests/test_self.rs b/test_suite/tests/test_self.rs index 2813c485..ed71d42d 100644 --- a/test_suite/tests/test_self.rs +++ b/test_suite/tests/test_self.rs @@ -1,4 +1,4 @@ -#![allow(clippy::used_underscore_binding)] +#![allow(clippy::used_underscore_binding, dead_code)] use serde_derive::{Deserialize, Serialize}; diff --git a/test_suite/tests/ui/conflict/alias-enum.stderr b/test_suite/tests/ui/conflict/alias-enum.stderr index c8404105..b19c04c1 100644 --- a/test_suite/tests/ui/conflict/alias-enum.stderr +++ b/test_suite/tests/ui/conflict/alias-enum.stderr @@ -7,18 +7,18 @@ error[E0425]: cannot find value `__FAIL__` in this scope warning: unreachable pattern --> tests/ui/conflict/alias-enum.rs:13:9 | -8 | #[serde(alias = "a", alias = "b", alias = "c")] + 8 | #[serde(alias = "a", alias = "b", alias = "c")] | --- matches all the relevant values ... 13 | b: (), | ^ no value can reach this | - = note: `#[warn(unreachable_patterns)]` on by default + = note: `#[warn(unreachable_patterns)]` (part of `#[warn(unused)]`) on by default warning: unreachable pattern --> tests/ui/conflict/alias-enum.rs:12:25 | -8 | #[serde(alias = "a", alias = "b", alias = "c")] + 8 | #[serde(alias = "a", alias = "b", alias = "c")] | --- matches all the relevant values ... 12 | #[serde(alias = "c")] diff --git a/test_suite/tests/ui/conflict/alias.stderr b/test_suite/tests/ui/conflict/alias.stderr index 4c1a96d1..cd747fac 100644 --- a/test_suite/tests/ui/conflict/alias.stderr +++ b/test_suite/tests/ui/conflict/alias.stderr @@ -7,13 +7,13 @@ error[E0425]: cannot find value `__FAIL__` in this scope warning: unreachable pattern --> tests/ui/conflict/alias.rs:10:5 | -5 | #[serde(alias = "a", alias = "b", alias = "c")] + 5 | #[serde(alias = "a", alias = "b", alias = "c")] | --- matches all the relevant values ... 10 | b: (), | ^ no value can reach this | - = note: `#[warn(unreachable_patterns)]` on by default + = note: `#[warn(unreachable_patterns)]` (part of `#[warn(unused)]`) on by default warning: unreachable pattern --> tests/ui/conflict/alias.rs:9:21 diff --git a/test_suite/tests/ui/conflict/internal-tag-alias.stderr b/test_suite/tests/ui/conflict/internal-tag-alias.stderr index 8a3df92c..8afa6a9b 100644 --- a/test_suite/tests/ui/conflict/internal-tag-alias.stderr +++ b/test_suite/tests/ui/conflict/internal-tag-alias.stderr @@ -1,11 +1,11 @@ error: variant field name `conflict` conflicts with internal tag --> tests/ui/conflict/internal-tag-alias.rs:4:1 | -4 | / #[serde(tag = "conflict")] -5 | | enum E { -6 | | A { -7 | | #[serde(alias = "conflict")] -8 | | x: (), -9 | | }, + 4 | / #[serde(tag = "conflict")] + 5 | | enum E { + 6 | | A { + 7 | | #[serde(alias = "conflict")] + 8 | | x: (), + 9 | | }, 10 | | } | |_^ diff --git a/test_suite/tests/ui/conflict/internal-tag.stderr b/test_suite/tests/ui/conflict/internal-tag.stderr index d1792306..97f4bc90 100644 --- a/test_suite/tests/ui/conflict/internal-tag.stderr +++ b/test_suite/tests/ui/conflict/internal-tag.stderr @@ -1,11 +1,11 @@ error: variant field name `conflict` conflicts with internal tag --> tests/ui/conflict/internal-tag.rs:4:1 | -4 | / #[serde(tag = "conflict")] -5 | | enum E { -6 | | A { -7 | | #[serde(rename = "conflict")] -8 | | x: (), -9 | | }, + 4 | / #[serde(tag = "conflict")] + 5 | | enum E { + 6 | | A { + 7 | | #[serde(rename = "conflict")] + 8 | | x: (), + 9 | | }, 10 | | } | |_^ diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.stderr b/test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.stderr index c21b4769..50c0ae97 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.stderr +++ b/test_suite/tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.stderr @@ -1,7 +1,7 @@ error[E0308]: `match` arms have incompatible types --> tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs:10:33 | -5 | #[derive(Deserialize)] + 5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `i8` @@ -13,7 +13,7 @@ error[E0308]: `match` arms have incompatible types error[E0308]: `match` arms have incompatible types --> tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs:12:27 | -5 | #[derive(Deserialize)] + 5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `u8` @@ -25,7 +25,7 @@ error[E0308]: `match` arms have incompatible types error[E0308]: `match` arms have incompatible types --> tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs:15:27 | -5 | #[derive(Deserialize)] + 5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `i8` diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.stderr b/test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.stderr index 09da2438..125b7262 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.stderr +++ b/test_suite/tests/ui/default-attribute/incorrect_type_enum_externally_tagged.stderr @@ -13,7 +13,7 @@ error[E0308]: `match` arms have incompatible types error[E0308]: `match` arms have incompatible types --> tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs:11:27 | -5 | #[derive(Deserialize)] + 5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `u8` @@ -25,7 +25,7 @@ error[E0308]: `match` arms have incompatible types error[E0308]: `match` arms have incompatible types --> tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs:14:27 | -5 | #[derive(Deserialize)] + 5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `i8` diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.stderr b/test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.stderr index 74fead2d..fed3e06a 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.stderr +++ b/test_suite/tests/ui/default-attribute/incorrect_type_enum_internally_tagged.stderr @@ -1,7 +1,7 @@ error[E0308]: `match` arms have incompatible types --> tests/ui/default-attribute/incorrect_type_enum_internally_tagged.rs:12:27 | -5 | #[derive(Deserialize)] + 5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `u8` @@ -13,7 +13,7 @@ error[E0308]: `match` arms have incompatible types error[E0308]: `match` arms have incompatible types --> tests/ui/default-attribute/incorrect_type_enum_internally_tagged.rs:15:27 | -5 | #[derive(Deserialize)] + 5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `i8` diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.stderr b/test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.stderr index 9e1167d9..027b665d 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.stderr +++ b/test_suite/tests/ui/default-attribute/incorrect_type_enum_untagged.stderr @@ -1,7 +1,7 @@ error[E0308]: `match` arms have incompatible types --> tests/ui/default-attribute/incorrect_type_enum_untagged.rs:10:33 | -5 | #[derive(Deserialize)] + 5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `i8` @@ -13,7 +13,7 @@ error[E0308]: `match` arms have incompatible types error[E0308]: `match` arms have incompatible types --> tests/ui/default-attribute/incorrect_type_enum_untagged.rs:12:27 | -5 | #[derive(Deserialize)] + 5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `u8` @@ -25,7 +25,7 @@ error[E0308]: `match` arms have incompatible types error[E0308]: `match` arms have incompatible types --> tests/ui/default-attribute/incorrect_type_enum_untagged.rs:15:27 | -5 | #[derive(Deserialize)] + 5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `i8` diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_newtype.stderr b/test_suite/tests/ui/default-attribute/incorrect_type_newtype.stderr index b4e066ae..04bb8349 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_newtype.stderr +++ b/test_suite/tests/ui/default-attribute/incorrect_type_newtype.stderr @@ -2,10 +2,7 @@ error[E0308]: mismatched types --> tests/ui/default-attribute/incorrect_type_newtype.rs:6:19 | 6 | #[serde(default = "main")] - | ^^^^^^ - | | - | expected `Newtype`, found `()` - | expected due to this + | ^^^^^^ expected `Newtype`, found `()` error[E0308]: `match` arms have incompatible types --> tests/ui/default-attribute/incorrect_type_newtype.rs:7:34 diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_struct.stderr b/test_suite/tests/ui/default-attribute/incorrect_type_struct.stderr index 13431b03..4973c03d 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_struct.stderr +++ b/test_suite/tests/ui/default-attribute/incorrect_type_struct.stderr @@ -2,10 +2,7 @@ error[E0308]: mismatched types --> tests/ui/default-attribute/incorrect_type_struct.rs:6:19 | 6 | #[serde(default = "main")] - | ^^^^^^ - | | - | expected `Struct`, found `()` - | expected due to this + | ^^^^^^ expected `Struct`, found `()` error[E0308]: `match` arms have incompatible types --> tests/ui/default-attribute/incorrect_type_struct.rs:8:23 @@ -22,7 +19,7 @@ error[E0308]: `match` arms have incompatible types error[E0308]: `match` arms have incompatible types --> tests/ui/default-attribute/incorrect_type_struct.rs:11:23 | -5 | #[derive(Deserialize)] + 5 | #[derive(Deserialize)] | ----------- | | | this is found to be of type `i8` @@ -51,7 +48,7 @@ error[E0308]: mismatched types error[E0308]: mismatched types --> tests/ui/default-attribute/incorrect_type_struct.rs:11:23 | -5 | #[derive(Deserialize)] + 5 | #[derive(Deserialize)] | ----------- expected due to the type of this binding ... 11 | #[serde(default = "main")] diff --git a/test_suite/tests/ui/default-attribute/incorrect_type_tuple.stderr b/test_suite/tests/ui/default-attribute/incorrect_type_tuple.stderr index 131158e2..dba33bfb 100644 --- a/test_suite/tests/ui/default-attribute/incorrect_type_tuple.stderr +++ b/test_suite/tests/ui/default-attribute/incorrect_type_tuple.stderr @@ -2,10 +2,7 @@ error[E0308]: mismatched types --> tests/ui/default-attribute/incorrect_type_tuple.rs:6:19 | 6 | #[serde(default = "main")] - | ^^^^^^ - | | - | expected `Tuple`, found `()` - | expected due to this + | ^^^^^^ expected `Tuple`, found `()` error[E0308]: `match` arms have incompatible types --> tests/ui/default-attribute/incorrect_type_tuple.rs:7:36 diff --git a/test_suite/tests/ui/on_unimplemented.stderr b/test_suite/tests/ui/on_unimplemented.stderr index 1b031819..ec48b6d7 100644 --- a/test_suite/tests/ui/on_unimplemented.stderr +++ b/test_suite/tests/ui/on_unimplemented.stderr @@ -2,10 +2,15 @@ error[E0277]: the trait bound `MyStruct: Serialize` is not satisfied --> tests/ui/on_unimplemented.rs:21:15 | 21 | to_string(&MyStruct); - | --------- ^^^^^^^^^ the trait `Serialize` is not implemented for `MyStruct` + | --------- ^^^^^^^^^ unsatisfied trait bound | | | required by a bound introduced by this call | +help: the trait `Serialize` is not implemented for `MyStruct` + --> tests/ui/on_unimplemented.rs:18:1 + | +18 | struct MyStruct; + | ^^^^^^^^^^^^^^^ = note: for local types consider adding `#[derive(serde::Serialize)]` to your `MyStruct` type = note: for types from other crates check whether the crate offers a `serde` feature flag = help: the following other types implement trait `Serialize`: @@ -21,18 +26,23 @@ error[E0277]: the trait bound `MyStruct: Serialize` is not satisfied note: required by a bound in `to_string` --> tests/ui/on_unimplemented.rs:6:8 | -4 | fn to_string(_: &T) -> String + 4 | fn to_string(_: &T) -> String | --------- required by a bound in this function -5 | where -6 | T: Serialize, + 5 | where + 6 | T: Serialize, | ^^^^^^^^^ required by this bound in `to_string` error[E0277]: the trait bound `MyStruct: Deserialize<'_>` is not satisfied --> tests/ui/on_unimplemented.rs:22:23 | 22 | let _: MyStruct = from_str(""); - | ^^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `MyStruct` + | ^^^^^^^^^^^^ unsatisfied trait bound | +help: the trait `Deserialize<'_>` is not implemented for `MyStruct` + --> tests/ui/on_unimplemented.rs:18:1 + | +18 | struct MyStruct; + | ^^^^^^^^^^^^^^^ = note: for local types consider adding `#[derive(serde::Deserialize)]` to your `MyStruct` type = note: for types from other crates check whether the crate offers a `serde` feature flag = help: the following other types implement trait `Deserialize<'de>`: diff --git a/test_suite/tests/ui/transparent/de_at_least_one.stderr b/test_suite/tests/ui/transparent/de_at_least_one.stderr index 6fb2fb20..97d7f52a 100644 --- a/test_suite/tests/ui/transparent/de_at_least_one.stderr +++ b/test_suite/tests/ui/transparent/de_at_least_one.stderr @@ -1,11 +1,11 @@ error: #[serde(transparent)] requires at least one field that is neither skipped nor has a default --> tests/ui/transparent/de_at_least_one.rs:4:1 | -4 | / #[serde(transparent)] -5 | | struct S { -6 | | #[serde(skip)] -7 | | a: u8, -8 | | #[serde(default)] -9 | | b: u8, + 4 | / #[serde(transparent)] + 5 | | struct S { + 6 | | #[serde(skip)] + 7 | | a: u8, + 8 | | #[serde(default)] + 9 | | b: u8, 10 | | } | |_^ diff --git a/test_suite/tests/ui/with-variant/skip_de_struct_field.stderr b/test_suite/tests/ui/with-variant/skip_de_struct_field.stderr index 34bb1f73..5632b67d 100644 --- a/test_suite/tests/ui/with-variant/skip_de_struct_field.stderr +++ b/test_suite/tests/ui/with-variant/skip_de_struct_field.stderr @@ -1,10 +1,10 @@ error: variant `Struct` cannot have both #[serde(deserialize_with)] and a field `f1` marked with #[serde(skip_deserializing)] --> tests/ui/with-variant/skip_de_struct_field.rs:5:5 | -5 | / #[serde(deserialize_with = "deserialize_some_other_variant")] -6 | | Struct { -7 | | #[serde(skip_deserializing)] -8 | | f1: String, -9 | | f2: u8, + 5 | / #[serde(deserialize_with = "deserialize_some_other_variant")] + 6 | | Struct { + 7 | | #[serde(skip_deserializing)] + 8 | | f1: String, + 9 | | f2: u8, 10 | | }, | |_____^ diff --git a/test_suite/tests/ui/with-variant/skip_ser_struct_field.stderr b/test_suite/tests/ui/with-variant/skip_ser_struct_field.stderr index f2fe26be..f6792159 100644 --- a/test_suite/tests/ui/with-variant/skip_ser_struct_field.stderr +++ b/test_suite/tests/ui/with-variant/skip_ser_struct_field.stderr @@ -1,10 +1,10 @@ error: variant `Struct` cannot have both #[serde(serialize_with)] and a field `f1` marked with #[serde(skip_serializing)] --> tests/ui/with-variant/skip_ser_struct_field.rs:5:5 | -5 | / #[serde(serialize_with = "serialize_some_other_variant")] -6 | | Struct { -7 | | #[serde(skip_serializing)] -8 | | f1: String, -9 | | f2: u8, + 5 | / #[serde(serialize_with = "serialize_some_other_variant")] + 6 | | Struct { + 7 | | #[serde(skip_serializing)] + 8 | | f1: String, + 9 | | f2: u8, 10 | | }, | |_____^ diff --git a/test_suite/tests/ui/with-variant/skip_ser_struct_field_if.stderr b/test_suite/tests/ui/with-variant/skip_ser_struct_field_if.stderr index bd83aa34..c06c3404 100644 --- a/test_suite/tests/ui/with-variant/skip_ser_struct_field_if.stderr +++ b/test_suite/tests/ui/with-variant/skip_ser_struct_field_if.stderr @@ -1,10 +1,10 @@ error: variant `Struct` cannot have both #[serde(serialize_with)] and a field `f1` marked with #[serde(skip_serializing_if)] --> tests/ui/with-variant/skip_ser_struct_field_if.rs:5:5 | -5 | / #[serde(serialize_with = "serialize_some_newtype_variant")] -6 | | Struct { -7 | | #[serde(skip_serializing_if = "always")] -8 | | f1: String, -9 | | f2: u8, + 5 | / #[serde(serialize_with = "serialize_some_newtype_variant")] + 6 | | Struct { + 7 | | #[serde(skip_serializing_if = "always")] + 8 | | f1: String, + 9 | | f2: u8, 10 | | }, | |_____^ diff --git a/test_suite/tests/ui/with/incorrect_type.stderr b/test_suite/tests/ui/with/incorrect_type.stderr index fd08ebad..1e625b0e 100644 --- a/test_suite/tests/ui/with/incorrect_type.stderr +++ b/test_suite/tests/ui/with/incorrect_type.stderr @@ -13,7 +13,7 @@ error[E0277]: the trait bound `&u8: Serializer` is not satisfied note: required by a bound in `w::serialize` --> tests/ui/with/incorrect_type.rs:9:28 | -9 | pub fn serialize(_: S) -> Result { + 9 | pub fn serialize(_: S) -> Result { | ^^^^^^^^^^ required by this bound in `serialize` error[E0061]: this function takes 1 argument but 2 arguments were supplied @@ -27,7 +27,7 @@ error[E0061]: this function takes 1 argument but 2 arguments were supplied note: function defined here --> tests/ui/with/incorrect_type.rs:9:12 | -9 | pub fn serialize(_: S) -> Result { + 9 | pub fn serialize(_: S) -> Result { | ^^^^^^^^^ error[E0277]: the trait bound `&u8: Serializer` is not satisfied @@ -64,7 +64,7 @@ error[E0277]: the trait bound `&u8: Serializer` is not satisfied note: required by a bound in `w::serialize` --> tests/ui/with/incorrect_type.rs:9:28 | -9 | pub fn serialize(_: S) -> Result { + 9 | pub fn serialize(_: S) -> Result { | ^^^^^^^^^^ required by this bound in `serialize` error[E0061]: this function takes 1 argument but 2 arguments were supplied @@ -78,7 +78,7 @@ error[E0061]: this function takes 1 argument but 2 arguments were supplied note: function defined here --> tests/ui/with/incorrect_type.rs:9:12 | -9 | pub fn serialize(_: S) -> Result { + 9 | pub fn serialize(_: S) -> Result { | ^^^^^^^^^ error[E0277]: the trait bound `&u8: Serializer` is not satisfied