serde/test_suite/tests/test_gen.rs

894 lines
22 KiB
Rust
Raw Normal View History

2018-08-12 12:54:53 -05:00
// These just test that serde_derive is able to produce code that compiles
2016-05-15 17:54:20 -05:00
// successfully when there are a variety of generics and non-(de)serializable
// types involved.
2016-05-07 14:33:59 -05:00
2017-09-09 13:34:08 -05:00
#![deny(warnings)]
#![allow(
unknown_lints,
mixed_script_confusables,
Ignore derive_partial_eq_without_eq clippy lint error: you are deriving `PartialEq` and can implement `Eq` --> serde/src/de/value.rs:51:17 | 51 | #[derive(Clone, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = note: `-D clippy::derive-partial-eq-without-eq` implied by `-D clippy::all` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> serde_derive/src/internals/case.rs:13:23 | 13 | #[derive(Copy, Clone, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/unstable/mod.rs:6:21 | 6 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_ignored_any.rs:7:10 | 7 | #[derive(PartialEq, Debug, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_identifier.rs:7:34 | 7 | #[derive(Deserialize, Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_identifier.rs:24:34 | 24 | #[derive(Deserialize, Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_identifier.rs:41:34 | 41 | #[derive(Deserialize, Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_identifier.rs:59:34 | 59 | #[derive(Deserialize, Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_ser.rs:46:10 | 46 | #[derive(PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_value.rs:11:34 | 11 | #[derive(Deserialize, Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de_error.rs:15:23 | 15 | #[derive(Copy, Clone, PartialEq, Debug, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de_error.rs:18:10 | 18 | #[derive(PartialEq, Debug, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de_error.rs:26:10 | 26 | #[derive(PartialEq, Debug, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de_error.rs:34:10 | 34 | #[derive(PartialEq, Debug, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de_error.rs:41:19 | 41 | #[derive(Default, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de_error.rs:60:10 | 60 | #[derive(PartialEq, Debug, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_borrow.rs:70:34 | 70 | #[derive(Deserialize, Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_borrow.rs:97:34 | 97 | #[derive(Deserialize, Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_borrow.rs:106:34 | 106 | #[derive(Deserialize, Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de.rs:43:23 | 43 | #[derive(Copy, Clone, PartialEq, Debug, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de.rs:46:10 | 46 | #[derive(PartialEq, Debug, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de.rs:49:10 | 49 | #[derive(PartialEq, Debug, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de.rs:52:10 | 52 | #[derive(PartialEq, Debug, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de.rs:76:10 | 76 | #[derive(PartialEq, Debug, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de.rs:82:10 | 82 | #[derive(PartialEq, Debug, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de.rs:102:10 | 102 | #[derive(PartialEq, Debug, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de.rs:109:19 | 109 | #[derive(Default, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de.rs:128:10 | 128 | #[derive(PartialEq, Debug, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de.rs:135:10 | 135 | #[derive(PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_de.rs:185:14 | 185 | #[derive(PartialEq, Debug, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:25:17 | 25 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:110:17 | 110 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:580:21 | 580 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:607:21 | 607 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:681:21 | 681 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:684:21 | 684 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:816:21 | 816 | #[derive(Debug, PartialEq, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:976:21 | 976 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:1027:21 | 1027 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:1273:21 | 1273 | #[derive(Debug, PartialEq, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:1342:21 | 1342 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:1413:21 | 1413 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:1450:21 | 1450 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:1474:21 | 1474 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:1509:21 | 1509 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:1543:21 | 1543 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:1601:21 | 1601 | #[derive(Debug, PartialEq, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:1743:45 | 1743 | #[derive(Serialize, Deserialize, Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:1763:45 | 1763 | #[derive(Serialize, Deserialize, Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:1770:45 | 1770 | #[derive(Serialize, Deserialize, Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:1870:21 | 1870 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_macros.rs:1888:21 | 1888 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:108:17 | 108 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:124:17 | 124 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:147:17 | 147 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:344:17 | 344 | #[derive(Debug, PartialEq, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:394:17 | 394 | #[derive(Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:413:17 | 413 | #[derive(Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:458:17 | 458 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:512:17 | 512 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:520:17 | 520 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:528:17 | 528 | #[derive(Debug, PartialEq, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:647:17 | 647 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_gen.rs:835:17 | 835 | #[derive(Debug, PartialEq, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:675:17 | 675 | #[derive(Debug, PartialEq, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:1047:17 | 1047 | #[derive(Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:1050:17 | 1050 | #[derive(Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:1196:17 | 1196 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:1514:17 | 1514 | #[derive(Debug, PartialEq, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:1548:41 | 1548 | #[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:1566:41 | 1566 | #[derive(Clone, Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:1600:30 | 1600 | #[derive(Clone, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:1803:21 | 1803 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:1843:21 | 1843 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:1852:21 | 1852 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:1947:21 | 1947 | #[derive(Debug, PartialEq, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2003:21 | 2003 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2037:21 | 2037 | #[derive(Debug, PartialEq, Serialize, Deserialize)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2074:45 | 2074 | #[derive(Deserialize, Serialize, Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2080:45 | 2080 | #[derive(Deserialize, Serialize, Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2157:38 | 2157 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2193:38 | 2193 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2200:38 | 2200 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2240:38 | 2240 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2279:38 | 2279 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2316:38 | 2316 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2359:38 | 2359 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2390:38 | 2390 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2421:38 | 2421 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2426:38 | 2426 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2483:38 | 2483 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2507:38 | 2507 | #[derive(Serialize, Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2521:27 | 2521 | #[derive(Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2552:27 | 2552 | #[derive(Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2558:27 | 2558 | #[derive(Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2586:14 | 2586 | #[derive(PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2624:27 | 2624 | #[derive(Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq error: you are deriving `PartialEq` and can implement `Eq` --> test_suite/tests/test_annotations.rs:2647:27 | 2647 | #[derive(Deserialize, PartialEq, Debug)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
2022-05-21 22:36:25 -05:00
clippy::derive_partial_eq_without_eq,
clippy::items_after_statements,
clippy::missing_errors_doc,
clippy::missing_panics_doc,
clippy::must_use_candidate,
// Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422
clippy::nonstandard_macro_braces,
2021-01-25 15:25:53 -06:00
clippy::ptr_arg,
clippy::too_many_lines,
Ignore more type_repetition_in_bounds I'm not sure what is going on with this lint but it's triggering in a lot of test code. Will need to investigate further. error: this type has already been used as a bound predicate --> test_suite/tests/test_gen.rs:194:21 | 194 | bound = "E: SerializeWith + DeserializeWith" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::type-repetition-in-bounds` implied by `-D clippy::pedantic` = help: consider combining the bounds: `"E: SerializeWith + DeserializeWith": "E: SerializeWith + DeserializeWith" + "E: SerializeWith + DeserializeWith"` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds error: this type has already been used as a bound predicate --> test_suite/tests/test_gen.rs:184:21 | 184 | #[serde(bound = "D: SerializeWith + DeserializeWith")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider combining the bounds: `"D: SerializeWith + DeserializeWith": "D: SerializeWith + DeserializeWith" + "D: SerializeWith + DeserializeWith"` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds error: this type has already been used as a bound predicate --> test_suite/tests/test_gen.rs:210:31 | 210 | bound(serialize = "E: SerializeWith") | ^^^^^^^^^^^^^^^^^^ | = help: consider combining the bounds: `"E: SerializeWith": "E: SerializeWith"` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds error: this type has already been used as a bound predicate --> test_suite/tests/test_gen.rs:201:31 | 201 | #[serde(bound(serialize = "D: SerializeWith", deserialize = "D: DeserializeWith"))] | ^^^^^^^^^^^^^^^^^^ | = help: consider combining the bounds: `"D: SerializeWith": "D: SerializeWith"` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds error: this type has already been used as a bound predicate --> test_suite/tests/test_gen.rs:231:21 | 231 | bound = "E: SerializeWith + DeserializeWith" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider combining the bounds: `"E: SerializeWith + DeserializeWith": "E: SerializeWith + DeserializeWith" + "E: SerializeWith + DeserializeWith"` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds error: this type has already been used as a bound predicate --> test_suite/tests/test_gen.rs:221:21 | 221 | #[serde(bound = "D: SerializeWith + DeserializeWith")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider combining the bounds: `"D: SerializeWith + DeserializeWith": "D: SerializeWith + DeserializeWith" + "D: SerializeWith + DeserializeWith"` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds error: this type has already been used as a bound predicate --> test_suite/tests/test_gen.rs:247:31 | 247 | bound(serialize = "E: SerializeWith") | ^^^^^^^^^^^^^^^^^^ | = help: consider combining the bounds: `"E: SerializeWith": "E: SerializeWith"` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds error: this type has already been used as a bound predicate --> test_suite/tests/test_gen.rs:238:31 | 238 | #[serde(bound(serialize = "D: SerializeWith", deserialize = "D: DeserializeWith"))] | ^^^^^^^^^^^^^^^^^^ | = help: consider combining the bounds: `"D: SerializeWith": "D: SerializeWith"` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds error: this type has already been used as a bound predicate --> test_suite/tests/test_annotations.rs:84:5 | 84 | C: MyDefault, | ^^^^^^^^^^^^ | = note: `-D clippy::type-repetition-in-bounds` implied by `-D clippy::pedantic` = help: consider combining the bounds: `C: MyDefault` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds error: this type has already been used as a bound predicate --> test_suite/tests/test_annotations.rs:85:5 | 85 | E: MyDefault, | ^^^^^^^^^^^^ | = help: consider combining the bounds: `E: MyDefault` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds error: this type has already been used as a bound predicate --> test_suite/tests/test_annotations.rs:105:5 | 105 | C: MyDefault; | ^^^^^^^^^^^^ | = help: consider combining the bounds: `C: MyDefault` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds error: this type has already been used as a bound predicate --> test_suite/tests/test_annotations.rs:1066:5 | 1066 | B: 'a, | ^^^^^ | = help: consider combining the bounds: `` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds error: this type has already been used as a bound predicate --> test_suite/tests/test_annotations.rs:1067:5 | 1067 | D: SerializeWith, | ^^^^^^^^^^^^^^^^ | = help: consider combining the bounds: `D: SerializeWith` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds error: this type has already been used as a bound predicate --> test_suite/tests/test_annotations.rs:1106:5 | 1106 | B: SerializeWith, | ^^^^^^^^^^^^^^^^ | = help: consider combining the bounds: `B: SerializeWith` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds error: this type has already been used as a bound predicate --> test_suite/tests/test_annotations.rs:1150:5 | 1150 | B: SerializeWith, | ^^^^^^^^^^^^^^^^ | = help: consider combining the bounds: `B: SerializeWith` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds error: this type has already been used as a bound predicate --> test_suite/tests/test_annotations.rs:1368:5 | 1368 | B: DeserializeWith, | ^^^^^^^^^^^^^^^^^^ | = help: consider combining the bounds: `B: DeserializeWith` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds
2022-04-30 23:30:38 -05:00
clippy::trivially_copy_pass_by_ref,
clippy::type_repetition_in_bounds
)]
2018-12-31 20:44:24 -06:00
use serde::de::DeserializeOwned;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
2016-05-07 14:33:59 -05:00
use std::borrow::Cow;
use std::marker::PhantomData;
use std::option::Option as StdOption;
2017-02-01 11:42:12 -06:00
use std::result::Result as StdResult;
// Try to trip up the generated code if it fails to use fully qualified paths.
#[allow(dead_code)]
struct Result;
2017-02-01 11:42:12 -06:00
#[allow(dead_code)]
struct Ok;
#[allow(dead_code)]
struct Err;
#[allow(dead_code)]
struct Option;
#[allow(dead_code)]
struct Some;
#[allow(dead_code)]
struct None;
2016-05-07 14:33:59 -05:00
//////////////////////////////////////////////////////////////////////////
#[test]
fn test_gen() {
#[derive(Serialize, Deserialize)]
struct With<T> {
t: T,
#[serde(serialize_with = "ser_x", deserialize_with = "de_x")]
x: X,
}
assert::<With<i32>>();
#[derive(Serialize, Deserialize)]
struct WithTogether<T> {
t: T,
#[serde(with = "both_x")]
x: X,
}
assert::<WithTogether<i32>>();
#[derive(Serialize, Deserialize)]
struct WithRef<'a, T: 'a> {
#[serde(skip_deserializing)]
t: StdOption<&'a T>,
#[serde(serialize_with = "ser_x", deserialize_with = "de_x")]
x: X,
}
assert::<WithRef<i32>>();
#[derive(Serialize, Deserialize)]
struct PhantomX {
x: PhantomData<X>,
}
assert::<PhantomX>();
#[derive(Serialize, Deserialize)]
struct PhantomT<T> {
t: PhantomData<T>,
}
assert::<PhantomT<X>>();
#[derive(Serialize, Deserialize)]
struct NoBounds<T> {
t: T,
option: StdOption<T>,
boxed: Box<T>,
option_boxed: StdOption<Box<T>>,
}
assert::<NoBounds<i32>>();
#[derive(Serialize, Deserialize)]
enum EnumWith<T> {
Unit,
2018-04-30 03:41:22 -05:00
Newtype(#[serde(serialize_with = "ser_x", deserialize_with = "de_x")] X),
Tuple(
T,
2018-04-30 03:41:22 -05:00
#[serde(serialize_with = "ser_x", deserialize_with = "de_x")] X,
2017-04-13 14:28:23 -05:00
),
Struct {
t: T,
#[serde(serialize_with = "ser_x", deserialize_with = "de_x")]
x: X,
2017-04-13 14:28:23 -05:00
},
}
assert::<EnumWith<i32>>();
#[derive(Serialize)]
2017-04-13 14:28:23 -05:00
struct MultipleRef<'a, 'b, 'c, T>
where
T: 'c,
'c: 'b,
'b: 'a,
{
t: T,
rrrt: &'a &'b &'c T,
}
assert_ser::<MultipleRef<i32>>();
2016-05-07 14:33:59 -05:00
#[derive(Serialize, Deserialize)]
2018-04-30 03:41:22 -05:00
struct Newtype(#[serde(serialize_with = "ser_x", deserialize_with = "de_x")] X);
assert::<Newtype>();
2016-05-19 01:46:06 -05:00
#[derive(Serialize, Deserialize)]
struct Tuple<T>(
T,
2018-04-30 03:41:22 -05:00
#[serde(serialize_with = "ser_x", deserialize_with = "de_x")] X,
);
assert::<Tuple<i32>>();
#[derive(Serialize, Deserialize)]
enum TreeNode<D> {
Split {
left: Box<TreeNode<D>>,
right: Box<TreeNode<D>>,
},
2017-12-23 22:13:08 -06:00
Leaf {
data: D,
},
}
assert::<TreeNode<i32>>();
#[derive(Serialize, Deserialize)]
struct ListNode<D> {
data: D,
next: Box<ListNode<D>>,
}
assert::<ListNode<i32>>();
#[derive(Serialize, Deserialize)]
struct RecursiveA {
b: Box<RecursiveB>,
}
assert::<RecursiveA>();
#[derive(Serialize, Deserialize)]
enum RecursiveB {
A(RecursiveA),
}
assert::<RecursiveB>();
#[derive(Serialize, Deserialize)]
struct RecursiveGenericA<T> {
t: T,
b: Box<RecursiveGenericB<T>>,
}
assert::<RecursiveGenericA<i32>>();
#[derive(Serialize, Deserialize)]
enum RecursiveGenericB<T> {
T(T),
A(RecursiveGenericA<T>),
}
assert::<RecursiveGenericB<i32>>();
#[derive(Serialize)]
struct OptionStatic<'a> {
a: StdOption<&'a str>,
b: StdOption<&'static str>,
}
assert_ser::<OptionStatic>();
#[derive(Serialize, Deserialize)]
2017-12-23 22:13:08 -06:00
#[serde(bound = "D: SerializeWith + DeserializeWith")]
struct WithTraits1<D, E> {
2018-04-30 03:41:22 -05:00
#[serde(
serialize_with = "SerializeWith::serialize_with",
deserialize_with = "DeserializeWith::deserialize_with"
)]
d: D,
2018-04-30 03:41:22 -05:00
#[serde(
serialize_with = "SerializeWith::serialize_with",
deserialize_with = "DeserializeWith::deserialize_with",
bound = "E: SerializeWith + DeserializeWith"
)]
e: E,
}
assert::<WithTraits1<X, X>>();
#[derive(Serialize, Deserialize)]
2018-11-21 03:13:17 -06:00
#[serde(bound(serialize = "D: SerializeWith", deserialize = "D: DeserializeWith"))]
struct WithTraits2<D, E> {
2018-04-30 03:41:22 -05:00
#[serde(
serialize_with = "SerializeWith::serialize_with",
deserialize_with = "DeserializeWith::deserialize_with"
)]
d: D,
2018-04-30 03:41:22 -05:00
#[serde(
2018-07-08 21:02:44 -05:00
serialize_with = "SerializeWith::serialize_with",
bound(serialize = "E: SerializeWith")
2018-04-30 03:41:22 -05:00
)]
#[serde(
deserialize_with = "DeserializeWith::deserialize_with",
bound(deserialize = "E: DeserializeWith")
)]
e: E,
}
assert::<WithTraits2<X, X>>();
#[derive(Serialize, Deserialize)]
#[serde(bound = "D: SerializeWith + DeserializeWith")]
enum VariantWithTraits1<D, E> {
#[serde(
serialize_with = "SerializeWith::serialize_with",
deserialize_with = "DeserializeWith::deserialize_with"
)]
D(D),
#[serde(
serialize_with = "SerializeWith::serialize_with",
deserialize_with = "DeserializeWith::deserialize_with",
bound = "E: SerializeWith + DeserializeWith"
)]
E(E),
}
assert::<VariantWithTraits1<X, X>>();
#[derive(Serialize, Deserialize)]
2018-11-21 03:13:17 -06:00
#[serde(bound(serialize = "D: SerializeWith", deserialize = "D: DeserializeWith"))]
enum VariantWithTraits2<D, E> {
#[serde(
serialize_with = "SerializeWith::serialize_with",
deserialize_with = "DeserializeWith::deserialize_with"
)]
D(D),
#[serde(
2018-07-08 21:02:44 -05:00
serialize_with = "SerializeWith::serialize_with",
bound(serialize = "E: SerializeWith")
)]
#[serde(
deserialize_with = "DeserializeWith::deserialize_with",
bound(deserialize = "E: DeserializeWith")
)]
E(E),
}
assert::<VariantWithTraits2<X, X>>();
#[derive(Serialize, Deserialize)]
struct CowStr<'a>(Cow<'a, str>);
assert::<CowStr>();
#[derive(Serialize, Deserialize)]
#[serde(bound(deserialize = "T::Owned: DeserializeOwned"))]
struct CowT<'a, T: ?Sized + 'a + ToOwned>(Cow<'a, T>);
assert::<CowT<str>>();
#[derive(Serialize, Deserialize)]
struct EmptyStruct {}
assert::<EmptyStruct>();
#[derive(Serialize, Deserialize)]
enum EmptyEnumVariant {
EmptyStruct {},
}
assert::<EmptyEnumVariant>();
2017-01-10 03:20:01 -06:00
2017-03-08 23:02:15 -06:00
#[derive(Serialize, Deserialize)]
2017-01-10 03:20:01 -06:00
struct NonAsciiIdents {
2020-04-19 19:32:11 -05:00
σ: f64,
2017-01-10 03:20:01 -06:00
}
2017-01-11 13:02:24 -06:00
#[derive(Serialize, Deserialize)]
struct EmptyBraced {}
#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
struct EmptyBracedDenyUnknown {}
#[derive(Serialize, Deserialize)]
struct BracedSkipAll {
#[serde(skip_deserializing)]
f: u8,
2017-01-11 13:02:24 -06:00
}
#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
struct BracedSkipAllDenyUnknown {
#[serde(skip_deserializing)]
f: u8,
2017-01-11 13:02:24 -06:00
}
2017-03-08 23:02:15 -06:00
#[derive(Serialize, Deserialize)]
2017-01-11 13:02:24 -06:00
struct EmptyTuple();
2017-03-08 23:02:15 -06:00
#[derive(Serialize, Deserialize)]
2017-01-11 13:02:24 -06:00
#[serde(deny_unknown_fields)]
struct EmptyTupleDenyUnknown();
#[derive(Serialize, Deserialize)]
2018-04-30 03:41:22 -05:00
struct TupleSkipAll(#[serde(skip_deserializing)] u8);
2017-01-11 13:02:24 -06:00
#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
2018-04-30 03:41:22 -05:00
struct TupleSkipAllDenyUnknown(#[serde(skip_deserializing)] u8);
2017-01-11 13:02:24 -06:00
#[derive(Serialize, Deserialize)]
enum EmptyEnum {}
#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
enum EmptyEnumDenyUnknown {}
#[derive(Serialize, Deserialize)]
enum EnumSkipAll {
#[serde(skip_deserializing)]
#[allow(dead_code)]
Variant,
}
2017-03-08 23:02:15 -06:00
#[derive(Serialize, Deserialize)]
2017-01-11 13:02:24 -06:00
enum EmptyVariants {
Braced {},
Tuple(),
BracedSkip {
#[serde(skip_deserializing)]
f: u8,
},
2018-04-30 03:41:22 -05:00
TupleSkip(#[serde(skip_deserializing)] u8),
2017-01-11 13:02:24 -06:00
}
2017-03-08 23:02:15 -06:00
#[derive(Serialize, Deserialize)]
2017-01-11 13:02:24 -06:00
#[serde(deny_unknown_fields)]
enum EmptyVariantsDenyUnknown {
Braced {},
Tuple(),
BracedSkip {
#[serde(skip_deserializing)]
f: u8,
},
2018-04-30 03:41:22 -05:00
TupleSkip(#[serde(skip_deserializing)] u8),
2017-01-11 13:02:24 -06:00
}
#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
struct UnitDenyUnknown;
2017-04-05 19:34:13 -05:00
#[derive(Serialize, Deserialize)]
struct EmptyArray {
empty: [X; 0],
}
enum Or<A, B> {
A(A),
B(B),
}
#[derive(Serialize, Deserialize)]
#[serde(untagged, remote = "Or")]
enum OrDef<A, B> {
A(A),
B(B),
}
struct Str<'a>(&'a str);
#[derive(Serialize, Deserialize)]
#[serde(remote = "Str")]
struct StrDef<'a>(&'a str);
#[derive(Serialize, Deserialize)]
struct Remote<'a> {
#[serde(with = "OrDef")]
or: Or<u8, bool>,
#[serde(borrow, with = "StrDef")]
s: Str<'a>,
}
#[derive(Serialize, Deserialize)]
enum BorrowVariant<'a> {
#[serde(borrow, with = "StrDef")]
S(Str<'a>),
}
mod vis {
2018-12-31 20:44:24 -06:00
use serde::{Deserialize, Serialize};
pub struct S;
#[derive(Serialize, Deserialize)]
#[serde(remote = "S")]
pub struct SDef;
}
// This would not work if SDef::serialize / deserialize are private.
#[derive(Serialize, Deserialize)]
struct RemoteVisibility {
#[serde(with = "vis::SDef")]
s: vis::S,
}
#[derive(Serialize, Deserialize)]
2018-03-27 03:56:05 -05:00
#[serde(remote = "Self")]
struct RemoteSelf;
#[derive(Serialize, Deserialize)]
enum ExternallyTaggedVariantWith {
#[serde(serialize_with = "ser_x")]
#[serde(deserialize_with = "de_x")]
#[allow(dead_code)]
Newtype(X),
#[serde(serialize_with = "serialize_some_other_variant")]
#[serde(deserialize_with = "deserialize_some_other_variant")]
#[allow(dead_code)]
Tuple(String, u8),
#[serde(serialize_with = "ser_x")]
#[serde(deserialize_with = "de_x")]
#[allow(dead_code)]
Struct1 { x: X },
#[serde(serialize_with = "serialize_some_other_variant")]
#[serde(deserialize_with = "deserialize_some_other_variant")]
#[allow(dead_code)]
Struct { f1: String, f2: u8 },
#[serde(serialize_with = "serialize_some_unit_variant")]
#[serde(deserialize_with = "deserialize_some_unit_variant")]
#[allow(dead_code)]
Unit,
}
assert_ser::<ExternallyTaggedVariantWith>();
#[derive(Serialize, Deserialize)]
#[serde(tag = "t")]
enum InternallyTaggedVariantWith {
#[serde(serialize_with = "ser_x")]
#[serde(deserialize_with = "de_x")]
#[allow(dead_code)]
Newtype(X),
#[serde(serialize_with = "ser_x")]
#[serde(deserialize_with = "de_x")]
#[allow(dead_code)]
Struct1 { x: X },
#[serde(serialize_with = "serialize_some_other_variant")]
#[serde(deserialize_with = "deserialize_some_other_variant")]
#[allow(dead_code)]
Struct { f1: String, f2: u8 },
#[serde(serialize_with = "serialize_some_unit_variant")]
#[serde(deserialize_with = "deserialize_some_unit_variant")]
#[allow(dead_code)]
Unit,
}
assert_ser::<InternallyTaggedVariantWith>();
#[derive(Serialize, Deserialize)]
#[serde(tag = "t", content = "c")]
enum AdjacentlyTaggedVariantWith {
#[serde(serialize_with = "ser_x")]
#[serde(deserialize_with = "de_x")]
#[allow(dead_code)]
Newtype(X),
#[serde(serialize_with = "serialize_some_other_variant")]
#[serde(deserialize_with = "deserialize_some_other_variant")]
#[allow(dead_code)]
Tuple(String, u8),
#[serde(serialize_with = "ser_x")]
#[serde(deserialize_with = "de_x")]
#[allow(dead_code)]
Struct1 { x: X },
#[serde(serialize_with = "serialize_some_other_variant")]
#[serde(deserialize_with = "deserialize_some_other_variant")]
#[allow(dead_code)]
Struct { f1: String, f2: u8 },
#[serde(serialize_with = "serialize_some_unit_variant")]
#[serde(deserialize_with = "deserialize_some_unit_variant")]
#[allow(dead_code)]
Unit,
}
assert_ser::<AdjacentlyTaggedVariantWith>();
#[derive(Serialize, Deserialize)]
#[serde(untagged)]
enum UntaggedVariantWith {
#[serde(serialize_with = "ser_x")]
#[serde(deserialize_with = "de_x")]
#[allow(dead_code)]
Newtype(X),
#[serde(serialize_with = "serialize_some_other_variant")]
#[serde(deserialize_with = "deserialize_some_other_variant")]
#[allow(dead_code)]
Tuple(String, u8),
#[serde(serialize_with = "ser_x")]
#[serde(deserialize_with = "de_x")]
#[allow(dead_code)]
Struct1 { x: X },
#[serde(serialize_with = "serialize_some_other_variant")]
#[serde(deserialize_with = "deserialize_some_other_variant")]
#[allow(dead_code)]
Struct { f1: String, f2: u8 },
#[serde(serialize_with = "serialize_some_unit_variant")]
#[serde(deserialize_with = "deserialize_some_unit_variant")]
#[allow(dead_code)]
Unit,
}
assert_ser::<UntaggedVariantWith>();
2017-09-09 13:34:08 -05:00
2018-05-02 00:25:06 -05:00
#[derive(Serialize, Deserialize)]
struct FlattenWith {
#[serde(flatten, serialize_with = "ser_x", deserialize_with = "de_x")]
x: X,
}
assert::<FlattenWith>();
#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
struct FlattenDenyUnknown<T> {
#[serde(flatten)]
t: T,
}
2017-09-09 13:34:08 -05:00
#[derive(Serialize, Deserialize)]
struct StaticStrStruct<'a> {
a: &'a str,
b: &'static str,
}
#[derive(Serialize, Deserialize)]
struct StaticStrTupleStruct<'a>(&'a str, &'static str);
#[derive(Serialize, Deserialize)]
struct StaticStrNewtypeStruct(&'static str);
#[derive(Serialize, Deserialize)]
enum StaticStrEnum<'a> {
2017-12-23 22:13:08 -06:00
Struct { a: &'a str, b: &'static str },
2017-09-09 13:34:08 -05:00
Tuple(&'a str, &'static str),
Newtype(&'static str),
}
#[derive(Serialize, Deserialize)]
struct SkippedStaticStr {
#[serde(skip_deserializing)]
skipped: &'static str,
other: isize,
}
assert::<SkippedStaticStr>();
macro_rules! T {
2018-04-30 03:41:22 -05:00
() => {
()
};
}
#[derive(Serialize, Deserialize)]
struct TypeMacro<T> {
mac: T!(),
marker: PhantomData<T>,
}
assert::<TypeMacro<X>>();
#[derive(Serialize)]
struct BigArray {
#[serde(serialize_with = "<[_]>::serialize")]
array: [u8; 256],
}
assert_ser::<BigArray>();
2018-04-10 10:16:23 -05:00
trait AssocSerde {
type Assoc;
}
struct NoSerdeImpl;
impl AssocSerde for NoSerdeImpl {
type Assoc = u32;
}
#[derive(Serialize, Deserialize)]
struct AssocDerive<T: AssocSerde> {
2018-04-30 03:41:22 -05:00
assoc: T::Assoc,
2018-04-10 10:16:23 -05:00
}
assert::<AssocDerive<NoSerdeImpl>>();
#[derive(Serialize, Deserialize)]
struct AssocDeriveMulti<S, T: AssocSerde> {
s: S,
assoc: T::Assoc,
}
assert::<AssocDeriveMulti<i32, NoSerdeImpl>>();
#[derive(Serialize)]
#[serde(tag = "t", content = "c")]
enum EmptyAdjacentlyTagged {
#[allow(dead_code)]
Struct {},
#[allow(dead_code)]
Tuple(),
}
assert_ser::<EmptyAdjacentlyTagged>();
2018-05-07 01:22:19 -05:00
mod restricted {
mod inner {
2018-12-31 20:44:24 -06:00
use serde::{Deserialize, Serialize};
2018-05-07 01:22:19 -05:00
#[derive(Serialize, Deserialize)]
struct Restricted {
pub(super) a: usize,
pub(in super::inner) b: usize,
}
}
}
2018-05-07 23:02:42 -05:00
#[derive(Deserialize)]
#[serde(tag = "t", content = "c")]
enum AdjacentlyTaggedVoid {}
#[derive(Serialize, Deserialize)]
enum SkippedVariant<T> {
#[serde(skip)]
#[allow(dead_code)]
T(T),
Unit,
}
assert::<SkippedVariant<X>>();
#[derive(Deserialize)]
struct ImplicitlyBorrowedOption<'a> {
option: std::option::Option<&'a str>,
}
#[derive(Serialize, Deserialize)]
#[serde(untagged)]
enum UntaggedNewtypeVariantWith {
Newtype(
#[serde(serialize_with = "ser_x")]
#[serde(deserialize_with = "de_x")]
X,
),
}
2018-05-20 15:53:29 -05:00
#[derive(Serialize, Deserialize)]
#[serde(transparent)]
struct TransparentWith {
#[serde(serialize_with = "ser_x")]
#[serde(deserialize_with = "de_x")]
x: X,
}
#[derive(Deserialize)]
#[serde(untagged)]
enum UntaggedWithBorrow<'a> {
Single(#[serde(borrow)] RelObject<'a>),
Many(#[serde(borrow)] Vec<RelObject<'a>>),
}
#[derive(Deserialize)]
struct RelObject<'a> {
ty: &'a str,
id: String,
}
#[derive(Serialize, Deserialize)]
struct FlattenSkipSerializing<T> {
#[serde(flatten, skip_serializing)]
#[allow(dead_code)]
flat: T,
}
#[derive(Serialize, Deserialize)]
struct FlattenSkipSerializingIf<T> {
#[serde(flatten, skip_serializing_if = "StdOption::is_none")]
flat: StdOption<T>,
}
#[derive(Serialize, Deserialize)]
struct FlattenSkipDeserializing<T> {
#[serde(flatten, skip_deserializing)]
flat: T,
}
2020-05-08 17:38:44 -05:00
// https://github.com/serde-rs/serde/issues/1804
#[derive(Serialize, Deserialize)]
enum Message {
#[serde(skip)]
#[allow(dead_code)]
String(String),
#[serde(other)]
Unknown,
}
#[derive(Serialize)]
#[repr(packed)]
struct Packed {
x: u8,
y: u16,
}
macro_rules! deriving {
($field:ty) => {
#[derive(Deserialize)]
struct MacroRules<'a> {
field: $field,
}
};
}
deriving!(&'a str);
macro_rules! mac {
($($tt:tt)*) => {
$($tt)*
};
}
#[derive(Deserialize)]
struct BorrowLifetimeInsideMacro<'a> {
#[serde(borrow = "'a")]
f: mac!(Cow<'a, str>),
}
2021-01-25 15:25:53 -06:00
#[derive(Serialize)]
struct Struct {
#[serde(serialize_with = "vec_first_element")]
vec: Vec<Self>,
}
}
//////////////////////////////////////////////////////////////////////////
fn assert<T: Serialize + DeserializeOwned>() {}
fn assert_ser<T: Serialize>() {}
trait SerializeWith {
2017-01-14 18:07:43 -06:00
fn serialize_with<S: Serializer>(_: &Self, _: S) -> StdResult<S::Ok, S::Error>;
}
trait DeserializeWith: Sized {
fn deserialize_with<'de, D: Deserializer<'de>>(_: D) -> StdResult<Self, D::Error>;
}
// Implements neither Serialize nor Deserialize
pub struct X;
pub fn ser_x<S: Serializer>(_: &X, _: S) -> StdResult<S::Ok, S::Error> {
unimplemented!()
}
pub fn de_x<'de, D: Deserializer<'de>>(_: D) -> StdResult<X, D::Error> {
unimplemented!()
}
mod both_x {
2017-12-23 22:13:08 -06:00
pub use super::{de_x as deserialize, ser_x as serialize};
}
impl SerializeWith for X {
2017-01-14 18:07:43 -06:00
fn serialize_with<S: Serializer>(_: &Self, _: S) -> StdResult<S::Ok, S::Error> {
unimplemented!()
}
}
impl DeserializeWith for X {
fn deserialize_with<'de, D: Deserializer<'de>>(_: D) -> StdResult<Self, D::Error> {
unimplemented!()
}
}
pub fn serialize_some_unit_variant<S>(_: S) -> StdResult<S::Ok, S::Error>
2017-12-23 22:13:08 -06:00
where
S: Serializer,
{
unimplemented!()
}
pub fn deserialize_some_unit_variant<'de, D>(_: D) -> StdResult<(), D::Error>
2017-12-23 22:13:08 -06:00
where
D: Deserializer<'de>,
{
unimplemented!()
}
pub fn serialize_some_other_variant<S>(_: &str, _: &u8, _: S) -> StdResult<S::Ok, S::Error>
2017-12-23 22:13:08 -06:00
where
S: Serializer,
{
unimplemented!()
}
pub fn deserialize_some_other_variant<'de, D>(_: D) -> StdResult<(String, u8), D::Error>
2017-12-23 22:13:08 -06:00
where
D: Deserializer<'de>,
{
unimplemented!()
}
2017-12-23 22:13:08 -06:00
pub fn is_zero(n: &u8) -> bool {
*n == 0
}
2021-01-25 15:25:53 -06:00
fn vec_first_element<T, S>(vec: &Vec<T>, serializer: S) -> StdResult<S::Ok, S::Error>
where
T: Serialize,
S: Serializer,
{
vec.first().serialize(serializer)
}
//////////////////////////////////////////////////////////////////////////
#[derive(Debug, PartialEq, Deserialize)]
#[serde(tag = "tag")]
enum InternallyTagged {
#[serde(deserialize_with = "deserialize_generic")]
Unit,
#[serde(deserialize_with = "deserialize_generic")]
Newtype(i32),
#[serde(deserialize_with = "deserialize_generic")]
Struct { f1: String, f2: u8 },
}
fn deserialize_generic<'de, T, D>(deserializer: D) -> StdResult<T, D::Error>
where
T: Deserialize<'de>,
D: Deserializer<'de>,
{
T::deserialize(deserializer)
}
//////////////////////////////////////////////////////////////////////////
#[repr(packed)]
pub struct RemotePacked {
pub a: u16,
pub b: u32,
}
#[derive(Serialize)]
#[repr(packed)]
#[serde(remote = "RemotePacked")]
pub struct RemotePackedDef {
a: u16,
b: u32,
}
impl Drop for RemotePackedDef {
fn drop(&mut self) {}
}
#[repr(packed)]
pub struct RemotePackedNonCopy {
pub a: u16,
pub b: String,
}
#[derive(Deserialize)]
#[repr(packed)]
#[serde(remote = "RemotePackedNonCopy")]
pub struct RemotePackedNonCopyDef {
a: u16,
b: String,
}
impl Drop for RemotePackedNonCopyDef {
fn drop(&mut self) {}
}