mirror of
https://github.com/serde-rs/serde.git
synced 2025-09-26 20:40:35 +00:00
Allow more dead code
This commit is contained in:
parent
363deb84cc
commit
c85e4240be
@ -1,3 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use serde_derive::Deserialize;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use serde_derive::Deserialize;
|
||||
|
||||
macro_rules! bug {
|
||||
|
@ -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};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![allow(clippy::trivially_copy_pass_by_ref)]
|
||||
#![allow(clippy::trivially_copy_pass_by_ref, dead_code)]
|
||||
|
||||
use serde_derive::Deserialize;
|
||||
|
||||
|
@ -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};
|
||||
|
@ -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)]
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![allow(clippy::redundant_field_names)]
|
||||
#![allow(clippy::redundant_field_names, dead_code)]
|
||||
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![allow(clippy::used_underscore_binding)]
|
||||
#![allow(clippy::used_underscore_binding, dead_code)]
|
||||
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
|
@ -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")]
|
||||
|
@ -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
|
||||
|
@ -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 | | }
|
||||
| |_^
|
||||
|
@ -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 | | }
|
||||
| |_^
|
||||
|
@ -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`
|
||||
|
@ -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`
|
||||
|
@ -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`
|
||||
|
@ -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`
|
||||
|
@ -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
|
||||
|
@ -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")]
|
||||
|
@ -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
|
||||
|
@ -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>(_: &T) -> String
|
||||
4 | fn to_string<T>(_: &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>`:
|
||||
|
@ -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 | | }
|
||||
| |_^
|
||||
|
@ -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 | | },
|
||||
| |_____^
|
||||
|
@ -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 | | },
|
||||
| |_____^
|
||||
|
@ -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 | | },
|
||||
| |_____^
|
||||
|
@ -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<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`
|
||||
|
||||
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<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
|
||||
@ -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<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`
|
||||
|
||||
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<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
|
||||
|
Loading…
x
Reference in New Issue
Block a user