Allow more dead code

This commit is contained in:
Oli Scherer
2025-08-26 07:13:09 +00:00
parent 363deb84cc
commit c85e4240be
25 changed files with 88 additions and 77 deletions
+2
View File
@@ -1,3 +1,5 @@
#![allow(dead_code)]
use serde_derive::Deserialize; use serde_derive::Deserialize;
#[derive(Deserialize)] #[derive(Deserialize)]
+2
View File
@@ -1,3 +1,5 @@
#![allow(dead_code)]
use serde_derive::Deserialize; use serde_derive::Deserialize;
macro_rules! bug { macro_rules! bug {
+1 -1
View File
@@ -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}; use serde_derive::{Deserialize, Serialize};
+1 -1
View File
@@ -1,4 +1,4 @@
#![allow(clippy::trivially_copy_pass_by_ref)] #![allow(clippy::trivially_copy_pass_by_ref, dead_code)]
use serde_derive::Deserialize; use serde_derive::Deserialize;
+4 -1
View File
@@ -1,7 +1,10 @@
#![allow( #![allow(
clippy::derive_partial_eq_without_eq, clippy::derive_partial_eq_without_eq,
clippy::items_after_statements, 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}; use serde::de::value::{BorrowedStrDeserializer, MapDeserializer};
+4 -1
View File
@@ -18,7 +18,10 @@
clippy::ptr_arg, clippy::ptr_arg,
clippy::too_many_lines, clippy::too_many_lines,
clippy::trivially_copy_pass_by_ref, 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)] #![deny(clippy::collection_is_never_read)]
+1 -1
View File
@@ -1,4 +1,4 @@
#![allow(clippy::redundant_field_names)] #![allow(clippy::redundant_field_names, dead_code)]
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
+1 -1
View File
@@ -1,4 +1,4 @@
#![allow(clippy::used_underscore_binding)] #![allow(clippy::used_underscore_binding, dead_code)]
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
@@ -7,18 +7,18 @@ error[E0425]: cannot find value `__FAIL__` in this scope
warning: unreachable pattern warning: unreachable pattern
--> tests/ui/conflict/alias-enum.rs:13:9 --> 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 | --- matches all the relevant values
... ...
13 | b: (), 13 | b: (),
| ^ no value can reach this | ^ 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 warning: unreachable pattern
--> tests/ui/conflict/alias-enum.rs:12:25 --> 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 | --- matches all the relevant values
... ...
12 | #[serde(alias = "c")] 12 | #[serde(alias = "c")]
+2 -2
View File
@@ -7,13 +7,13 @@ error[E0425]: cannot find value `__FAIL__` in this scope
warning: unreachable pattern warning: unreachable pattern
--> tests/ui/conflict/alias.rs:10:5 --> 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 | --- matches all the relevant values
... ...
10 | b: (), 10 | b: (),
| ^ no value can reach this | ^ 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 warning: unreachable pattern
--> tests/ui/conflict/alias.rs:9:21 --> tests/ui/conflict/alias.rs:9:21
@@ -1,11 +1,11 @@
error: variant field name `conflict` conflicts with internal tag error: variant field name `conflict` conflicts with internal tag
--> tests/ui/conflict/internal-tag-alias.rs:4:1 --> tests/ui/conflict/internal-tag-alias.rs:4:1
| |
4 | / #[serde(tag = "conflict")] 4 | / #[serde(tag = "conflict")]
5 | | enum E { 5 | | enum E {
6 | | A { 6 | | A {
7 | | #[serde(alias = "conflict")] 7 | | #[serde(alias = "conflict")]
8 | | x: (), 8 | | x: (),
9 | | }, 9 | | },
10 | | } 10 | | }
| |_^ | |_^
@@ -1,11 +1,11 @@
error: variant field name `conflict` conflicts with internal tag error: variant field name `conflict` conflicts with internal tag
--> tests/ui/conflict/internal-tag.rs:4:1 --> tests/ui/conflict/internal-tag.rs:4:1
| |
4 | / #[serde(tag = "conflict")] 4 | / #[serde(tag = "conflict")]
5 | | enum E { 5 | | enum E {
6 | | A { 6 | | A {
7 | | #[serde(rename = "conflict")] 7 | | #[serde(rename = "conflict")]
8 | | x: (), 8 | | x: (),
9 | | }, 9 | | },
10 | | } 10 | | }
| |_^ | |_^
@@ -1,7 +1,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:10:33 --> 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` | 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 error[E0308]: `match` arms have incompatible types
--> tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs:12:27 --> 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` | 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 error[E0308]: `match` arms have incompatible types
--> tests/ui/default-attribute/incorrect_type_enum_adjacently_tagged.rs:15:27 --> 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` | 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 error[E0308]: `match` arms have incompatible types
--> tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs:11:27 --> 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` | 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 error[E0308]: `match` arms have incompatible types
--> tests/ui/default-attribute/incorrect_type_enum_externally_tagged.rs:14:27 --> 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` | this is found to be of type `i8`
@@ -1,7 +1,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:12:27 --> 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` | 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 error[E0308]: `match` arms have incompatible types
--> tests/ui/default-attribute/incorrect_type_enum_internally_tagged.rs:15:27 --> 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` | this is found to be of type `i8`
@@ -1,7 +1,7 @@
error[E0308]: `match` arms have incompatible types error[E0308]: `match` arms have incompatible types
--> tests/ui/default-attribute/incorrect_type_enum_untagged.rs:10:33 --> 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` | 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 error[E0308]: `match` arms have incompatible types
--> tests/ui/default-attribute/incorrect_type_enum_untagged.rs:12:27 --> 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` | 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 error[E0308]: `match` arms have incompatible types
--> tests/ui/default-attribute/incorrect_type_enum_untagged.rs:15:27 --> 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` | this is found to be of type `i8`
@@ -2,10 +2,7 @@ error[E0308]: mismatched types
--> tests/ui/default-attribute/incorrect_type_newtype.rs:6:19 --> tests/ui/default-attribute/incorrect_type_newtype.rs:6:19
| |
6 | #[serde(default = "main")] 6 | #[serde(default = "main")]
| ^^^^^^ | ^^^^^^ expected `Newtype`, found `()`
| |
| expected `Newtype`, found `()`
| expected due to this
error[E0308]: `match` arms have incompatible types error[E0308]: `match` arms have incompatible types
--> tests/ui/default-attribute/incorrect_type_newtype.rs:7:34 --> tests/ui/default-attribute/incorrect_type_newtype.rs:7:34
@@ -2,10 +2,7 @@ error[E0308]: mismatched types
--> tests/ui/default-attribute/incorrect_type_struct.rs:6:19 --> tests/ui/default-attribute/incorrect_type_struct.rs:6:19
| |
6 | #[serde(default = "main")] 6 | #[serde(default = "main")]
| ^^^^^^ | ^^^^^^ expected `Struct`, found `()`
| |
| expected `Struct`, found `()`
| expected due to this
error[E0308]: `match` arms have incompatible types error[E0308]: `match` arms have incompatible types
--> tests/ui/default-attribute/incorrect_type_struct.rs:8:23 --> 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 error[E0308]: `match` arms have incompatible types
--> tests/ui/default-attribute/incorrect_type_struct.rs:11:23 --> tests/ui/default-attribute/incorrect_type_struct.rs:11:23
| |
5 | #[derive(Deserialize)] 5 | #[derive(Deserialize)]
| ----------- | -----------
| | | |
| this is found to be of type `i8` | this is found to be of type `i8`
@@ -51,7 +48,7 @@ error[E0308]: mismatched types
error[E0308]: mismatched types error[E0308]: mismatched types
--> tests/ui/default-attribute/incorrect_type_struct.rs:11:23 --> tests/ui/default-attribute/incorrect_type_struct.rs:11:23
| |
5 | #[derive(Deserialize)] 5 | #[derive(Deserialize)]
| ----------- expected due to the type of this binding | ----------- expected due to the type of this binding
... ...
11 | #[serde(default = "main")] 11 | #[serde(default = "main")]
@@ -2,10 +2,7 @@ error[E0308]: mismatched types
--> tests/ui/default-attribute/incorrect_type_tuple.rs:6:19 --> tests/ui/default-attribute/incorrect_type_tuple.rs:6:19
| |
6 | #[serde(default = "main")] 6 | #[serde(default = "main")]
| ^^^^^^ | ^^^^^^ expected `Tuple`, found `()`
| |
| expected `Tuple`, found `()`
| expected due to this
error[E0308]: `match` arms have incompatible types error[E0308]: `match` arms have incompatible types
--> tests/ui/default-attribute/incorrect_type_tuple.rs:7:36 --> tests/ui/default-attribute/incorrect_type_tuple.rs:7:36
+15 -5
View File
@@ -2,10 +2,15 @@ error[E0277]: the trait bound `MyStruct: Serialize` is not satisfied
--> tests/ui/on_unimplemented.rs:21:15 --> tests/ui/on_unimplemented.rs:21:15
| |
21 | to_string(&MyStruct); 21 | to_string(&MyStruct);
| --------- ^^^^^^^^^ the trait `Serialize` is not implemented for `MyStruct` | --------- ^^^^^^^^^ unsatisfied trait bound
| | | |
| required by a bound introduced by this call | 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 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 = note: for types from other crates check whether the crate offers a `serde` feature flag
= help: the following other types implement trait `Serialize`: = 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` note: required by a bound in `to_string`
--> tests/ui/on_unimplemented.rs:6:8 --> tests/ui/on_unimplemented.rs:6:8
| |
4 | fn to_string<T>(_: &T) -> String 4 | fn to_string<T>(_: &T) -> String
| --------- required by a bound in this function | --------- required by a bound in this function
5 | where 5 | where
6 | T: Serialize, 6 | T: Serialize,
| ^^^^^^^^^ required by this bound in `to_string` | ^^^^^^^^^ required by this bound in `to_string`
error[E0277]: the trait bound `MyStruct: Deserialize<'_>` is not satisfied error[E0277]: the trait bound `MyStruct: Deserialize<'_>` is not satisfied
--> tests/ui/on_unimplemented.rs:22:23 --> tests/ui/on_unimplemented.rs:22:23
| |
22 | let _: MyStruct = from_str(""); 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 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 = note: for types from other crates check whether the crate offers a `serde` feature flag
= help: the following other types implement trait `Deserialize<'de>`: = help: the following other types implement trait `Deserialize<'de>`:
@@ -1,11 +1,11 @@
error: #[serde(transparent)] requires at least one field that is neither skipped nor has a default 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 --> tests/ui/transparent/de_at_least_one.rs:4:1
| |
4 | / #[serde(transparent)] 4 | / #[serde(transparent)]
5 | | struct S { 5 | | struct S {
6 | | #[serde(skip)] 6 | | #[serde(skip)]
7 | | a: u8, 7 | | a: u8,
8 | | #[serde(default)] 8 | | #[serde(default)]
9 | | b: u8, 9 | | b: u8,
10 | | } 10 | | }
| |_^ | |_^
@@ -1,10 +1,10 @@
error: variant `Struct` cannot have both #[serde(deserialize_with)] and a field `f1` marked with #[serde(skip_deserializing)] 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 --> tests/ui/with-variant/skip_de_struct_field.rs:5:5
| |
5 | / #[serde(deserialize_with = "deserialize_some_other_variant")] 5 | / #[serde(deserialize_with = "deserialize_some_other_variant")]
6 | | Struct { 6 | | Struct {
7 | | #[serde(skip_deserializing)] 7 | | #[serde(skip_deserializing)]
8 | | f1: String, 8 | | f1: String,
9 | | f2: u8, 9 | | f2: u8,
10 | | }, 10 | | },
| |_____^ | |_____^
@@ -1,10 +1,10 @@
error: variant `Struct` cannot have both #[serde(serialize_with)] and a field `f1` marked with #[serde(skip_serializing)] 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 --> tests/ui/with-variant/skip_ser_struct_field.rs:5:5
| |
5 | / #[serde(serialize_with = "serialize_some_other_variant")] 5 | / #[serde(serialize_with = "serialize_some_other_variant")]
6 | | Struct { 6 | | Struct {
7 | | #[serde(skip_serializing)] 7 | | #[serde(skip_serializing)]
8 | | f1: String, 8 | | f1: String,
9 | | f2: u8, 9 | | f2: u8,
10 | | }, 10 | | },
| |_____^ | |_____^
@@ -1,10 +1,10 @@
error: variant `Struct` cannot have both #[serde(serialize_with)] and a field `f1` marked with #[serde(skip_serializing_if)] 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 --> tests/ui/with-variant/skip_ser_struct_field_if.rs:5:5
| |
5 | / #[serde(serialize_with = "serialize_some_newtype_variant")] 5 | / #[serde(serialize_with = "serialize_some_newtype_variant")]
6 | | Struct { 6 | | Struct {
7 | | #[serde(skip_serializing_if = "always")] 7 | | #[serde(skip_serializing_if = "always")]
8 | | f1: String, 8 | | f1: String,
9 | | f2: u8, 9 | | f2: u8,
10 | | }, 10 | | },
| |_____^ | |_____^
@@ -13,7 +13,7 @@ error[E0277]: the trait bound `&u8: Serializer` is not satisfied
note: required by a bound in `w::serialize` note: required by a bound in `w::serialize`
--> tests/ui/with/incorrect_type.rs:9:28 --> tests/ui/with/incorrect_type.rs:9:28
| |
9 | pub fn serialize<T, S: Serializer>(_: S) -> Result<S::Ok, S::Error> { 9 | pub fn serialize<T, S: Serializer>(_: S) -> Result<S::Ok, S::Error> {
| ^^^^^^^^^^ required by this bound in `serialize` | ^^^^^^^^^^ required by this bound in `serialize`
error[E0061]: this function takes 1 argument but 2 arguments were supplied 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 note: function defined here
--> tests/ui/with/incorrect_type.rs:9:12 --> tests/ui/with/incorrect_type.rs:9:12
| |
9 | pub fn serialize<T, S: Serializer>(_: S) -> Result<S::Ok, S::Error> { 9 | pub fn serialize<T, S: Serializer>(_: S) -> Result<S::Ok, S::Error> {
| ^^^^^^^^^ | ^^^^^^^^^
error[E0277]: the trait bound `&u8: Serializer` is not satisfied 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` note: required by a bound in `w::serialize`
--> tests/ui/with/incorrect_type.rs:9:28 --> tests/ui/with/incorrect_type.rs:9:28
| |
9 | pub fn serialize<T, S: Serializer>(_: S) -> Result<S::Ok, S::Error> { 9 | pub fn serialize<T, S: Serializer>(_: S) -> Result<S::Ok, S::Error> {
| ^^^^^^^^^^ required by this bound in `serialize` | ^^^^^^^^^^ required by this bound in `serialize`
error[E0061]: this function takes 1 argument but 2 arguments were supplied 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 note: function defined here
--> tests/ui/with/incorrect_type.rs:9:12 --> tests/ui/with/incorrect_type.rs:9:12
| |
9 | pub fn serialize<T, S: Serializer>(_: S) -> Result<S::Ok, S::Error> { 9 | pub fn serialize<T, S: Serializer>(_: S) -> Result<S::Ok, S::Error> {
| ^^^^^^^^^ | ^^^^^^^^^
error[E0277]: the trait bound `&u8: Serializer` is not satisfied error[E0277]: the trait bound `&u8: Serializer` is not satisfied