serde/test_suite/tests/test_de_error.rs

1569 lines
37 KiB
Rust
Raw Normal View History

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
#![allow(
clippy::derive_partial_eq_without_eq,
clippy::empty_enum,
clippy::unreadable_literal
)]
#![cfg_attr(feature = "unstable", feature(never_type))]
use serde::de::{Deserialize, IntoDeserializer};
use serde_derive::Deserialize;
use serde_test::{assert_de_tokens_error, Token};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::ffi::{CStr, CString};
2022-01-20 23:43:08 -06:00
use std::num::{
NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize, NonZeroU128,
NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize, Wrapping,
};
use std::time::{Duration, SystemTime};
#[derive(Copy, Clone, PartialEq, Debug, Deserialize)]
struct UnitStruct;
#[derive(PartialEq, Debug, Deserialize)]
struct Struct {
a: i32,
b: i32,
#[serde(skip_deserializing)]
c: i32,
}
#[derive(PartialEq, Debug, Deserialize)]
#[serde(deny_unknown_fields)]
struct StructDenyUnknown {
a: i32,
#[serde(skip_deserializing)]
b: i32,
}
#[derive(PartialEq, Debug, Deserialize)]
#[serde(deny_unknown_fields)]
struct StructSkipAllDenyUnknown {
#[serde(skip_deserializing)]
a: i32,
}
#[derive(Default, PartialEq, Debug)]
struct NotDeserializable;
#[derive(PartialEq, Debug, Deserialize)]
enum Enum {
#[allow(dead_code)]
#[serde(skip_deserializing)]
Skipped,
Unit,
Simple(i32),
Seq(i32, i32, i32),
Map {
a: i32,
b: i32,
c: i32,
},
SimpleWithSkipped(#[serde(skip_deserializing)] NotDeserializable),
}
#[derive(PartialEq, Debug, Deserialize)]
enum EnumSkipAll {
#[allow(dead_code)]
#[serde(skip_deserializing)]
Skipped,
}
2022-01-20 23:24:27 -06:00
#[test]
fn test_i8() {
let test = assert_de_tokens_error::<i8>;
// from signed
test(
&[Token::I16(-129)],
"invalid value: integer `-129`, expected i8",
);
test(
&[Token::I32(-129)],
"invalid value: integer `-129`, expected i8",
);
test(
&[Token::I64(-129)],
"invalid value: integer `-129`, expected i8",
);
test(
&[Token::I16(128)],
"invalid value: integer `128`, expected i8",
);
test(
&[Token::I32(128)],
"invalid value: integer `128`, expected i8",
);
test(
&[Token::I64(128)],
"invalid value: integer `128`, expected i8",
);
// from unsigned
test(
&[Token::U8(128)],
"invalid value: integer `128`, expected i8",
);
test(
&[Token::U16(128)],
"invalid value: integer `128`, expected i8",
);
test(
&[Token::U32(128)],
"invalid value: integer `128`, expected i8",
);
test(
&[Token::U64(128)],
"invalid value: integer `128`, expected i8",
);
}
#[test]
fn test_i16() {
let test = assert_de_tokens_error::<i16>;
// from signed
test(
&[Token::I32(-32769)],
"invalid value: integer `-32769`, expected i16",
);
test(
&[Token::I64(-32769)],
"invalid value: integer `-32769`, expected i16",
);
test(
&[Token::I32(32768)],
"invalid value: integer `32768`, expected i16",
);
test(
&[Token::I64(32768)],
"invalid value: integer `32768`, expected i16",
);
// from unsigned
test(
&[Token::U16(32768)],
"invalid value: integer `32768`, expected i16",
);
test(
&[Token::U32(32768)],
"invalid value: integer `32768`, expected i16",
);
test(
&[Token::U64(32768)],
"invalid value: integer `32768`, expected i16",
);
}
#[test]
fn test_i32() {
let test = assert_de_tokens_error::<i32>;
// from signed
test(
&[Token::I64(-2147483649)],
"invalid value: integer `-2147483649`, expected i32",
);
test(
&[Token::I64(2147483648)],
"invalid value: integer `2147483648`, expected i32",
);
// from unsigned
test(
&[Token::U32(2147483648)],
"invalid value: integer `2147483648`, expected i32",
);
test(
&[Token::U64(2147483648)],
"invalid value: integer `2147483648`, expected i32",
);
}
#[test]
fn test_i64() {
let test = assert_de_tokens_error::<i64>;
// from unsigned
test(
&[Token::U64(9223372036854775808)],
"invalid value: integer `9223372036854775808`, expected i64",
);
}
2022-01-25 13:24:53 -06:00
#[test]
fn test_i128() {
let deserializer = <i128 as IntoDeserializer>::into_deserializer(1);
let error = <&str>::deserialize(deserializer).unwrap_err();
assert_eq!(
error.to_string(),
"invalid type: integer `1` as i128, expected a borrowed string",
2022-01-25 13:24:53 -06:00
);
}
2022-01-20 23:24:27 -06:00
#[test]
fn test_u8() {
let test = assert_de_tokens_error::<u8>;
// from signed
test(&[Token::I8(-1)], "invalid value: integer `-1`, expected u8");
test(
&[Token::I16(-1)],
"invalid value: integer `-1`, expected u8",
);
test(
&[Token::I32(-1)],
"invalid value: integer `-1`, expected u8",
);
test(
&[Token::I64(-1)],
"invalid value: integer `-1`, expected u8",
);
test(
&[Token::I16(256)],
"invalid value: integer `256`, expected u8",
);
test(
&[Token::I32(256)],
"invalid value: integer `256`, expected u8",
);
test(
&[Token::I64(256)],
"invalid value: integer `256`, expected u8",
);
// from unsigned
test(
&[Token::U16(256)],
"invalid value: integer `256`, expected u8",
);
test(
&[Token::U32(256)],
"invalid value: integer `256`, expected u8",
);
test(
&[Token::U64(256)],
"invalid value: integer `256`, expected u8",
);
}
#[test]
fn test_u16() {
let test = assert_de_tokens_error::<u16>;
// from signed
test(
&[Token::I8(-1)],
"invalid value: integer `-1`, expected u16",
);
test(
&[Token::I16(-1)],
"invalid value: integer `-1`, expected u16",
);
test(
&[Token::I32(-1)],
"invalid value: integer `-1`, expected u16",
);
test(
&[Token::I64(-1)],
"invalid value: integer `-1`, expected u16",
);
test(
&[Token::I32(65536)],
"invalid value: integer `65536`, expected u16",
);
test(
&[Token::I64(65536)],
"invalid value: integer `65536`, expected u16",
);
// from unsigned
test(
&[Token::U32(65536)],
"invalid value: integer `65536`, expected u16",
);
test(
&[Token::U64(65536)],
"invalid value: integer `65536`, expected u16",
);
}
#[test]
fn test_u32() {
let test = assert_de_tokens_error::<u32>;
// from signed
test(
&[Token::I8(-1)],
"invalid value: integer `-1`, expected u32",
);
test(
&[Token::I16(-1)],
"invalid value: integer `-1`, expected u32",
);
test(
&[Token::I32(-1)],
"invalid value: integer `-1`, expected u32",
);
test(
&[Token::I64(-1)],
"invalid value: integer `-1`, expected u32",
);
test(
&[Token::I64(4294967296)],
"invalid value: integer `4294967296`, expected u32",
);
// from unsigned
test(
&[Token::U64(4294967296)],
"invalid value: integer `4294967296`, expected u32",
);
}
#[test]
fn test_u64() {
let test = assert_de_tokens_error::<u64>;
// from signed
test(
&[Token::I8(-1)],
"invalid value: integer `-1`, expected u64",
);
test(
&[Token::I16(-1)],
"invalid value: integer `-1`, expected u64",
);
test(
&[Token::I32(-1)],
"invalid value: integer `-1`, expected u64",
);
test(
&[Token::I64(-1)],
"invalid value: integer `-1`, expected u64",
);
2022-01-25 13:24:53 -06:00
let deserializer = <u64 as IntoDeserializer>::into_deserializer(1);
let error = <&str>::deserialize(deserializer).unwrap_err();
assert_eq!(
error.to_string(),
"invalid type: integer `1`, expected a borrowed string",
);
2022-01-20 23:24:27 -06:00
}
#[test]
fn test_u128() {
let test = assert_de_tokens_error::<u128>;
// from signed
test(
&[Token::I8(-1)],
"invalid value: integer `-1`, expected u128",
);
test(
&[Token::I16(-1)],
"invalid value: integer `-1`, expected u128",
);
test(
&[Token::I32(-1)],
"invalid value: integer `-1`, expected u128",
);
test(
&[Token::I64(-1)],
"invalid value: integer `-1`, expected u128",
);
2022-01-25 13:24:53 -06:00
let deserializer = <u128 as IntoDeserializer>::into_deserializer(1);
let error = <&str>::deserialize(deserializer).unwrap_err();
assert_eq!(
error.to_string(),
"invalid type: integer `1` as u128, expected a borrowed string",
2022-01-25 13:24:53 -06:00
);
2022-01-20 23:24:27 -06:00
}
#[test]
fn test_usize() {
let test = assert_de_tokens_error::<usize>;
// from signed
test(
&[Token::I8(-1)],
"invalid value: integer `-1`, expected usize",
);
test(
&[Token::I16(-1)],
"invalid value: integer `-1`, expected usize",
);
test(
2022-01-20 23:43:08 -06:00
&[Token::I32(-1)],
"invalid value: integer `-1`, expected usize",
);
test(
&[Token::I64(-1)],
"invalid value: integer `-1`, expected usize",
);
}
#[test]
fn test_nonzero_i8() {
let test = assert_de_tokens_error::<NonZeroI8>;
// from zero
test(
&[Token::I8(0)],
"invalid value: integer `0`, expected a nonzero i8",
);
test(
&[Token::I16(0)],
"invalid value: integer `0`, expected a nonzero i8",
);
test(
&[Token::I32(0)],
"invalid value: integer `0`, expected a nonzero i8",
);
test(
&[Token::I64(0)],
"invalid value: integer `0`, expected a nonzero i8",
);
test(
&[Token::U8(0)],
"invalid value: integer `0`, expected a nonzero i8",
);
test(
&[Token::U16(0)],
"invalid value: integer `0`, expected a nonzero i8",
);
test(
&[Token::U32(0)],
"invalid value: integer `0`, expected a nonzero i8",
);
test(
&[Token::U64(0)],
"invalid value: integer `0`, expected a nonzero i8",
);
2022-01-20 23:43:08 -06:00
// from signed
test(
&[Token::I16(-129)],
"invalid value: integer `-129`, expected a nonzero i8",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I32(-129)],
"invalid value: integer `-129`, expected a nonzero i8",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I64(-129)],
"invalid value: integer `-129`, expected a nonzero i8",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I16(128)],
"invalid value: integer `128`, expected a nonzero i8",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I32(128)],
"invalid value: integer `128`, expected a nonzero i8",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I64(128)],
"invalid value: integer `128`, expected a nonzero i8",
2022-01-20 23:43:08 -06:00
);
// from unsigned
test(
&[Token::U8(128)],
"invalid value: integer `128`, expected a nonzero i8",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::U16(128)],
"invalid value: integer `128`, expected a nonzero i8",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::U32(128)],
"invalid value: integer `128`, expected a nonzero i8",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::U64(128)],
"invalid value: integer `128`, expected a nonzero i8",
2022-01-20 23:43:08 -06:00
);
}
#[test]
fn test_nonzero_i16() {
let test = assert_de_tokens_error::<NonZeroI16>;
// from zero
test(
&[Token::I8(0)],
"invalid value: integer `0`, expected a nonzero i16",
);
test(
&[Token::I16(0)],
"invalid value: integer `0`, expected a nonzero i16",
);
test(
&[Token::I32(0)],
"invalid value: integer `0`, expected a nonzero i16",
);
test(
&[Token::I64(0)],
"invalid value: integer `0`, expected a nonzero i16",
);
test(
&[Token::U8(0)],
"invalid value: integer `0`, expected a nonzero i16",
);
test(
&[Token::U16(0)],
"invalid value: integer `0`, expected a nonzero i16",
);
test(
&[Token::U32(0)],
"invalid value: integer `0`, expected a nonzero i16",
);
test(
&[Token::U64(0)],
"invalid value: integer `0`, expected a nonzero i16",
);
2022-01-20 23:43:08 -06:00
// from signed
test(
&[Token::I32(-32769)],
"invalid value: integer `-32769`, expected a nonzero i16",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I64(-32769)],
"invalid value: integer `-32769`, expected a nonzero i16",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I32(32768)],
"invalid value: integer `32768`, expected a nonzero i16",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I64(32768)],
"invalid value: integer `32768`, expected a nonzero i16",
2022-01-20 23:43:08 -06:00
);
// from unsigned
test(
&[Token::U16(32768)],
"invalid value: integer `32768`, expected a nonzero i16",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::U32(32768)],
"invalid value: integer `32768`, expected a nonzero i16",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::U64(32768)],
"invalid value: integer `32768`, expected a nonzero i16",
2022-01-20 23:43:08 -06:00
);
}
#[test]
fn test_nonzero_i32() {
let test = assert_de_tokens_error::<NonZeroI32>;
// from zero
test(
&[Token::I8(0)],
"invalid value: integer `0`, expected a nonzero i32",
);
test(
&[Token::I16(0)],
"invalid value: integer `0`, expected a nonzero i32",
);
test(
&[Token::I32(0)],
"invalid value: integer `0`, expected a nonzero i32",
);
test(
&[Token::I64(0)],
"invalid value: integer `0`, expected a nonzero i32",
);
test(
&[Token::U8(0)],
"invalid value: integer `0`, expected a nonzero i32",
);
test(
&[Token::U16(0)],
"invalid value: integer `0`, expected a nonzero i32",
);
test(
&[Token::U32(0)],
"invalid value: integer `0`, expected a nonzero i32",
);
test(
&[Token::U64(0)],
"invalid value: integer `0`, expected a nonzero i32",
);
2022-01-20 23:43:08 -06:00
// from signed
test(
&[Token::I64(-2147483649)],
"invalid value: integer `-2147483649`, expected a nonzero i32",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I64(2147483648)],
"invalid value: integer `2147483648`, expected a nonzero i32",
2022-01-20 23:43:08 -06:00
);
// from unsigned
test(
&[Token::U32(2147483648)],
"invalid value: integer `2147483648`, expected a nonzero i32",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::U64(2147483648)],
"invalid value: integer `2147483648`, expected a nonzero i32",
2022-01-20 23:43:08 -06:00
);
}
#[test]
fn test_nonzero_i64() {
let test = assert_de_tokens_error::<NonZeroI64>;
// from zero
test(
&[Token::I8(0)],
"invalid value: integer `0`, expected a nonzero i64",
);
test(
&[Token::I16(0)],
"invalid value: integer `0`, expected a nonzero i64",
);
test(
&[Token::I32(0)],
"invalid value: integer `0`, expected a nonzero i64",
);
test(
&[Token::I64(0)],
"invalid value: integer `0`, expected a nonzero i64",
);
test(
&[Token::U8(0)],
"invalid value: integer `0`, expected a nonzero i64",
);
test(
&[Token::U16(0)],
"invalid value: integer `0`, expected a nonzero i64",
);
test(
&[Token::U32(0)],
"invalid value: integer `0`, expected a nonzero i64",
);
test(
&[Token::U64(0)],
"invalid value: integer `0`, expected a nonzero i64",
);
2022-01-20 23:43:08 -06:00
// from unsigned
test(
&[Token::U64(9223372036854775808)],
"invalid value: integer `9223372036854775808`, expected a nonzero i64",
2022-01-20 23:43:08 -06:00
);
}
#[test]
fn test_nonzero_i128() {
let test = assert_de_tokens_error::<NonZeroI128>;
// from zero
test(
&[Token::I8(0)],
"invalid value: integer `0`, expected a nonzero i128",
);
test(
&[Token::I16(0)],
"invalid value: integer `0`, expected a nonzero i128",
);
test(
&[Token::I32(0)],
"invalid value: integer `0`, expected a nonzero i128",
);
test(
&[Token::I64(0)],
"invalid value: integer `0`, expected a nonzero i128",
);
test(
&[Token::U8(0)],
"invalid value: integer `0`, expected a nonzero i128",
);
test(
&[Token::U16(0)],
"invalid value: integer `0`, expected a nonzero i128",
);
test(
&[Token::U32(0)],
"invalid value: integer `0`, expected a nonzero i128",
);
test(
&[Token::U64(0)],
"invalid value: integer `0`, expected a nonzero i128",
);
2022-01-20 23:43:08 -06:00
}
#[test]
fn test_nonzero_isize() {
let test = assert_de_tokens_error::<NonZeroIsize>;
// from zero
test(
&[Token::I8(0)],
"invalid value: integer `0`, expected a nonzero isize",
);
test(
&[Token::I16(0)],
"invalid value: integer `0`, expected a nonzero isize",
);
test(
&[Token::I32(0)],
"invalid value: integer `0`, expected a nonzero isize",
);
test(
&[Token::I64(0)],
"invalid value: integer `0`, expected a nonzero isize",
);
test(
&[Token::U8(0)],
"invalid value: integer `0`, expected a nonzero isize",
);
test(
&[Token::U16(0)],
"invalid value: integer `0`, expected a nonzero isize",
);
test(
&[Token::U32(0)],
"invalid value: integer `0`, expected a nonzero isize",
);
test(
&[Token::U64(0)],
"invalid value: integer `0`, expected a nonzero isize",
);
2022-01-20 23:43:08 -06:00
}
#[test]
fn test_nonzero_u8() {
let test = assert_de_tokens_error::<NonZeroU8>;
// from zero
test(
&[Token::I8(0)],
"invalid value: integer `0`, expected a nonzero u8",
);
test(
&[Token::I16(0)],
"invalid value: integer `0`, expected a nonzero u8",
);
test(
&[Token::I32(0)],
"invalid value: integer `0`, expected a nonzero u8",
);
test(
&[Token::I64(0)],
"invalid value: integer `0`, expected a nonzero u8",
);
test(
&[Token::U8(0)],
"invalid value: integer `0`, expected a nonzero u8",
);
test(
&[Token::U16(0)],
"invalid value: integer `0`, expected a nonzero u8",
);
test(
&[Token::U32(0)],
"invalid value: integer `0`, expected a nonzero u8",
);
test(
&[Token::U64(0)],
"invalid value: integer `0`, expected a nonzero u8",
);
2022-01-20 23:43:08 -06:00
// from signed
test(
&[Token::I8(-1)],
"invalid value: integer `-1`, expected a nonzero u8",
);
2022-01-20 23:43:08 -06:00
test(
&[Token::I16(-1)],
"invalid value: integer `-1`, expected a nonzero u8",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I32(-1)],
"invalid value: integer `-1`, expected a nonzero u8",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I64(-1)],
"invalid value: integer `-1`, expected a nonzero u8",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I16(256)],
"invalid value: integer `256`, expected a nonzero u8",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I32(256)],
"invalid value: integer `256`, expected a nonzero u8",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I64(256)],
"invalid value: integer `256`, expected a nonzero u8",
2022-01-20 23:43:08 -06:00
);
// from unsigned
test(
&[Token::U16(256)],
"invalid value: integer `256`, expected a nonzero u8",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::U32(256)],
"invalid value: integer `256`, expected a nonzero u8",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::U64(256)],
"invalid value: integer `256`, expected a nonzero u8",
2022-01-20 23:43:08 -06:00
);
}
#[test]
fn test_nonzero_u16() {
let test = assert_de_tokens_error::<NonZeroU16>;
// from zero
test(
&[Token::I8(0)],
"invalid value: integer `0`, expected a nonzero u16",
);
test(
&[Token::I16(0)],
"invalid value: integer `0`, expected a nonzero u16",
);
test(
&[Token::I32(0)],
"invalid value: integer `0`, expected a nonzero u16",
);
test(
&[Token::I64(0)],
"invalid value: integer `0`, expected a nonzero u16",
);
test(
&[Token::U8(0)],
"invalid value: integer `0`, expected a nonzero u16",
);
test(
&[Token::U16(0)],
"invalid value: integer `0`, expected a nonzero u16",
);
test(
&[Token::U32(0)],
"invalid value: integer `0`, expected a nonzero u16",
);
test(
&[Token::U64(0)],
"invalid value: integer `0`, expected a nonzero u16",
);
2022-01-20 23:43:08 -06:00
// from signed
test(
&[Token::I8(-1)],
"invalid value: integer `-1`, expected a nonzero u16",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I16(-1)],
"invalid value: integer `-1`, expected a nonzero u16",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I32(-1)],
"invalid value: integer `-1`, expected a nonzero u16",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I64(-1)],
"invalid value: integer `-1`, expected a nonzero u16",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I32(65536)],
"invalid value: integer `65536`, expected a nonzero u16",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I64(65536)],
"invalid value: integer `65536`, expected a nonzero u16",
2022-01-20 23:43:08 -06:00
);
// from unsigned
test(
&[Token::U32(65536)],
"invalid value: integer `65536`, expected a nonzero u16",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::U64(65536)],
"invalid value: integer `65536`, expected a nonzero u16",
2022-01-20 23:43:08 -06:00
);
}
#[test]
fn test_nonzero_u32() {
let test = assert_de_tokens_error::<NonZeroU32>;
// from zero
test(
&[Token::I8(0)],
"invalid value: integer `0`, expected a nonzero u32",
);
test(
&[Token::I16(0)],
"invalid value: integer `0`, expected a nonzero u32",
);
test(
&[Token::I32(0)],
"invalid value: integer `0`, expected a nonzero u32",
);
test(
&[Token::I64(0)],
"invalid value: integer `0`, expected a nonzero u32",
);
test(
&[Token::U8(0)],
"invalid value: integer `0`, expected a nonzero u32",
);
test(
&[Token::U16(0)],
"invalid value: integer `0`, expected a nonzero u32",
);
test(
&[Token::U32(0)],
"invalid value: integer `0`, expected a nonzero u32",
);
test(
&[Token::U64(0)],
"invalid value: integer `0`, expected a nonzero u32",
);
2022-01-20 23:43:08 -06:00
// from signed
test(
&[Token::I8(-1)],
"invalid value: integer `-1`, expected a nonzero u32",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I16(-1)],
"invalid value: integer `-1`, expected a nonzero u32",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I32(-1)],
"invalid value: integer `-1`, expected a nonzero u32",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I64(-1)],
"invalid value: integer `-1`, expected a nonzero u32",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I64(4294967296)],
"invalid value: integer `4294967296`, expected a nonzero u32",
2022-01-20 23:43:08 -06:00
);
// from unsigned
test(
&[Token::U64(4294967296)],
"invalid value: integer `4294967296`, expected a nonzero u32",
2022-01-20 23:43:08 -06:00
);
}
#[test]
fn test_nonzero_u64() {
let test = assert_de_tokens_error::<NonZeroU64>;
// from zero
test(
&[Token::I8(0)],
"invalid value: integer `0`, expected a nonzero u64",
);
test(
&[Token::I16(0)],
"invalid value: integer `0`, expected a nonzero u64",
);
test(
&[Token::I32(0)],
"invalid value: integer `0`, expected a nonzero u64",
);
test(
&[Token::I64(0)],
"invalid value: integer `0`, expected a nonzero u64",
);
test(
&[Token::U8(0)],
"invalid value: integer `0`, expected a nonzero u64",
);
test(
&[Token::U16(0)],
"invalid value: integer `0`, expected a nonzero u64",
);
test(
&[Token::U32(0)],
"invalid value: integer `0`, expected a nonzero u64",
);
test(
&[Token::U64(0)],
"invalid value: integer `0`, expected a nonzero u64",
);
2022-01-20 23:43:08 -06:00
// from signed
test(
&[Token::I8(-1)],
"invalid value: integer `-1`, expected a nonzero u64",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I16(-1)],
"invalid value: integer `-1`, expected a nonzero u64",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I32(-1)],
"invalid value: integer `-1`, expected a nonzero u64",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I64(-1)],
"invalid value: integer `-1`, expected a nonzero u64",
2022-01-20 23:43:08 -06:00
);
}
#[test]
fn test_nonzero_u128() {
let test = assert_de_tokens_error::<NonZeroU128>;
// from zero
test(
&[Token::I8(0)],
"invalid value: integer `0`, expected a nonzero u128",
);
test(
&[Token::I16(0)],
"invalid value: integer `0`, expected a nonzero u128",
);
test(
&[Token::I32(0)],
"invalid value: integer `0`, expected a nonzero u128",
);
test(
&[Token::I64(0)],
"invalid value: integer `0`, expected a nonzero u128",
);
test(
&[Token::U8(0)],
"invalid value: integer `0`, expected a nonzero u128",
);
test(
&[Token::U16(0)],
"invalid value: integer `0`, expected a nonzero u128",
);
test(
&[Token::U32(0)],
"invalid value: integer `0`, expected a nonzero u128",
);
test(
&[Token::U64(0)],
"invalid value: integer `0`, expected a nonzero u128",
);
2022-01-20 23:43:08 -06:00
// from signed
test(
&[Token::I8(-1)],
"invalid value: integer `-1`, expected a nonzero u128",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I16(-1)],
"invalid value: integer `-1`, expected a nonzero u128",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I32(-1)],
"invalid value: integer `-1`, expected a nonzero u128",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I64(-1)],
"invalid value: integer `-1`, expected a nonzero u128",
2022-01-20 23:43:08 -06:00
);
}
#[test]
fn test_nonzero_usize() {
let test = assert_de_tokens_error::<NonZeroUsize>;
// from zero
test(
&[Token::I8(0)],
"invalid value: integer `0`, expected a nonzero usize",
);
test(
&[Token::I16(0)],
"invalid value: integer `0`, expected a nonzero usize",
);
test(
&[Token::I32(0)],
"invalid value: integer `0`, expected a nonzero usize",
);
test(
&[Token::I64(0)],
"invalid value: integer `0`, expected a nonzero usize",
);
test(
&[Token::U8(0)],
"invalid value: integer `0`, expected a nonzero usize",
);
test(
&[Token::U16(0)],
"invalid value: integer `0`, expected a nonzero usize",
);
test(
&[Token::U32(0)],
"invalid value: integer `0`, expected a nonzero usize",
);
test(
&[Token::U64(0)],
"invalid value: integer `0`, expected a nonzero usize",
);
2022-01-20 23:43:08 -06:00
// from signed
test(
&[Token::I8(-1)],
"invalid value: integer `-1`, expected a nonzero usize",
2022-01-20 23:43:08 -06:00
);
test(
&[Token::I16(-1)],
"invalid value: integer `-1`, expected a nonzero usize",
2022-01-20 23:43:08 -06:00
);
test(
2022-01-20 23:24:27 -06:00
&[Token::I32(-1)],
"invalid value: integer `-1`, expected a nonzero usize",
2022-01-20 23:24:27 -06:00
);
test(
&[Token::I64(-1)],
"invalid value: integer `-1`, expected a nonzero usize",
2022-01-20 23:24:27 -06:00
);
}
#[test]
fn test_unknown_field() {
assert_de_tokens_error::<StructDenyUnknown>(
&[
Token::Struct {
name: "StructDenyUnknown",
len: 1,
},
Token::Str("a"),
Token::I32(0),
Token::Str("d"),
],
"unknown field `d`, expected `a`",
);
}
#[test]
fn test_skipped_field_is_unknown() {
assert_de_tokens_error::<StructDenyUnknown>(
&[
Token::Struct {
name: "StructDenyUnknown",
len: 1,
},
Token::Str("b"),
],
"unknown field `b`, expected `a`",
);
}
#[test]
fn test_skip_all_deny_unknown() {
assert_de_tokens_error::<StructSkipAllDenyUnknown>(
&[
Token::Struct {
name: "StructSkipAllDenyUnknown",
len: 0,
},
Token::Str("a"),
],
"unknown field `a`, there are no fields",
);
}
#[test]
fn test_unknown_variant() {
assert_de_tokens_error::<Enum>(
&[
Token::UnitVariant { name: "Enum", variant: "Foo" },
],
"unknown variant `Foo`, expected one of `Unit`, `Simple`, `Seq`, `Map`, `SimpleWithSkipped`",
);
}
#[test]
fn test_enum_skipped_variant() {
assert_de_tokens_error::<Enum>(
&[
Token::UnitVariant { name: "Enum", variant: "Skipped" },
],
"unknown variant `Skipped`, expected one of `Unit`, `Simple`, `Seq`, `Map`, `SimpleWithSkipped`",
);
}
#[test]
fn test_enum_skip_all() {
assert_de_tokens_error::<EnumSkipAll>(
&[Token::UnitVariant {
name: "EnumSkipAll",
variant: "Skipped",
}],
"unknown variant `Skipped`, there are no variants",
);
}
#[test]
fn test_duplicate_field_struct() {
assert_de_tokens_error::<Struct>(
&[
Token::Map { len: Some(3) },
Token::Str("a"),
Token::I32(1),
Token::Str("a"),
],
"duplicate field `a`",
);
}
#[test]
fn test_duplicate_field_enum() {
assert_de_tokens_error::<Enum>(
&[
Token::StructVariant {
name: "Enum",
variant: "Map",
len: 3,
},
Token::Str("a"),
Token::I32(1),
Token::Str("a"),
],
"duplicate field `a`",
);
}
#[test]
fn test_enum_out_of_range() {
assert_de_tokens_error::<Enum>(
&[Token::Enum { name: "Enum" }, Token::U32(5), Token::Unit],
"invalid value: integer `5`, expected variant index 0 <= i < 5",
);
}
#[test]
fn test_short_tuple() {
assert_de_tokens_error::<(u8, u8, u8)>(
&[Token::Tuple { len: 1 }, Token::U8(1), Token::TupleEnd],
"invalid length 1, expected a tuple of size 3",
);
}
#[test]
fn test_short_array() {
assert_de_tokens_error::<[u8; 3]>(
&[Token::Seq { len: Some(1) }, Token::U8(1), Token::SeqEnd],
"invalid length 1, expected an array of length 3",
);
}
#[test]
fn test_cstring_internal_null() {
assert_de_tokens_error::<CString>(
&[Token::Bytes(b"a\0c")],
"nul byte found in provided data at position: 1",
);
}
#[test]
fn test_cstring_internal_null_end() {
assert_de_tokens_error::<CString>(
&[Token::Bytes(b"ac\0")],
"nul byte found in provided data at position: 2",
);
}
#[test]
fn test_unit_from_empty_seq() {
assert_de_tokens_error::<()>(
&[Token::Seq { len: Some(0) }, Token::SeqEnd],
"invalid type: sequence, expected unit",
);
}
#[test]
fn test_unit_from_empty_seq_without_len() {
assert_de_tokens_error::<()>(
&[Token::Seq { len: None }, Token::SeqEnd],
"invalid type: sequence, expected unit",
);
}
#[test]
fn test_unit_from_tuple_struct() {
assert_de_tokens_error::<()>(
&[
Token::TupleStruct {
name: "Anything",
len: 0,
},
Token::TupleStructEnd,
],
"invalid type: sequence, expected unit",
);
}
#[test]
fn test_string_from_unit() {
assert_de_tokens_error::<String>(
&[Token::Unit],
"invalid type: unit value, expected a string",
);
}
#[test]
fn test_btreeset_from_unit() {
assert_de_tokens_error::<BTreeSet<isize>>(
&[Token::Unit],
"invalid type: unit value, expected a sequence",
);
}
#[test]
fn test_btreeset_from_unit_struct() {
assert_de_tokens_error::<BTreeSet<isize>>(
&[Token::UnitStruct { name: "Anything" }],
"invalid type: unit value, expected a sequence",
);
}
#[test]
fn test_hashset_from_unit() {
assert_de_tokens_error::<HashSet<isize>>(
&[Token::Unit],
"invalid type: unit value, expected a sequence",
);
}
#[test]
fn test_hashset_from_unit_struct() {
assert_de_tokens_error::<HashSet<isize>>(
&[Token::UnitStruct { name: "Anything" }],
"invalid type: unit value, expected a sequence",
);
}
#[test]
fn test_vec_from_unit() {
assert_de_tokens_error::<Vec<isize>>(
&[Token::Unit],
"invalid type: unit value, expected a sequence",
);
}
#[test]
fn test_vec_from_unit_struct() {
assert_de_tokens_error::<Vec<isize>>(
&[Token::UnitStruct { name: "Anything" }],
"invalid type: unit value, expected a sequence",
);
}
#[test]
fn test_zero_array_from_unit() {
assert_de_tokens_error::<[isize; 0]>(
&[Token::Unit],
"invalid type: unit value, expected an empty array",
);
}
#[test]
fn test_zero_array_from_unit_struct() {
assert_de_tokens_error::<[isize; 0]>(
&[Token::UnitStruct { name: "Anything" }],
"invalid type: unit value, expected an empty array",
);
}
#[test]
fn test_btreemap_from_unit() {
assert_de_tokens_error::<BTreeMap<isize, isize>>(
&[Token::Unit],
"invalid type: unit value, expected a map",
);
}
#[test]
fn test_btreemap_from_unit_struct() {
assert_de_tokens_error::<BTreeMap<isize, isize>>(
&[Token::UnitStruct { name: "Anything" }],
"invalid type: unit value, expected a map",
);
}
#[test]
fn test_hashmap_from_unit() {
assert_de_tokens_error::<HashMap<isize, isize>>(
&[Token::Unit],
"invalid type: unit value, expected a map",
);
}
#[test]
fn test_hashmap_from_unit_struct() {
assert_de_tokens_error::<HashMap<isize, isize>>(
&[Token::UnitStruct { name: "Anything" }],
"invalid type: unit value, expected a map",
);
}
#[test]
fn test_bool_from_string() {
assert_de_tokens_error::<bool>(
&[Token::Str("false")],
"invalid type: string \"false\", expected a boolean",
);
}
#[test]
fn test_number_from_string() {
assert_de_tokens_error::<isize>(
&[Token::Str("1")],
"invalid type: string \"1\", expected isize",
);
}
#[test]
fn test_integer_from_float() {
assert_de_tokens_error::<isize>(
&[Token::F32(0.0)],
"invalid type: floating point `0.0`, expected isize",
);
}
Only format Unexpected::Float with decimal point if it is finite bef110b92a1 changed the display for unexpected floats to always append a ".0" if there was no decimal point found in the formatting of the float. However, this should only be relevant for finite (i.e., not NaN or inf) values. The change introduced a test failure in the ordered-float crate due to this: ---- impl_serde::test_fail_on_nan stdout ---- thread 'impl_serde::test_fail_on_nan' panicked at 'assertion failed: `(left == right)` left: `Error { msg: "invalid value: floating point `NaN.0`, expected float (but not NaN)" }`, right: `"invalid value: floating point `NaN`, expected float (but not NaN)"`', src/lib.rs:1554:9 stack backtrace: 0: rust_begin_unwind at /usr/src/rustc-1.70.0/library/std/src/panicking.rs:578:5 1: core::panicking::panic_fmt at /usr/src/rustc-1.70.0/library/core/src/panicking.rs:67:14 2: core::panicking::assert_failed_inner 3: core::panicking::assert_failed at /usr/src/rustc-1.70.0/library/core/src/panicking.rs:228:5 4: serde_test::assert::assert_de_tokens_error at /usr/share/cargo/registry/serde_test-1.0.171/src/assert.rs:228:19 5: ordered_float::impl_serde::test_fail_on_nan at ./src/lib.rs:1554:9 6: ordered_float::impl_serde::test_fail_on_nan::{{closure}} at ./src/lib.rs:1553:27 7: core::ops::function::FnOnce::call_once at /usr/src/rustc-1.70.0/library/core/src/ops/function.rs:250:5 8: core::ops::function::FnOnce::call_once at /usr/src/rustc-1.70.0/library/core/src/ops/function.rs:250:5 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
2024-05-01 07:20:59 -05:00
#[test]
fn test_nan_no_decimal_point() {
assert_de_tokens_error::<isize>(
&[Token::F32(f32::NAN)],
"invalid type: floating point `NaN`, expected isize",
);
}
#[test]
fn test_unit_struct_from_seq() {
assert_de_tokens_error::<UnitStruct>(
&[Token::Seq { len: Some(0) }, Token::SeqEnd],
"invalid type: sequence, expected unit struct UnitStruct",
);
}
#[test]
fn test_wrapping_overflow() {
assert_de_tokens_error::<Wrapping<u16>>(
&[Token::U32(65_536)],
"invalid value: integer `65536`, expected u16",
);
}
#[test]
fn test_duration_overflow_seq() {
assert_de_tokens_error::<Duration>(
&[
Token::Seq { len: Some(2) },
Resolve legacy_numeric_constants clippy lints warning: usage of a legacy numeric method --> serde_derive/src/ser.rs:292:51 | 292 | assert!(fields.len() as u64 <= u64::from(u32::max_value())); | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants = note: `#[warn(clippy::legacy_numeric_constants)]` on by default help: use the associated constant instead | 292 | assert!(fields.len() as u64 <= u64::from(u32::MAX)); | ~~~ warning: usage of a legacy numeric method --> serde_derive/src/ser.rs:400:53 | 400 | assert!(variants.len() as u64 <= u64::from(u32::max_value())); | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 400 | assert!(variants.len() as u64 <= u64::from(u32::MAX)); | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1462:29 | 1462 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants = note: `-W clippy::legacy-numeric-constants` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::legacy_numeric_constants)]` help: use the associated constant instead | 1462 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1479:29 | 1479 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 1479 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1493:29 | 1493 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 1493 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1510:29 | 1510 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 1510 | Token::U64(u64::MAX), | ~~~
2024-04-05 21:18:03 -05:00
Token::U64(u64::MAX),
Token::U32(1_000_000_000),
Token::SeqEnd,
],
"overflow deserializing Duration",
);
}
#[test]
fn test_duration_overflow_struct() {
assert_de_tokens_error::<Duration>(
&[
Token::Struct {
name: "Duration",
len: 2,
},
Token::Str("secs"),
Resolve legacy_numeric_constants clippy lints warning: usage of a legacy numeric method --> serde_derive/src/ser.rs:292:51 | 292 | assert!(fields.len() as u64 <= u64::from(u32::max_value())); | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants = note: `#[warn(clippy::legacy_numeric_constants)]` on by default help: use the associated constant instead | 292 | assert!(fields.len() as u64 <= u64::from(u32::MAX)); | ~~~ warning: usage of a legacy numeric method --> serde_derive/src/ser.rs:400:53 | 400 | assert!(variants.len() as u64 <= u64::from(u32::max_value())); | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 400 | assert!(variants.len() as u64 <= u64::from(u32::MAX)); | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1462:29 | 1462 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants = note: `-W clippy::legacy-numeric-constants` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::legacy_numeric_constants)]` help: use the associated constant instead | 1462 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1479:29 | 1479 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 1479 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1493:29 | 1493 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 1493 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1510:29 | 1510 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 1510 | Token::U64(u64::MAX), | ~~~
2024-04-05 21:18:03 -05:00
Token::U64(u64::MAX),
Token::Str("nanos"),
Token::U32(1_000_000_000),
Token::StructEnd,
],
"overflow deserializing Duration",
);
}
#[test]
fn test_systemtime_overflow_seq() {
assert_de_tokens_error::<SystemTime>(
&[
Token::Seq { len: Some(2) },
Resolve legacy_numeric_constants clippy lints warning: usage of a legacy numeric method --> serde_derive/src/ser.rs:292:51 | 292 | assert!(fields.len() as u64 <= u64::from(u32::max_value())); | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants = note: `#[warn(clippy::legacy_numeric_constants)]` on by default help: use the associated constant instead | 292 | assert!(fields.len() as u64 <= u64::from(u32::MAX)); | ~~~ warning: usage of a legacy numeric method --> serde_derive/src/ser.rs:400:53 | 400 | assert!(variants.len() as u64 <= u64::from(u32::max_value())); | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 400 | assert!(variants.len() as u64 <= u64::from(u32::MAX)); | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1462:29 | 1462 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants = note: `-W clippy::legacy-numeric-constants` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::legacy_numeric_constants)]` help: use the associated constant instead | 1462 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1479:29 | 1479 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 1479 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1493:29 | 1493 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 1493 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1510:29 | 1510 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 1510 | Token::U64(u64::MAX), | ~~~
2024-04-05 21:18:03 -05:00
Token::U64(u64::MAX),
Token::U32(1_000_000_000),
Token::SeqEnd,
],
"overflow deserializing SystemTime epoch offset",
);
}
#[test]
fn test_systemtime_overflow_struct() {
assert_de_tokens_error::<SystemTime>(
&[
Token::Struct {
name: "SystemTime",
len: 2,
},
Token::Str("secs_since_epoch"),
Resolve legacy_numeric_constants clippy lints warning: usage of a legacy numeric method --> serde_derive/src/ser.rs:292:51 | 292 | assert!(fields.len() as u64 <= u64::from(u32::max_value())); | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants = note: `#[warn(clippy::legacy_numeric_constants)]` on by default help: use the associated constant instead | 292 | assert!(fields.len() as u64 <= u64::from(u32::MAX)); | ~~~ warning: usage of a legacy numeric method --> serde_derive/src/ser.rs:400:53 | 400 | assert!(variants.len() as u64 <= u64::from(u32::max_value())); | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 400 | assert!(variants.len() as u64 <= u64::from(u32::MAX)); | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1462:29 | 1462 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants = note: `-W clippy::legacy-numeric-constants` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::legacy_numeric_constants)]` help: use the associated constant instead | 1462 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1479:29 | 1479 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 1479 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1493:29 | 1493 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 1493 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1510:29 | 1510 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 1510 | Token::U64(u64::MAX), | ~~~
2024-04-05 21:18:03 -05:00
Token::U64(u64::MAX),
Token::Str("nanos_since_epoch"),
Token::U32(1_000_000_000),
Token::StructEnd,
],
"overflow deserializing SystemTime epoch offset",
);
}
#[test]
fn test_systemtime_overflow() {
assert_de_tokens_error::<SystemTime>(
&[
Token::Seq { len: Some(2) },
Resolve legacy_numeric_constants clippy lints warning: usage of a legacy numeric method --> serde_derive/src/ser.rs:292:51 | 292 | assert!(fields.len() as u64 <= u64::from(u32::max_value())); | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants = note: `#[warn(clippy::legacy_numeric_constants)]` on by default help: use the associated constant instead | 292 | assert!(fields.len() as u64 <= u64::from(u32::MAX)); | ~~~ warning: usage of a legacy numeric method --> serde_derive/src/ser.rs:400:53 | 400 | assert!(variants.len() as u64 <= u64::from(u32::max_value())); | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 400 | assert!(variants.len() as u64 <= u64::from(u32::MAX)); | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1462:29 | 1462 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants = note: `-W clippy::legacy-numeric-constants` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::legacy_numeric_constants)]` help: use the associated constant instead | 1462 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1479:29 | 1479 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 1479 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1493:29 | 1493 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 1493 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1510:29 | 1510 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 1510 | Token::U64(u64::MAX), | ~~~
2024-04-05 21:18:03 -05:00
Token::U64(u64::MAX),
Token::U32(0),
Token::SeqEnd,
],
"overflow deserializing SystemTime",
);
}
#[test]
fn test_cstr_internal_null() {
assert_de_tokens_error::<Box<CStr>>(
&[Token::Bytes(b"a\0c")],
"nul byte found in provided data at position: 1",
);
}
#[test]
fn test_cstr_internal_null_end() {
assert_de_tokens_error::<Box<CStr>>(
&[Token::Bytes(b"ac\0")],
"nul byte found in provided data at position: 2",
);
}
#[cfg(feature = "unstable")]
#[test]
fn test_never_type() {
assert_de_tokens_error::<!>(&[], "cannot deserialize `!`");
assert_de_tokens_error::<Result<u8, !>>(
&[Token::NewtypeVariant {
name: "Result",
variant: "Err",
}],
"cannot deserialize `!`",
);
}