Compare commits

...

37 Commits

Author SHA1 Message Date
David Tolnay ab1ca04b2e Release 1.0.131 2021-12-08 18:47:15 -08:00
David Tolnay fb2fe409c8 Touch up PR 2116 2021-12-08 18:44:41 -08:00
David Tolnay 549fac7235 Merge pull request #2116 from tyranron/fix-unused-results
Fix `unused_results` complaining rustc lint in codegen for adjacently tagged enum
2021-12-08 18:43:31 -08:00
David Tolnay c375d8b19b Merge pull request #2124 from dtolnay/cbor
Change cbor link to new repo
2021-11-26 14:48:40 -08:00
David Tolnay 6cf507f808 Change cbor link to new repo 2021-11-26 14:43:09 -08:00
David Tolnay c3c1641c06 Remove workaround for redundant_field_names Clippy bug 2021-11-04 20:23:25 -07:00
David Tolnay 1fcda0ebdb Enable pedantic lints on test suite in CI 2021-11-04 20:21:48 -07:00
David Tolnay 8f16ac0a94 Move deny(clippy) to command line arguments in the CI job 2021-11-04 20:09:35 -07:00
David Tolnay 737f78c315 Ignore enum_variant_names Clippy lint in test suite
error: all variants have the same prefix: `Serialize`
        --> test_suite/tests/test_macros.rs:1741:5
         |
    1741 | /     enum E {
    1742 | |         #[serde(rename_all = "camelCase")]
    1743 | |         Serialize {
    1744 | |             serialize: bool,
    ...    |
    1756 | |         },
    1757 | |     }
         | |_____^
         |
         = note: `-D clippy::enum-variant-names` implied by `-D clippy::all`
         = help: remove the prefixes and use full paths to the variants instead of glob imports
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names
2021-11-04 20:06:02 -07:00
David Tolnay 4a97386cb9 Clippy if_then_panic lint has been renamed to manual_assert 2021-11-04 19:57:14 -07:00
tyranron 5b32217877 Fix unused_results complaining rustc lint in codegen for adjacently tagged enum 2021-10-29 14:13:26 +03:00
David Tolnay 5b140361a3 Merge pull request #2102 from atouchet/url
Update URL
2021-10-14 16:33:22 -07:00
Alex Touchet 678351eac7 Update URL 2021-10-14 16:27:49 -07:00
David Tolnay 999c261d11 Ui test changes for trybuild 1.0.49 2021-10-08 02:46:15 -04:00
David Tolnay efbe574209 Update ui test files 2021-10-07 00:56:29 -04:00
David Tolnay 33b2677384 Suppress broken semicolon_if_nothing_returned lint
https://github.com/rust-lang/rust-clippy/issues/7768

    error: consider adding a `;` to the last statement for consistent formatting
       --> serde/src/de/impls.rs:849:1
        |
    849 | / seq_impl!(
    850 | |     BinaryHeap<T: Ord>,
    851 | |     seq,
    852 | |     BinaryHeap::clear,
    ...   |
    855 | |     BinaryHeap::push
    856 | | );
        | |__^
        |
    note: the lint level is defined here
       --> serde/src/lib.rs:97:52
        |
    97  | #![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
        |                                                    ^^^^^^^^^^^^^^^
        = note: `#[deny(clippy::semicolon_if_nothing_returned)]` implied by `#[deny(clippy::pedantic)]`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
    help: add a `;` here
        |
    849 + seq_impl!(
    850 +     BinaryHeap<T: Ord>,
    851 +     seq,
    852 +     BinaryHeap::clear,
    853 +     BinaryHeap::with_capacity(size_hint::cautious(seq.size_hint())),
    854 +     BinaryHeap::reserve,
      ...

    error: consider adding a `;` to the last statement for consistent formatting
       --> serde/src/de/impls.rs:859:1
        |
    859 | / seq_impl!(
    860 | |     BTreeSet<T: Eq + Ord>,
    861 | |     seq,
    862 | |     BTreeSet::clear,
    ...   |
    865 | |     BTreeSet::insert
    866 | | );
        | |__^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
    help: add a `;` here
        |
    859 + seq_impl!(
    860 +     BTreeSet<T: Eq + Ord>,
    861 +     seq,
    862 +     BTreeSet::clear,
    863 +     BTreeSet::new(),
    864 +     nop_reserve,
      ...

    error: consider adding a `;` to the last statement for consistent formatting
       --> serde/src/de/impls.rs:869:1
        |
    869 | / seq_impl!(
    870 | |     LinkedList<T>,
    871 | |     seq,
    872 | |     LinkedList::clear,
    ...   |
    875 | |     LinkedList::push_back
    876 | | );
        | |__^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
    help: add a `;` here
        |
    869 + seq_impl!(
    870 +     LinkedList<T>,
    871 +     seq,
    872 +     LinkedList::clear,
    873 +     LinkedList::new(),
    874 +     nop_reserve,
      ...

    error: consider adding a `;` to the last statement for consistent formatting
       --> serde/src/de/impls.rs:879:1
        |
    879 | / seq_impl!(
    880 | |     HashSet<T: Eq + Hash, S: BuildHasher + Default>,
    881 | |     seq,
    882 | |     HashSet::clear,
    883 | |     HashSet::with_capacity_and_hasher(size_hint::cautious(seq.size_hint()), S::default()),
    884 | |     HashSet::reserve,
    885 | |     HashSet::insert);
        | |_____________________^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
    help: add a `;` here
        |
    879 + seq_impl!(
    880 +     HashSet<T: Eq + Hash, S: BuildHasher + Default>,
    881 +     seq,
    882 +     HashSet::clear,
    883 +     HashSet::with_capacity_and_hasher(size_hint::cautious(seq.size_hint()), S::default()),
    884 +     HashSet::reserve,
      ...

    error: consider adding a `;` to the last statement for consistent formatting
       --> serde/src/de/impls.rs:888:1
        |
    888 | / seq_impl!(
    889 | |     VecDeque<T>,
    890 | |     seq,
    891 | |     VecDeque::clear,
    ...   |
    894 | |     VecDeque::push_back
    895 | | );
        | |__^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
    help: add a `;` here
        |
    888 + seq_impl!(
    889 +     VecDeque<T>,
    890 +     seq,
    891 +     VecDeque::clear,
    892 +     VecDeque::with_capacity(size_hint::cautious(seq.size_hint())),
    893 +     VecDeque::reserve,
      ...

    error: consider adding a `;` to the last statement for consistent formatting
        --> serde/src/de/impls.rs:1300:1
         |
    1300 | / map_impl!(
    1301 | |     BTreeMap<K: Ord, V>,
    1302 | |     map,
    1303 | |     BTreeMap::new());
         | |_____________________^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
    help: add a `;` here
         |
    1300 + map_impl!(
    1301 +     BTreeMap<K: Ord, V>,
    1302 +     map,
    1303 +     BTreeMap::new());;
         |

    error: consider adding a `;` to the last statement for consistent formatting
        --> serde/src/de/impls.rs:1306:1
         |
    1306 | / map_impl!(
    1307 | |     HashMap<K: Eq + Hash, V, S: BuildHasher + Default>,
    1308 | |     map,
    1309 | |     HashMap::with_capacity_and_hasher(size_hint::cautious(map.size_hint()), S::default()));
         | |___________________________________________________________________________________________^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
    help: add a `;` here
         |
    1306 + map_impl!(
    1307 +     HashMap<K: Eq + Hash, V, S: BuildHasher + Default>,
    1308 +     map,
    1309 +     HashMap::with_capacity_and_hasher(size_hint::cautious(map.size_hint()), S::default()));;
         |
2021-10-04 23:57:05 -04:00
David Tolnay 01ded9f405 Declare minimum Rust version in Cargo metadata 2021-10-02 02:43:22 -04:00
David Tolnay fc827ecec2 Resolve redundant_closure_for_method_calls clippy lints
error: redundant closure
      --> serde_derive/src/bound.rs:53:19
       |
    53 |         .flat_map(|predicates| predicates.to_vec());
       |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `[T]::to_vec`
       |
    note: the lint level is defined here
      --> serde_derive/src/lib.rs:18:22
       |
    18 | #![deny(clippy::all, clippy::pedantic)]
       |                      ^^^^^^^^^^^^^^^^
       = note: `#[deny(clippy::redundant_closure_for_method_calls)]` implied by `#[deny(clippy::pedantic)]`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls

    error: redundant closure
      --> serde_derive/src/bound.rs:75:19
       |
    75 |         .flat_map(|predicates| predicates.to_vec());
       |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `[T]::to_vec`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls
2021-09-30 00:31:49 -04:00
David Tolnay 5c785eee58 Ignore if_then_panic clippy lint
error: only a `panic!` in `if`-then statement
      --> serde_derive/src/internals/ctxt.rs:58:9
       |
    58 | /         if !thread::panicking() && self.errors.borrow().is_some() {
    59 | |             panic!("forgot to check for errors");
    60 | |         }
       | |_________^ help: try: `assert!(!!thread::panicking() && self.errors.borrow().is_some(), "forgot to check for errors");`
       |
    note: the lint level is defined here
      --> serde_derive/src/lib.rs:18:9
       |
    18 | #![deny(clippy::all, clippy::pedantic)]
       |         ^^^^^^^^^^^
       = note: `#[deny(clippy::if_then_panic)]` implied by `#[deny(clippy::all)]`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic

    error: only a `panic!` in `if`-then statement
       --> serde_test/src/assert.rs:73:5
        |
    73  | /     if ser.remaining() > 0 {
    74  | |         panic!("{} remaining tokens", ser.remaining());
    75  | |     }
        | |_____^ help: try: `assert!(!ser.remaining() > 0, "{} remaining tokens", ser.remaining());`
        |
    note: the lint level is defined here
       --> serde_test/src/lib.rs:149:44
        |
    149 | #![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
        |                                            ^^^^^^
        = note: `#[deny(clippy::if_then_panic)]` implied by `#[deny(clippy::all)]`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic

    error: only a `panic!` in `if`-then statement
       --> serde_test/src/assert.rs:126:5
        |
    126 | /     if ser.remaining() > 0 {
    127 | |         panic!("{} remaining tokens", ser.remaining());
    128 | |     }
        | |_____^ help: try: `assert!(!ser.remaining() > 0, "{} remaining tokens", ser.remaining());`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic

    error: only a `panic!` in `if`-then statement
       --> serde_test/src/assert.rs:166:5
        |
    166 | /     if de.remaining() > 0 {
    167 | |         panic!("{} remaining tokens", de.remaining());
    168 | |     }
        | |_____^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic

    error: only a `panic!` in `if`-then statement
       --> serde_test/src/assert.rs:180:5
        |
    180 | /     if de.remaining() > 0 {
    181 | |         panic!("{} remaining tokens", de.remaining());
    182 | |     }
        | |_____^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic

    error: only a `panic!` in `if`-then statement
       --> serde_test/src/assert.rs:220:5
        |
    220 | /     if de.remaining() > 0 {
    221 | |         panic!("{} remaining tokens", de.remaining());
    222 | |     }
        | |_____^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic

    error: only a `panic!` in `if`-then statement
        --> test_suite/tests/test_de.rs:1349:9
         |
    1349 | /         if de.remaining() > 0 {
    1350 | |             panic!("{} remaining tokens", de.remaining());
    1351 | |         }
         | |_________^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());`
         |
         = note: `-D clippy::if-then-panic` implied by `-D clippy::all`
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
2021-09-30 00:31:49 -04:00
David Tolnay 819db93a3d Format with rustfmt 2021-09-29 2021-09-30 00:31:49 -04:00
David Tolnay a6690ea2fe Update ui test suite to nightly-2021-09-14 2021-09-14 19:13:54 -07:00
David Tolnay 65e1a50749 Release 1.0.130 2021-08-28 11:31:38 -07:00
David Tolnay 87d41b59fd Merge pull request #2081 from dtolnay/accessunsized
Enable unsized Map/SeqAccess types to use the impl for &mut
2021-08-28 11:11:57 -07:00
David Tolnay 3f120fb355 Enable unsized Map/SeqAccess types to use the impl for &mut 2021-08-28 10:59:51 -07:00
David Tolnay 2b92c80cc1 Release 1.0.129 2021-08-23 15:01:24 -07:00
David Tolnay c1c0ede452 Merge pull request #2080 from dtolnay/packeddrop
Support packed remote struct without destructuring
2021-08-23 15:00:50 -07:00
David Tolnay 4a66c5f33d Support packed remote struct without destructuring 2021-08-23 14:38:33 -07:00
David Tolnay 714c8a5586 Add test of packed struct that cannot be destructured
Currently fails:

    error[E0509]: cannot move out of type `RemotePackedNonCopyDef`, which implements the `Drop` trait
       --> test_suite/tests/test_gen.rs:876:10
        |
    876 | #[derive(Deserialize)]
        |          ^^^^^^^^^^^
        |          |
        |          cannot move out of here
        |          data moved here
        |          move occurs because `__v1` has type `std::string::String`, which does not implement the `Copy` trait
        |
        = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
2021-08-23 14:38:33 -07:00
David Tolnay dc0c0dcba1 Merge pull request #2079 from dtolnay/packedremote
Fix unaligned reference warnings on packed remote def
2021-08-23 14:38:21 -07:00
David Tolnay 54102ee7d0 Avoid generating ref patterns for fields of packed remote struct 2021-08-23 10:18:28 -07:00
David Tolnay 14accf7518 Add test of remote with a packed struct
Currently fails to build:

    error: reference to packed field is unaligned
       --> test_suite/tests/test_gen.rs:858:10
        |
    858 | #[derive(Serialize, Deserialize)]
        |          ^^^^^^^^^
        |
    note: the lint level is defined here
       --> test_suite/tests/test_gen.rs:5:9
        |
    5   | #![deny(warnings)]
        |         ^^^^^^^^
        = note: `#[deny(unaligned_references)]` implied by `#[deny(warnings)]`
        = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
        = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
        = note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: reference to packed field is unaligned
       --> test_suite/tests/test_gen.rs:858:21
        |
    858 | #[derive(Serialize, Deserialize)]
        |                     ^^^^^^^^^^^
        |
        = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
        = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
        = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
2021-08-23 10:18:05 -07:00
David Tolnay 55fdbea20b Merge pull request #2077 from dtolnay/tryfold
Use try_fold in default implementation of collect_seq, collect_map
2021-08-21 14:08:20 -07:00
David Tolnay 75d8902371 Use try_fold in default implementation of collect_seq, collect_map 2021-08-21 14:00:51 -07:00
David Tolnay 9451ea8df1 Format PR 1992 with rustfmt 2021-08-21 12:49:58 -07:00
David Tolnay c1ce03b3dd Merge pull request 1992 from Mingun/unnecessary-deserialize-with 2021-08-21 12:49:39 -07:00
Mingun e0fc46783d Add test with generic deserialize_with function 2021-06-12 18:47:08 +05:00
Mingun ca772a14f9 Get rid of useless DeserializeWith wrapper 2021-06-12 18:38:03 +05:00
123 changed files with 405 additions and 201 deletions
+6 -8
View File
@@ -153,11 +153,9 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@clippy - uses: dtolnay/rust-toolchain@clippy
# The need for -Aredundant_field_names here is a Clippy bug. - run: cd serde && cargo clippy --features rc,unstable -- -Dclippy::all -Dclippy::pedantic
# https://github.com/rust-lang/rust-clippy/issues/5356 - run: cd serde_derive && cargo clippy -- -Dclippy::all -Dclippy::pedantic
- run: cd serde && cargo clippy --features rc,unstable -- -D clippy::all -A clippy::redundant_field_names - run: cd serde_derive_internals && cargo clippy -- -Dclippy::all -Dclippy::pedantic
- run: cd serde_derive && cargo clippy -- -D clippy::all - run: cd serde_test && cargo clippy -- -Dclippy::all -Dclippy::pedantic
- run: cd serde_derive_internals && cargo clippy -- -D clippy::all - run: cd test_suite && cargo clippy --tests --features unstable -- -Dclippy::all -Dclippy::pedantic
- run: cd serde_test && cargo clippy -- -D clippy::all -A clippy::redundant_field_names - run: cd test_suite/no_std && cargo clippy -- -Dclippy::all -Dclippy::pedantic
- run: cd test_suite && cargo clippy --tests --features unstable -- -D clippy::all -A clippy::redundant_field_names
- run: cd test_suite/no_std && cargo clippy -- -D clippy::all -A clippy::redundant_field_names
+3 -2
View File
@@ -1,7 +1,8 @@
[package] [package]
name = "serde" name = "serde"
version = "1.0.128" # remember to update html_root_url and serde_derive dependency version = "1.0.131" # remember to update html_root_url and serde_derive dependency
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"] authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
rust-version = "1.15"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
description = "A generic serialization/deserialization framework" description = "A generic serialization/deserialization framework"
homepage = "https://serde.rs" homepage = "https://serde.rs"
@@ -14,7 +15,7 @@ include = ["build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APAC
build = "build.rs" build = "build.rs"
[dependencies] [dependencies]
serde_derive = { version = "=1.0.128", optional = true, path = "../serde_derive" } serde_derive = { version = "=1.0.131", optional = true, path = "../serde_derive" }
[dev-dependencies] [dev-dependencies]
serde_derive = { version = "1.0", path = "../serde_derive" } serde_derive = { version = "1.0", path = "../serde_derive" }
+3
View File
@@ -62,8 +62,11 @@ fn main() {
// Inclusive ranges methods stabilized in Rust 1.27: // Inclusive ranges methods stabilized in Rust 1.27:
// https://github.com/rust-lang/rust/pull/50758 // https://github.com/rust-lang/rust/pull/50758
// Also Iterator::try_for_each:
// https://blog.rust-lang.org/2018/06/21/Rust-1.27.html#library-stabilizations
if minor >= 27 { if minor >= 27 {
println!("cargo:rustc-cfg=range_inclusive"); println!("cargo:rustc-cfg=range_inclusive");
println!("cargo:rustc-cfg=iterator_try_fold");
} }
// Non-zero integers stabilized in Rust 1.28: // Non-zero integers stabilized in Rust 1.28:
+2 -2
View File
@@ -1714,7 +1714,7 @@ pub trait SeqAccess<'de> {
} }
} }
impl<'de, 'a, A> SeqAccess<'de> for &'a mut A impl<'de, 'a, A: ?Sized> SeqAccess<'de> for &'a mut A
where where
A: SeqAccess<'de>, A: SeqAccess<'de>,
{ {
@@ -1867,7 +1867,7 @@ pub trait MapAccess<'de> {
} }
} }
impl<'de, 'a, A> MapAccess<'de> for &'a mut A impl<'de, 'a, A: ?Sized> MapAccess<'de> for &'a mut A
where where
A: MapAccess<'de>, A: MapAccess<'de>,
{ {
+6 -5
View File
@@ -60,7 +60,7 @@
//! //!
//! [JSON]: https://github.com/serde-rs/json //! [JSON]: https://github.com/serde-rs/json
//! [Bincode]: https://github.com/servo/bincode //! [Bincode]: https://github.com/servo/bincode
//! [CBOR]: https://github.com/pyfisch/cbor //! [CBOR]: https://github.com/enarx/ciborium
//! [YAML]: https://github.com/dtolnay/serde-yaml //! [YAML]: https://github.com/dtolnay/serde-yaml
//! [MessagePack]: https://github.com/3Hren/msgpack-rust //! [MessagePack]: https://github.com/3Hren/msgpack-rust
//! [TOML]: https://github.com/alexcrichton/toml-rs //! [TOML]: https://github.com/alexcrichton/toml-rs
@@ -73,7 +73,7 @@
//! [URL]: https://docs.rs/serde_qs //! [URL]: https://docs.rs/serde_qs
//! [Envy]: https://github.com/softprops/envy //! [Envy]: https://github.com/softprops/envy
//! [Envy Store]: https://github.com/softprops/envy-store //! [Envy Store]: https://github.com/softprops/envy-store
//! [Cargo]: http://doc.crates.io/manifest.html //! [Cargo]: https://doc.rust-lang.org/cargo/reference/manifest.html
//! [AWS Parameter Store]: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html //! [AWS Parameter Store]: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html
//! [S-expressions]: https://github.com/rotty/lexpr-rs //! [S-expressions]: https://github.com/rotty/lexpr-rs
//! [D-Bus]: https://docs.rs/zvariant //! [D-Bus]: https://docs.rs/zvariant
@@ -84,7 +84,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Serde types in rustdoc of other crates get linked to here. // Serde types in rustdoc of other crates get linked to here.
#![doc(html_root_url = "https://docs.rs/serde/1.0.128")] #![doc(html_root_url = "https://docs.rs/serde/1.0.131")]
// Support using Serde without the standard library! // Support using Serde without the standard library!
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
// Unstable functionality only if the user asks for it. For tracking and // Unstable functionality only if the user asks for it. For tracking and
@@ -94,13 +94,14 @@
#![cfg_attr(feature = "unstable", feature(never_type))] #![cfg_attr(feature = "unstable", feature(never_type))]
#![allow(unknown_lints, bare_trait_objects, deprecated)] #![allow(unknown_lints, bare_trait_objects, deprecated)]
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))] #![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
// Ignored clippy and clippy_pedantic lints // Ignored clippy and clippy_pedantic lints
#![cfg_attr( #![cfg_attr(
feature = "cargo-clippy", feature = "cargo-clippy",
allow( allow(
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/5704 // clippy bug: https://github.com/rust-lang/rust-clippy/issues/5704
unnested_or_patterns, unnested_or_patterns,
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/7768
semicolon_if_nothing_returned,
// not available in our oldest supported compiler // not available in our oldest supported compiler
checked_conversions, checked_conversions,
empty_enum, empty_enum,
@@ -157,7 +158,7 @@ mod lib {
pub use std::*; pub use std::*;
} }
pub use self::core::{cmp, iter, mem, num, slice, str}; pub use self::core::{cmp, iter, mem, num, ptr, slice, str};
pub use self::core::{f32, f64}; pub use self::core::{f32, f64};
pub use self::core::{i16, i32, i64, i8, isize}; pub use self::core::{i16, i32, i64, i8, isize};
pub use self::core::{u16, u32, u64, u8, usize}; pub use self::core::{u16, u32, u64, u8, usize};
+1
View File
@@ -14,6 +14,7 @@ pub use lib::default::Default;
pub use lib::fmt::{self, Formatter}; pub use lib::fmt::{self, Formatter};
pub use lib::marker::PhantomData; pub use lib::marker::PhantomData;
pub use lib::option::Option::{self, None, Some}; pub use lib::option::Option::{self, None, Some};
pub use lib::ptr;
pub use lib::result::Result::{self, Err, Ok}; pub use lib::result::Result::{self, Err, Ok};
pub use self::string::from_utf8_lossy; pub use self::string::from_utf8_lossy;
+26 -4
View File
@@ -1279,9 +1279,20 @@ pub trait Serializer: Sized {
{ {
let iter = iter.into_iter(); let iter = iter.into_iter();
let mut serializer = try!(self.serialize_seq(iterator_len_hint(&iter))); let mut serializer = try!(self.serialize_seq(iterator_len_hint(&iter)));
for item in iter {
try!(serializer.serialize_element(&item)); #[cfg(iterator_try_fold)]
{
let mut iter = iter;
try!(iter.try_for_each(|item| serializer.serialize_element(&item)));
} }
#[cfg(not(iterator_try_fold))]
{
for item in iter {
try!(serializer.serialize_element(&item));
}
}
serializer.end() serializer.end()
} }
@@ -1319,9 +1330,20 @@ pub trait Serializer: Sized {
{ {
let iter = iter.into_iter(); let iter = iter.into_iter();
let mut serializer = try!(self.serialize_map(iterator_len_hint(&iter))); let mut serializer = try!(self.serialize_map(iterator_len_hint(&iter)));
for (key, value) in iter {
try!(serializer.serialize_entry(&key, &value)); #[cfg(iterator_try_fold)]
{
let mut iter = iter;
try!(iter.try_for_each(|(key, value)| serializer.serialize_entry(&key, &value)));
} }
#[cfg(not(iterator_try_fold))]
{
for (key, value) in iter {
try!(serializer.serialize_entry(&key, &value));
}
}
serializer.end() serializer.end()
} }
+2 -1
View File
@@ -1,7 +1,8 @@
[package] [package]
name = "serde_derive" name = "serde_derive"
version = "1.0.128" # remember to update html_root_url version = "1.0.131" # remember to update html_root_url
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"] authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
rust-version = "1.31"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]" description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
homepage = "https://serde.rs" homepage = "https://serde.rs"
+6
View File
@@ -16,6 +16,12 @@ fn main() {
if minor >= 37 { if minor >= 37 {
println!("cargo:rustc-cfg=underscore_consts"); println!("cargo:rustc-cfg=underscore_consts");
} }
// The ptr::addr_of! macro stabilized in Rust 1.51:
// https://blog.rust-lang.org/2021/03/25/Rust-1.51.0.html#stabilized-apis
if minor >= 51 {
println!("cargo:rustc-cfg=ptr_addr_of");
}
} }
fn rustc_minor_version() -> Option<u32> { fn rustc_minor_version() -> Option<u32> {
+2 -2
View File
@@ -50,7 +50,7 @@ pub fn with_where_predicates_from_fields(
.data .data
.all_fields() .all_fields()
.filter_map(|field| from_field(&field.attrs)) .filter_map(|field| from_field(&field.attrs))
.flat_map(|predicates| predicates.to_vec()); .flat_map(<[syn::WherePredicate]>::to_vec);
let mut generics = generics.clone(); let mut generics = generics.clone();
generics.make_where_clause().predicates.extend(predicates); generics.make_where_clause().predicates.extend(predicates);
@@ -72,7 +72,7 @@ pub fn with_where_predicates_from_variants(
let predicates = variants let predicates = variants
.iter() .iter()
.filter_map(|variant| from_variant(&variant.attrs)) .filter_map(|variant| from_variant(&variant.attrs))
.flat_map(|predicates| predicates.to_vec()); .flat_map(<[syn::WherePredicate]>::to_vec);
let mut generics = generics.clone(); let mut generics = generics.clone();
generics.make_where_clause().predicates.extend(predicates); generics.make_where_clause().predicates.extend(predicates);
+40 -18
View File
@@ -36,7 +36,7 @@ pub fn expand_derive_deserialize(
let impl_block = if let Some(remote) = cont.attrs.remote() { let impl_block = if let Some(remote) = cont.attrs.remote() {
let vis = &input.vis; let vis = &input.vis;
let used = pretend::pretend_used(&cont); let used = pretend::pretend_used(&cont, params.is_packed);
quote! { quote! {
impl #de_impl_generics #ident #ty_generics #where_clause { impl #de_impl_generics #ident #ty_generics #where_clause {
#vis fn deserialize<__D>(__deserializer: __D) -> #serde::__private::Result<#remote #ty_generics, __D::Error> #vis fn deserialize<__D>(__deserializer: __D) -> #serde::__private::Result<#remote #ty_generics, __D::Error>
@@ -125,6 +125,9 @@ struct Parameters {
/// At least one field has a serde(getter) attribute, implying that the /// At least one field has a serde(getter) attribute, implying that the
/// remote type has a private field. /// remote type has a private field.
has_getter: bool, has_getter: bool,
/// Type has a repr(packed) attribute.
is_packed: bool,
} }
impl Parameters { impl Parameters {
@@ -137,6 +140,7 @@ impl Parameters {
let borrowed = borrowed_lifetimes(cont); let borrowed = borrowed_lifetimes(cont);
let generics = build_generics(cont, &borrowed); let generics = build_generics(cont, &borrowed);
let has_getter = cont.data.has_getter(); let has_getter = cont.data.has_getter();
let is_packed = cont.attrs.is_packed();
Parameters { Parameters {
local, local,
@@ -144,6 +148,7 @@ impl Parameters {
generics, generics,
borrowed, borrowed,
has_getter, has_getter,
is_packed,
} }
} }
@@ -1453,7 +1458,7 @@ fn deserialize_adjacently_tagged_enum(
while let _serde::__private::Some(__k) = #next_key { while let _serde::__private::Some(__k) = #next_key {
match __k { match __k {
_serde::__private::de::TagContentOtherField::Other => { _serde::__private::de::TagContentOtherField::Other => {
try!(_serde::de::MapAccess::next_value::<_serde::de::IgnoredAny>(&mut __map)); let _ = try!(_serde::de::MapAccess::next_value::<_serde::de::IgnoredAny>(&mut __map));
continue; continue;
}, },
_serde::__private::de::TagContentOtherField::Tag => { _serde::__private::de::TagContentOtherField::Tag => {
@@ -1728,6 +1733,8 @@ fn deserialize_externally_tagged_variant(
} }
} }
// Generates significant part of the visit_seq and visit_map bodies of visitors
// for the variants of internally tagged enum.
fn deserialize_internally_tagged_variant( fn deserialize_internally_tagged_variant(
params: &Parameters, params: &Parameters,
variant: &Variant, variant: &Variant,
@@ -1779,11 +1786,9 @@ fn deserialize_untagged_variant(
deserializer: TokenStream, deserializer: TokenStream,
) -> Fragment { ) -> Fragment {
if let Some(path) = variant.attrs.deserialize_with() { if let Some(path) = variant.attrs.deserialize_with() {
let (wrapper, wrapper_ty, unwrap_fn) = wrap_deserialize_variant_with(params, variant, path); let unwrap_fn = unwrap_to_variant_closure(params, variant, false);
return quote_block! { return quote_block! {
#wrapper _serde::__private::Result::map(#path(#deserializer), #unwrap_fn)
_serde::__private::Result::map(
<#wrapper_ty as _serde::Deserialize>::deserialize(#deserializer), #unwrap_fn)
}; };
} }
@@ -2883,44 +2888,61 @@ fn wrap_deserialize_variant_with(
variant: &Variant, variant: &Variant,
deserialize_with: &syn::ExprPath, deserialize_with: &syn::ExprPath,
) -> (TokenStream, TokenStream, TokenStream) { ) -> (TokenStream, TokenStream, TokenStream) {
let this = &params.this;
let variant_ident = &variant.ident;
let field_tys = variant.fields.iter().map(|field| field.ty); let field_tys = variant.fields.iter().map(|field| field.ty);
let (wrapper, wrapper_ty) = let (wrapper, wrapper_ty) =
wrap_deserialize_with(params, &quote!((#(#field_tys),*)), deserialize_with); wrap_deserialize_with(params, &quote!((#(#field_tys),*)), deserialize_with);
let unwrap_fn = unwrap_to_variant_closure(params, variant, true);
(wrapper, wrapper_ty, unwrap_fn)
}
// Generates closure that converts single input parameter to the final value.
fn unwrap_to_variant_closure(
params: &Parameters,
variant: &Variant,
with_wrapper: bool,
) -> TokenStream {
let this = &params.this;
let variant_ident = &variant.ident;
let (arg, wrapper) = if with_wrapper {
(quote! { __wrap }, quote! { __wrap.value })
} else {
let field_tys = variant.fields.iter().map(|field| field.ty);
(quote! { __wrap: (#(#field_tys),*) }, quote! { __wrap })
};
let field_access = (0..variant.fields.len()).map(|n| { let field_access = (0..variant.fields.len()).map(|n| {
Member::Unnamed(Index { Member::Unnamed(Index {
index: n as u32, index: n as u32,
span: Span::call_site(), span: Span::call_site(),
}) })
}); });
let unwrap_fn = match variant.style {
match variant.style {
Style::Struct if variant.fields.len() == 1 => { Style::Struct if variant.fields.len() == 1 => {
let member = &variant.fields[0].member; let member = &variant.fields[0].member;
quote! { quote! {
|__wrap| #this::#variant_ident { #member: __wrap.value } |#arg| #this::#variant_ident { #member: #wrapper }
} }
} }
Style::Struct => { Style::Struct => {
let members = variant.fields.iter().map(|field| &field.member); let members = variant.fields.iter().map(|field| &field.member);
quote! { quote! {
|__wrap| #this::#variant_ident { #(#members: __wrap.value.#field_access),* } |#arg| #this::#variant_ident { #(#members: #wrapper.#field_access),* }
} }
} }
Style::Tuple => quote! { Style::Tuple => quote! {
|__wrap| #this::#variant_ident(#(__wrap.value.#field_access),*) |#arg| #this::#variant_ident(#(#wrapper.#field_access),*)
}, },
Style::Newtype => quote! { Style::Newtype => quote! {
|__wrap| #this::#variant_ident(__wrap.value) |#arg| #this::#variant_ident(#wrapper)
}, },
Style::Unit => quote! { Style::Unit => quote! {
|__wrap| #this::#variant_ident |#arg| #this::#variant_ident
}, },
}; }
(wrapper, wrapper_ty, unwrap_fn)
} }
fn expr_is_missing(field: &Field, cattrs: &attr::Container) -> Fragment { fn expr_is_missing(field: &Field, cattrs: &attr::Container) -> Fragment {
+2 -2
View File
@@ -13,9 +13,8 @@
//! //!
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html //! [https://serde.rs/derive.html]: https://serde.rs/derive.html
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.128")] #![doc(html_root_url = "https://docs.rs/serde_derive/1.0.131")]
#![allow(unknown_lints, bare_trait_objects)] #![allow(unknown_lints, bare_trait_objects)]
#![deny(clippy::all, clippy::pedantic)]
// Ignored clippy lints // Ignored clippy lints
#![allow( #![allow(
// clippy false positive: https://github.com/rust-lang/rust-clippy/issues/7054 // clippy false positive: https://github.com/rust-lang/rust-clippy/issues/7054
@@ -44,6 +43,7 @@
clippy::indexing_slicing, clippy::indexing_slicing,
clippy::items_after_statements, clippy::items_after_statements,
clippy::let_underscore_drop, clippy::let_underscore_drop,
clippy::manual_assert,
clippy::map_err_ignore, clippy::map_err_ignore,
clippy::match_same_arms, clippy::match_same_arms,
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/6984 // clippy bug: https://github.com/rust-lang/rust-clippy/issues/6984
+103 -42
View File
@@ -1,7 +1,7 @@
use proc_macro2::{Span, TokenStream}; use proc_macro2::TokenStream;
use syn::Ident; use quote::format_ident;
use internals::ast::{Container, Data, Field, Style}; use internals::ast::{Container, Data, Field, Style, Variant};
// Suppress dead_code warnings that would otherwise appear when using a remote // Suppress dead_code warnings that would otherwise appear when using a remote
// derive. Other than this pretend code, a struct annotated with remote derive // derive. Other than this pretend code, a struct annotated with remote derive
@@ -20,8 +20,8 @@ use internals::ast::{Container, Data, Field, Style};
// 8 | enum EnumDef { V } // 8 | enum EnumDef { V }
// | ^ // | ^
// //
pub fn pretend_used(cont: &Container) -> TokenStream { pub fn pretend_used(cont: &Container, is_packed: bool) -> TokenStream {
let pretend_fields = pretend_fields_used(cont); let pretend_fields = pretend_fields_used(cont, is_packed);
let pretend_variants = pretend_variants_used(cont); let pretend_variants = pretend_variants_used(cont);
quote! { quote! {
@@ -32,49 +32,117 @@ pub fn pretend_used(cont: &Container) -> TokenStream {
// For structs with named fields, expands to: // For structs with named fields, expands to:
// //
// match None::<&T> {
// Some(T { a: __v0, b: __v1 }) => {}
// _ => {}
// }
//
// For packed structs on sufficiently new rustc, expands to:
//
// match None::<&T> {
// Some(__v @ T { a: _, b: _ }) => {
// let _ = addr_of!(__v.a);
// let _ = addr_of!(__v.b);
// }
// _ => {}
// }
//
// For packed structs on older rustc, we assume Sized and !Drop, and expand to:
//
// match None::<T> { // match None::<T> {
// Some(T { a: ref __v0, b: ref __v1 }) => {} // Some(T { a: __v0, b: __v1 }) => {}
// _ => {} // _ => {}
// } // }
// //
// For enums, expands to the following but only including struct variants: // For enums, expands to the following but only including struct variants:
// //
// match None::<T> { // match None::<&T> {
// Some(T::A { a: ref __v0 }) => {} // Some(T::A { a: __v0 }) => {}
// Some(T::B { b: ref __v0 }) => {} // Some(T::B { b: __v0 }) => {}
// _ => {} // _ => {}
// } // }
// //
// The `ref` is important in case the user has written a Drop impl on their fn pretend_fields_used(cont: &Container, is_packed: bool) -> TokenStream {
// type. Rust does not allow destructuring a struct or enum that has a Drop match &cont.data {
// impl. Data::Enum(variants) => pretend_fields_used_enum(cont, variants),
fn pretend_fields_used(cont: &Container) -> TokenStream { Data::Struct(Style::Struct, fields) => {
if is_packed {
pretend_fields_used_struct_packed(cont, fields)
} else {
pretend_fields_used_struct(cont, fields)
}
}
Data::Struct(_, _) => quote!(),
}
}
fn pretend_fields_used_struct(cont: &Container, fields: &[Field]) -> TokenStream {
let type_ident = &cont.ident; let type_ident = &cont.ident;
let (_, ty_generics, _) = cont.generics.split_for_impl(); let (_, ty_generics, _) = cont.generics.split_for_impl();
let patterns = match &cont.data { let members = fields.iter().map(|field| &field.member);
Data::Enum(variants) => variants let placeholders = (0usize..).map(|i| format_ident!("__v{}", i));
.iter()
.filter_map(|variant| match variant.style {
Style::Struct => {
let variant_ident = &variant.ident;
let pat = struct_pattern(&variant.fields);
Some(quote!(#type_ident::#variant_ident #pat))
}
_ => None,
})
.collect::<Vec<_>>(),
Data::Struct(Style::Struct, fields) => {
let pat = struct_pattern(fields);
vec![quote!(#type_ident #pat)]
}
Data::Struct(_, _) => {
return quote!();
}
};
quote! { quote! {
match _serde::__private::None::<#type_ident #ty_generics> { match _serde::__private::None::<&#type_ident #ty_generics> {
_serde::__private::Some(#type_ident { #(#members: #placeholders),* }) => {}
_ => {}
}
}
}
fn pretend_fields_used_struct_packed(cont: &Container, fields: &[Field]) -> TokenStream {
let type_ident = &cont.ident;
let (_, ty_generics, _) = cont.generics.split_for_impl();
let members = fields.iter().map(|field| &field.member).collect::<Vec<_>>();
#[cfg(ptr_addr_of)]
{
quote! {
match _serde::__private::None::<&#type_ident #ty_generics> {
_serde::__private::Some(__v @ #type_ident { #(#members: _),* }) => {
#(
let _ = _serde::__private::ptr::addr_of!(__v.#members);
)*
}
_ => {}
}
}
}
#[cfg(not(ptr_addr_of))]
{
let placeholders = (0usize..).map(|i| format_ident!("__v{}", i));
quote! {
match _serde::__private::None::<#type_ident #ty_generics> {
_serde::__private::Some(#type_ident { #(#members: #placeholders),* }) => {}
_ => {}
}
}
}
}
fn pretend_fields_used_enum(cont: &Container, variants: &[Variant]) -> TokenStream {
let type_ident = &cont.ident;
let (_, ty_generics, _) = cont.generics.split_for_impl();
let patterns = variants
.iter()
.filter_map(|variant| match variant.style {
Style::Struct => {
let variant_ident = &variant.ident;
let members = variant.fields.iter().map(|field| &field.member);
let placeholders = (0usize..).map(|i| format_ident!("__v{}", i));
Some(quote!(#type_ident::#variant_ident { #(#members: #placeholders),* }))
}
_ => None,
})
.collect::<Vec<_>>();
quote! {
match _serde::__private::None::<&#type_ident #ty_generics> {
#( #(
_serde::__private::Some(#patterns) => {} _serde::__private::Some(#patterns) => {}
)* )*
@@ -107,7 +175,7 @@ fn pretend_variants_used(cont: &Container) -> TokenStream {
let cases = variants.iter().map(|variant| { let cases = variants.iter().map(|variant| {
let variant_ident = &variant.ident; let variant_ident = &variant.ident;
let placeholders = &(0..variant.fields.len()) let placeholders = &(0..variant.fields.len())
.map(|i| Ident::new(&format!("__v{}", i), Span::call_site())) .map(|i| format_ident!("__v{}", i))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let pat = match variant.style { let pat = match variant.style {
@@ -131,10 +199,3 @@ fn pretend_variants_used(cont: &Container) -> TokenStream {
quote!(#(#cases)*) quote!(#(#cases)*)
} }
fn struct_pattern(fields: &[Field]) -> TokenStream {
let members = fields.iter().map(|field| &field.member);
let placeholders =
(0..fields.len()).map(|i| Ident::new(&format!("__v{}", i), Span::call_site()));
quote!({ #(#members: ref #placeholders),* })
}
+1 -1
View File
@@ -30,7 +30,7 @@ pub fn expand_derive_serialize(
let impl_block = if let Some(remote) = cont.attrs.remote() { let impl_block = if let Some(remote) = cont.attrs.remote() {
let vis = &input.vis; let vis = &input.vis;
let used = pretend::pretend_used(&cont); let used = pretend::pretend_used(&cont, params.is_packed);
quote! { quote! {
impl #impl_generics #ident #ty_generics #where_clause { impl #impl_generics #ident #ty_generics #where_clause {
#vis fn serialize<__S>(__self: &#remote #ty_generics, __serializer: __S) -> #serde::__private::Result<__S::Ok, __S::Error> #vis fn serialize<__S>(__self: &#remote #ty_generics, __serializer: __S) -> #serde::__private::Result<__S::Ok, __S::Error>
+1
View File
@@ -2,6 +2,7 @@
name = "serde_derive_internals" name = "serde_derive_internals"
version = "0.26.0" # remember to update html_root_url version = "0.26.0" # remember to update html_root_url
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"] authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
rust-version = "1.31"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
description = "AST representation used by Serde derive macros. Unstable." description = "AST representation used by Serde derive macros. Unstable."
homepage = "https://serde.rs" homepage = "https://serde.rs"
+1 -1
View File
@@ -1,6 +1,5 @@
#![doc(html_root_url = "https://docs.rs/serde_derive_internals/0.26.0")] #![doc(html_root_url = "https://docs.rs/serde_derive_internals/0.26.0")]
#![allow(unknown_lints, bare_trait_objects)] #![allow(unknown_lints, bare_trait_objects)]
#![deny(clippy::all, clippy::pedantic)]
// Ignored clippy lints // Ignored clippy lints
#![allow( #![allow(
clippy::cognitive_complexity, clippy::cognitive_complexity,
@@ -23,6 +22,7 @@
clippy::enum_glob_use, clippy::enum_glob_use,
clippy::items_after_statements, clippy::items_after_statements,
clippy::let_underscore_drop, clippy::let_underscore_drop,
clippy::manual_assert,
clippy::match_same_arms, clippy::match_same_arms,
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/6984 // clippy bug: https://github.com/rust-lang/rust-clippy/issues/6984
clippy::match_wildcard_for_single_variants, clippy::match_wildcard_for_single_variants,
+2 -1
View File
@@ -1,7 +1,8 @@
[package] [package]
name = "serde_test" name = "serde_test"
version = "1.0.128" # remember to update html_root_url version = "1.0.131" # remember to update html_root_url
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"] authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
rust-version = "1.15"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
description = "Token De/Serializer for testing De/Serialize implementations" description = "Token De/Serializer for testing De/Serialize implementations"
homepage = "https://serde.rs" homepage = "https://serde.rs"
+2 -2
View File
@@ -144,9 +144,8 @@
//! # } //! # }
//! ``` //! ```
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.128")] #![doc(html_root_url = "https://docs.rs/serde_test/1.0.131")]
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))] #![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
// Ignored clippy lints // Ignored clippy lints
#![cfg_attr(feature = "cargo-clippy", allow(float_cmp, needless_doctest_main))] #![cfg_attr(feature = "cargo-clippy", allow(float_cmp, needless_doctest_main))]
// Ignored clippy_pedantic lints // Ignored clippy_pedantic lints
@@ -155,6 +154,7 @@
allow( allow(
cloned_instead_of_copied, cloned_instead_of_copied,
empty_line_after_outer_attr, empty_line_after_outer_attr,
manual_assert,
missing_docs_in_private_items, missing_docs_in_private_items,
missing_panics_doc, missing_panics_doc,
module_name_repetitions, module_name_repetitions,
+1 -1
View File
@@ -23,4 +23,4 @@ rustversion = "1.0"
serde = { path = "../serde", features = ["rc", "derive"] } serde = { path = "../serde", features = ["rc", "derive"] }
serde_derive = { path = "../serde_derive", features = ["deserialize_in_place"] } serde_derive = { path = "../serde_derive", features = ["deserialize_in_place"] }
serde_test = { path = "../serde_test" } serde_test = { path = "../serde_test" }
trybuild = { version = "1.0.19", features = ["diff"] } trybuild = { version = "1.0.49", features = ["diff"] }
+1
View File
@@ -3,6 +3,7 @@
clippy::from_over_into, clippy::from_over_into,
// Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422
clippy::nonstandard_macro_braces, clippy::nonstandard_macro_braces,
clippy::too_many_lines,
clippy::trivially_copy_pass_by_ref clippy::trivially_copy_pass_by_ref
)] )]
+2
View File
@@ -1,3 +1,5 @@
#![allow(clippy::items_after_statements, clippy::used_underscore_binding)]
use serde::{Deserialize, Deserializer}; use serde::{Deserialize, Deserializer};
use serde_test::{assert_de_tokens, assert_de_tokens_error, Token}; use serde_test::{assert_de_tokens, assert_de_tokens_error, Token};
+7 -1
View File
@@ -1,4 +1,10 @@
#![allow(clippy::decimal_literal_representation, clippy::unreadable_literal)] #![allow(
clippy::decimal_literal_representation,
clippy::empty_enum,
clippy::manual_assert,
clippy::needless_pass_by_value,
clippy::unreadable_literal
)]
#![cfg_attr(feature = "unstable", feature(never_type))] #![cfg_attr(feature = "unstable", feature(never_type))]
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
+66
View File
@@ -6,9 +6,14 @@
#![allow( #![allow(
unknown_lints, unknown_lints,
mixed_script_confusables, mixed_script_confusables,
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 bug: https://github.com/rust-lang/rust-clippy/issues/7422
clippy::nonstandard_macro_braces, clippy::nonstandard_macro_braces,
clippy::ptr_arg, clippy::ptr_arg,
clippy::too_many_lines,
clippy::trivially_copy_pass_by_ref clippy::trivially_copy_pass_by_ref
)] )]
@@ -823,3 +828,64 @@ where
{ {
vec.first().serialize(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) {}
}
+5 -1
View File
@@ -1,5 +1,9 @@
#![deny(trivial_numeric_casts)] #![deny(trivial_numeric_casts)]
#![allow(clippy::redundant_field_names)] #![allow(
clippy::enum_variant_names,
clippy::redundant_field_names,
clippy::too_many_lines
)]
mod bytes; mod bytes;
+2
View File
@@ -1,3 +1,5 @@
#![allow(clippy::used_underscore_binding)]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[test] #[test]
+2
View File
@@ -1,3 +1,5 @@
#![allow(clippy::type_repetition_in_bounds)]
#[test] #[test]
fn test_gen_custom_serde() { fn test_gen_custom_serde() {
#[derive(serde::Serialize, serde::Deserialize)] #[derive(serde::Serialize, serde::Deserialize)]
+2
View File
@@ -1,3 +1,5 @@
#![allow(clippy::similar_names)]
use serde::de::value::{self, MapAccessDeserializer}; use serde::de::value::{self, MapAccessDeserializer};
use serde::de::{IntoDeserializer, MapAccess, Visitor}; use serde::de::{IntoDeserializer, MapAccess, Visitor};
use serde::{Deserialize, Deserializer}; use serde::{Deserialize, Deserializer};
@@ -1,5 +1,5 @@
error: failed to parse borrowed lifetimes: "zzz" error: failed to parse borrowed lifetimes: "zzz"
--> $DIR/bad_lifetimes.rs:5:22 --> tests/ui/borrow/bad_lifetimes.rs:5:22
| |
5 | #[serde(borrow = "zzz")] 5 | #[serde(borrow = "zzz")]
| ^^^^^ | ^^^^^
@@ -1,5 +1,5 @@
error: duplicate borrowed lifetime `'a` error: duplicate borrowed lifetime `'a`
--> $DIR/duplicate_lifetime.rs:5:22 --> tests/ui/borrow/duplicate_lifetime.rs:5:22
| |
5 | #[serde(borrow = "'a + 'a")] 5 | #[serde(borrow = "'a + 'a")]
| ^^^^^^^^^ | ^^^^^^^^^
@@ -1,5 +1,5 @@
error: duplicate serde attribute `borrow` error: duplicate serde attribute `borrow`
--> $DIR/duplicate_variant.rs:8:13 --> tests/ui/borrow/duplicate_variant.rs:8:13
| |
8 | #[serde(borrow)] 8 | #[serde(borrow)]
| ^^^^^^ | ^^^^^^
@@ -1,5 +1,5 @@
error: at least one lifetime must be borrowed error: at least one lifetime must be borrowed
--> $DIR/empty_lifetimes.rs:5:22 --> tests/ui/borrow/empty_lifetimes.rs:5:22
| |
5 | #[serde(borrow = "")] 5 | #[serde(borrow = "")]
| ^^ | ^^
@@ -1,5 +1,5 @@
error: field `s` has no lifetimes to borrow error: field `s` has no lifetimes to borrow
--> $DIR/no_lifetimes.rs:5:5 --> tests/ui/borrow/no_lifetimes.rs:5:5
| |
5 | / #[serde(borrow)] 5 | / #[serde(borrow)]
6 | | s: String, 6 | | s: String,
@@ -1,5 +1,5 @@
error: #[serde(borrow)] may only be used on newtype variants error: #[serde(borrow)] may only be used on newtype variants
--> $DIR/struct_variant.rs:8:5 --> tests/ui/borrow/struct_variant.rs:8:5
| |
8 | / #[serde(borrow)] 8 | / #[serde(borrow)]
9 | | S { s: Str<'a> }, 9 | | S { s: Str<'a> },
@@ -1,5 +1,5 @@
error: field `s` does not have lifetime 'b error: field `s` does not have lifetime 'b
--> $DIR/wrong_lifetime.rs:5:5 --> tests/ui/borrow/wrong_lifetime.rs:5:5
| |
5 | / #[serde(borrow = "'b")] 5 | / #[serde(borrow = "'b")]
6 | | s: &'a str, 6 | | s: &'a str,
@@ -1,5 +1,5 @@
error: enum tags `conflict` for type and content conflict with each other error: enum tags `conflict` for type and content conflict with each other
--> $DIR/adjacent-tag.rs:4:1 --> tests/ui/conflict/adjacent-tag.rs:4:1
| |
4 | / #[serde(tag = "conflict", content = "conflict")] 4 | / #[serde(tag = "conflict", content = "conflict")]
5 | | enum E { 5 | | enum E {
@@ -1,5 +1,5 @@
error: #[serde(flatten)] cannot be used on newtype structs error: #[serde(flatten)] cannot be used on newtype structs
--> $DIR/flatten-newtype-struct.rs:6:12 --> tests/ui/conflict/flatten-newtype-struct.rs:6:12
| |
6 | struct Foo(#[serde(flatten)] HashMap<String, String>); 6 | struct Foo(#[serde(flatten)] HashMap<String, String>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1,5 +1,5 @@
error: #[serde(flatten)] cannot be used on tuple structs error: #[serde(flatten)] cannot be used on tuple structs
--> $DIR/flatten-tuple-struct.rs:6:17 --> tests/ui/conflict/flatten-tuple-struct.rs:6:17
| |
6 | struct Foo(u32, #[serde(flatten)] HashMap<String, String>); 6 | struct Foo(u32, #[serde(flatten)] HashMap<String, String>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1,5 +1,5 @@
error: #[serde(from = "...")] and #[serde(try_from = "...")] conflict with each other error: #[serde(from = "...")] and #[serde(try_from = "...")] conflict with each other
--> $DIR/from-try-from.rs:4:1 --> tests/ui/conflict/from-try-from.rs:4:1
| |
4 | / #[serde(from = "u64", try_from = "u64")] 4 | / #[serde(from = "u64", try_from = "u64")]
5 | | struct S { 5 | | struct S {
@@ -1,5 +1,5 @@
error: variant field name `conflict` conflicts with internal tag error: variant field name `conflict` conflicts with internal tag
--> $DIR/internal-tag-alias.rs:4:1 --> tests/ui/conflict/internal-tag-alias.rs:4:1
| |
4 | / #[serde(tag = "conflict")] 4 | / #[serde(tag = "conflict")]
5 | | enum E { 5 | | enum E {
@@ -1,5 +1,5 @@
error: variant field name `conflict` conflicts with internal tag error: variant field name `conflict` conflicts with internal tag
--> $DIR/internal-tag.rs:4:1 --> tests/ui/conflict/internal-tag.rs:4:1
| |
4 | / #[serde(tag = "conflict")] 4 | / #[serde(tag = "conflict")]
5 | | enum E { 5 | | enum E {
@@ -1,5 +1,5 @@
error: #[serde(default)] can only be used on structs with named fields error: #[serde(default)] can only be used on structs with named fields
--> $DIR/enum.rs:5:1 --> tests/ui/default-attribute/enum.rs:5:1
| |
5 | enum E { 5 | enum E {
| ^^^^ | ^^^^
@@ -1,5 +1,5 @@
error: #[serde(default = "...")] can only be used on structs with named fields error: #[serde(default = "...")] can only be used on structs with named fields
--> $DIR/enum_path.rs:5:1 --> tests/ui/default-attribute/enum_path.rs:5:1
| |
5 | enum E { 5 | enum E {
| ^^^^ | ^^^^
@@ -1,5 +1,5 @@
error: #[serde(default)] can only be used on structs with named fields error: #[serde(default)] can only be used on structs with named fields
--> $DIR/nameless_struct_fields.rs:5:9 --> tests/ui/default-attribute/nameless_struct_fields.rs:5:9
| |
5 | struct T(u8, u8); 5 | struct T(u8, u8);
| ^^^^^^^^ | ^^^^^^^^
@@ -1,5 +1,5 @@
error: #[serde(default = "...")] can only be used on structs with named fields error: #[serde(default = "...")] can only be used on structs with named fields
--> $DIR/nameless_struct_fields_path.rs:5:9 --> tests/ui/default-attribute/nameless_struct_fields_path.rs:5:9
| |
5 | struct T(u8, u8); 5 | struct T(u8, u8);
| ^^^^^^^^ | ^^^^^^^^
@@ -1,5 +1,5 @@
error: unknown serde field attribute `serialize` error: unknown serde field attribute `serialize`
--> $DIR/rename-and-ser.rs:5:27 --> tests/ui/duplicate-attribute/rename-and-ser.rs:5:27
| |
5 | #[serde(rename = "x", serialize = "y")] 5 | #[serde(rename = "x", serialize = "y")]
| ^^^^^^^^^ | ^^^^^^^^^
@@ -1,5 +1,5 @@
error: duplicate serde attribute `rename` error: duplicate serde attribute `rename`
--> $DIR/rename-ser-rename-ser.rs:5:38 --> tests/ui/duplicate-attribute/rename-ser-rename-ser.rs:5:38
| |
5 | #[serde(rename(serialize = "x"), rename(serialize = "y"))] 5 | #[serde(rename(serialize = "x"), rename(serialize = "y"))]
| ^^^^^^ | ^^^^^^
@@ -1,5 +1,5 @@
error: duplicate serde attribute `rename` error: duplicate serde attribute `rename`
--> $DIR/rename-ser-rename.rs:6:13 --> tests/ui/duplicate-attribute/rename-ser-rename.rs:6:13
| |
6 | #[serde(rename = "y")] 6 | #[serde(rename = "y")]
| ^^^^^^ | ^^^^^^
@@ -1,5 +1,5 @@
error: duplicate serde attribute `rename` error: duplicate serde attribute `rename`
--> $DIR/rename-ser-ser.rs:5:37 --> tests/ui/duplicate-attribute/rename-ser-ser.rs:5:37
| |
5 | #[serde(rename(serialize = "x", serialize = "y"))] 5 | #[serde(rename(serialize = "x", serialize = "y"))]
| ^^^^^^^^^ | ^^^^^^^^^
@@ -1,5 +1,5 @@
error: duplicate serde attribute `rename` error: duplicate serde attribute `rename`
--> $DIR/two-rename-ser.rs:6:13 --> tests/ui/duplicate-attribute/two-rename-ser.rs:6:13
| |
6 | #[serde(rename(serialize = "y"))] 6 | #[serde(rename(serialize = "y"))]
| ^^^^^^ | ^^^^^^
@@ -1,5 +1,5 @@
error: duplicate serde attribute `serialize_with` error: duplicate serde attribute `serialize_with`
--> $DIR/with-and-serialize-with.rs:5:25 --> tests/ui/duplicate-attribute/with-and-serialize-with.rs:5:25
| |
5 | #[serde(with = "w", serialize_with = "s")] 5 | #[serde(with = "w", serialize_with = "s")]
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
@@ -1,5 +1,5 @@
error: #[serde(tag = "...", content = "...")] must be used together error: #[serde(tag = "...", content = "...")] must be used together
--> $DIR/content-no-tag.rs:4:9 --> tests/ui/enum-representation/content-no-tag.rs:4:9
| |
4 | #[serde(content = "c")] 4 | #[serde(content = "c")]
| ^^^^^^^ | ^^^^^^^
@@ -1,5 +1,5 @@
error: #[serde(tag = "...")] cannot be used with tuple variants error: #[serde(tag = "...")] cannot be used with tuple variants
--> $DIR/internal-tuple-variant.rs:6:5 --> tests/ui/enum-representation/internal-tuple-variant.rs:6:5
| |
6 | Tuple(u8, u8), 6 | Tuple(u8, u8),
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
@@ -1,17 +1,17 @@
error: untagged enum cannot have #[serde(tag = "...", content = "...")] error: untagged enum cannot have #[serde(tag = "...", content = "...")]
--> $DIR/untagged-and-adjacent.rs:4:9 --> tests/ui/enum-representation/untagged-and-adjacent.rs:4:9
| |
4 | #[serde(untagged)] 4 | #[serde(untagged)]
| ^^^^^^^^ | ^^^^^^^^
error: untagged enum cannot have #[serde(tag = "...", content = "...")] error: untagged enum cannot have #[serde(tag = "...", content = "...")]
--> $DIR/untagged-and-adjacent.rs:5:9 --> tests/ui/enum-representation/untagged-and-adjacent.rs:5:9
| |
5 | #[serde(tag = "t", content = "c")] 5 | #[serde(tag = "t", content = "c")]
| ^^^ | ^^^
error: untagged enum cannot have #[serde(tag = "...", content = "...")] error: untagged enum cannot have #[serde(tag = "...", content = "...")]
--> $DIR/untagged-and-adjacent.rs:5:20 --> tests/ui/enum-representation/untagged-and-adjacent.rs:5:20
| |
5 | #[serde(tag = "t", content = "c")] 5 | #[serde(tag = "t", content = "c")]
| ^^^^^^^ | ^^^^^^^
@@ -1,11 +1,11 @@
error: untagged enum cannot have #[serde(content = "...")] error: untagged enum cannot have #[serde(content = "...")]
--> $DIR/untagged-and-content.rs:4:9 --> tests/ui/enum-representation/untagged-and-content.rs:4:9
| |
4 | #[serde(untagged)] 4 | #[serde(untagged)]
| ^^^^^^^^ | ^^^^^^^^
error: untagged enum cannot have #[serde(content = "...")] error: untagged enum cannot have #[serde(content = "...")]
--> $DIR/untagged-and-content.rs:5:9 --> tests/ui/enum-representation/untagged-and-content.rs:5:9
| |
5 | #[serde(content = "c")] 5 | #[serde(content = "c")]
| ^^^^^^^ | ^^^^^^^
@@ -1,11 +1,11 @@
error: enum cannot be both untagged and internally tagged error: enum cannot be both untagged and internally tagged
--> $DIR/untagged-and-internal.rs:4:9 --> tests/ui/enum-representation/untagged-and-internal.rs:4:9
| |
4 | #[serde(untagged)] 4 | #[serde(untagged)]
| ^^^^^^^^ | ^^^^^^^^
error: enum cannot be both untagged and internally tagged error: enum cannot be both untagged and internally tagged
--> $DIR/untagged-and-internal.rs:5:9 --> tests/ui/enum-representation/untagged-and-internal.rs:5:9
| |
5 | #[serde(tag = "type")] 5 | #[serde(tag = "type")]
| ^^^ | ^^^
@@ -1,5 +1,5 @@
error: #[serde(untagged)] can only be used on enums error: #[serde(untagged)] can only be used on enums
--> $DIR/untagged-struct.rs:5:1 --> tests/ui/enum-representation/untagged-struct.rs:5:1
| |
5 | struct S; 5 | struct S;
| ^^^^^^ | ^^^^^^
@@ -1,5 +1,5 @@
error: expected serde rename attribute to be a string: `rename = "..."` error: expected serde rename attribute to be a string: `rename = "..."`
--> $DIR/boolean.rs:5:22 --> tests/ui/expected-string/boolean.rs:5:22
| |
5 | #[serde(rename = true)] 5 | #[serde(rename = true)]
| ^^^^ | ^^^^
@@ -1,5 +1,5 @@
error: expected serde rename attribute to be a string: `rename = "..."` error: expected serde rename attribute to be a string: `rename = "..."`
--> $DIR/byte_character.rs:5:22 --> tests/ui/expected-string/byte_character.rs:5:22
| |
5 | #[serde(rename = b'a')] 5 | #[serde(rename = b'a')]
| ^^^^ | ^^^^
@@ -1,5 +1,5 @@
error: expected serde rename attribute to be a string: `rename = "..."` error: expected serde rename attribute to be a string: `rename = "..."`
--> $DIR/byte_string.rs:5:22 --> tests/ui/expected-string/byte_string.rs:5:22
| |
5 | #[serde(rename = b"byte string")] 5 | #[serde(rename = b"byte string")]
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
@@ -1,5 +1,5 @@
error: expected serde rename attribute to be a string: `rename = "..."` error: expected serde rename attribute to be a string: `rename = "..."`
--> $DIR/character.rs:5:22 --> tests/ui/expected-string/character.rs:5:22
| |
5 | #[serde(rename = 'a')] 5 | #[serde(rename = 'a')]
| ^^^ | ^^^
@@ -1,5 +1,5 @@
error: expected serde rename attribute to be a string: `rename = "..."` error: expected serde rename attribute to be a string: `rename = "..."`
--> $DIR/float.rs:5:22 --> tests/ui/expected-string/float.rs:5:22
| |
5 | #[serde(rename = 3.14)] 5 | #[serde(rename = 3.14)]
| ^^^^ | ^^^^
@@ -1,5 +1,5 @@
error: expected serde rename attribute to be a string: `rename = "..."` error: expected serde rename attribute to be a string: `rename = "..."`
--> $DIR/integer.rs:5:22 --> tests/ui/expected-string/integer.rs:5:22
| |
5 | #[serde(rename = 100)] 5 | #[serde(rename = 100)]
| ^^^ | ^^^
+2 -2
View File
@@ -1,11 +1,11 @@
error: #[serde(field_identifier)] and #[serde(variant_identifier)] cannot both be set error: #[serde(field_identifier)] and #[serde(variant_identifier)] cannot both be set
--> $DIR/both.rs:4:9 --> tests/ui/identifier/both.rs:4:9
| |
4 | #[serde(field_identifier, variant_identifier)] 4 | #[serde(field_identifier, variant_identifier)]
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error: #[serde(field_identifier)] and #[serde(variant_identifier)] cannot both be set error: #[serde(field_identifier)] and #[serde(variant_identifier)] cannot both be set
--> $DIR/both.rs:4:27 --> tests/ui/identifier/both.rs:4:27
| |
4 | #[serde(field_identifier, variant_identifier)] 4 | #[serde(field_identifier, variant_identifier)]
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
@@ -1,5 +1,5 @@
error: #[serde(field_identifier)] can only be used on an enum error: #[serde(field_identifier)] can only be used on an enum
--> $DIR/field_struct.rs:5:1 --> tests/ui/identifier/field_struct.rs:5:1
| |
5 | struct S; 5 | struct S;
| ^^^^^^ | ^^^^^^
@@ -1,5 +1,5 @@
error: #[serde(field_identifier)] may only contain unit variants error: #[serde(field_identifier)] may only contain unit variants
--> $DIR/field_tuple.rs:7:5 --> tests/ui/identifier/field_tuple.rs:7:5
| |
7 | B(u8, u8), 7 | B(u8, u8),
| ^^^^^^^^^ | ^^^^^^^^^
@@ -1,5 +1,5 @@
error: `Other` must be the last variant error: `Other` must be the last variant
--> $DIR/newtype_not_last.rs:7:5 --> tests/ui/identifier/newtype_not_last.rs:7:5
| |
7 | Other(String), 7 | Other(String),
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
@@ -1,5 +1,5 @@
error: #[serde(other)] must be on a unit variant error: #[serde(other)] must be on a unit variant
--> $DIR/not_unit.rs:7:5 --> tests/ui/identifier/not_unit.rs:7:5
| |
7 | / #[serde(other)] 7 | / #[serde(other)]
8 | | Other(u8, u8), 8 | | Other(u8, u8),
@@ -1,5 +1,5 @@
error: #[serde(other)] must be on the last variant error: #[serde(other)] must be on the last variant
--> $DIR/other_not_last.rs:7:5 --> tests/ui/identifier/other_not_last.rs:7:5
| |
7 | / #[serde(other)] 7 | / #[serde(other)]
8 | | Other, 8 | | Other,
@@ -1,5 +1,5 @@
error: #[serde(other)] cannot appear on untagged enum error: #[serde(other)] cannot appear on untagged enum
--> $DIR/other_untagged.rs:6:5 --> tests/ui/identifier/other_untagged.rs:6:5
| |
6 | / #[serde(other)] 6 | / #[serde(other)]
7 | | Other, 7 | | Other,
@@ -1,5 +1,5 @@
error: #[serde(other)] may not be used on a variant identifier error: #[serde(other)] may not be used on a variant identifier
--> $DIR/other_variant.rs:6:5 --> tests/ui/identifier/other_variant.rs:6:5
| |
6 | / #[serde(other)] 6 | / #[serde(other)]
7 | | Other, 7 | | Other,
@@ -1,5 +1,5 @@
error: #[serde(variant_identifier)] can only be used on an enum error: #[serde(variant_identifier)] can only be used on an enum
--> $DIR/variant_struct.rs:5:1 --> tests/ui/identifier/variant_struct.rs:5:1
| |
5 | struct S; 5 | struct S;
| ^^^^^^ | ^^^^^^
@@ -1,5 +1,5 @@
error: #[serde(variant_identifier)] may only contain unit variants error: #[serde(variant_identifier)] may only contain unit variants
--> $DIR/variant_tuple.rs:7:5 --> tests/ui/identifier/variant_tuple.rs:7:5
| |
7 | B(u8, u8), 7 | B(u8, u8),
| ^^^^^^^^^ | ^^^^^^^^^
+1 -1
View File
@@ -1,5 +1,5 @@
error: malformed bound attribute, expected `bound(serialize = ..., deserialize = ...)` error: malformed bound attribute, expected `bound(serialize = ..., deserialize = ...)`
--> $DIR/bound.rs:5:19 --> tests/ui/malformed/bound.rs:5:19
| |
5 | #[serde(bound(unknown))] 5 | #[serde(bound(unknown))]
| ^^^^^^^ | ^^^^^^^
+1 -1
View File
@@ -1,5 +1,5 @@
error: unexpected end of input, expected literal error: unexpected end of input, expected literal
--> $DIR/cut_off.rs:4:17 --> tests/ui/malformed/cut_off.rs:4:17
| |
4 | #[serde(rename =)] 4 | #[serde(rename =)]
| ^ | ^
@@ -1,11 +1,11 @@
error: expected #[serde(...)] error: expected #[serde(...)]
--> $DIR/not_list.rs:4:3 --> tests/ui/malformed/not_list.rs:4:3
| |
4 | #[serde] 4 | #[serde]
| ^^^^^ | ^^^^^
error: expected #[serde(...)] error: expected #[serde(...)]
--> $DIR/not_list.rs:5:3 --> tests/ui/malformed/not_list.rs:5:3
| |
5 | #[serde = "?"] 5 | #[serde = "?"]
| ^^^^^^^^^^^ | ^^^^^^^^^^^
+1 -1
View File
@@ -1,5 +1,5 @@
error: malformed rename attribute, expected `rename(serialize = ..., deserialize = ...)` error: malformed rename attribute, expected `rename(serialize = ..., deserialize = ...)`
--> $DIR/rename.rs:5:20 --> tests/ui/malformed/rename.rs:5:20
| |
5 | #[serde(rename(unknown))] 5 | #[serde(rename(unknown))]
| ^^^^^^^ | ^^^^^^^
@@ -1,5 +1,5 @@
error: cannot deserialize when there is a lifetime parameter called 'de error: cannot deserialize when there is a lifetime parameter called 'de
--> $DIR/deserialize_de_lifetime.rs:4:10 --> tests/ui/precondition/deserialize_de_lifetime.rs:4:10
| |
4 | struct S<'de> { 4 | struct S<'de> {
| ^^^ | ^^^
@@ -1,5 +1,5 @@
error: cannot deserialize a dynamically sized struct error: cannot deserialize a dynamically sized struct
--> $DIR/deserialize_dst.rs:4:1 --> tests/ui/precondition/deserialize_dst.rs:4:1
| |
4 | / struct S { 4 | / struct S {
5 | | string: String, 5 | | string: String,
@@ -1,5 +1,5 @@
error: field identifiers cannot be serialized error: field identifiers cannot be serialized
--> $DIR/serialize_field_identifier.rs:4:1 --> tests/ui/precondition/serialize_field_identifier.rs:4:1
| |
4 | / #[serde(field_identifier)] 4 | / #[serde(field_identifier)]
5 | | enum F { 5 | | enum F {
@@ -1,5 +1,5 @@
error: variant identifiers cannot be serialized error: variant identifiers cannot be serialized
--> $DIR/serialize_variant_identifier.rs:4:1 --> tests/ui/precondition/serialize_variant_identifier.rs:4:1
| |
4 | / #[serde(variant_identifier)] 4 | / #[serde(variant_identifier)]
5 | | enum F { 5 | | enum F {
+1 -1
View File
@@ -1,5 +1,5 @@
error: failed to parse path: "~~~" error: failed to parse path: "~~~"
--> $DIR/bad_getter.rs:12:22 --> tests/ui/remote/bad_getter.rs:12:22
| |
12 | #[serde(getter = "~~~")] 12 | #[serde(getter = "~~~")]
| ^^^^^ | ^^^^^
+1 -1
View File
@@ -1,5 +1,5 @@
error: failed to parse path: "~~~" error: failed to parse path: "~~~"
--> $DIR/bad_remote.rs:10:18 --> tests/ui/remote/bad_remote.rs:10:18
| |
10 | #[serde(remote = "~~~")] 10 | #[serde(remote = "~~~")]
| ^^^^^ | ^^^^^
@@ -1,5 +1,5 @@
error: #[serde(getter = "...")] is not allowed in an enum error: #[serde(getter = "...")] is not allowed in an enum
--> $DIR/enum_getter.rs:10:1 --> tests/ui/remote/enum_getter.rs:10:1
| |
10 | / #[serde(remote = "remote::E")] 10 | / #[serde(remote = "remote::E")]
11 | | pub enum E { 11 | | pub enum E {
@@ -1,5 +1,5 @@
error[E0063]: missing field `b` in initializer of `remote::S` error[E0063]: missing field `b` in initializer of `remote::S`
--> $DIR/missing_field.rs:11:18 --> tests/ui/remote/missing_field.rs:11:18
| |
11 | #[serde(remote = "remote::S")] 11 | #[serde(remote = "remote::S")]
| ^^^^^^^^^^^ missing `b` | ^^^^^^^^^^^ missing `b`
@@ -1,5 +1,5 @@
error: #[serde(getter = "...")] can only be used in structs that have #[serde(remote = "...")] error: #[serde(getter = "...")] can only be used in structs that have #[serde(remote = "...")]
--> $DIR/nonremote_getter.rs:4:1 --> tests/ui/remote/nonremote_getter.rs:4:1
| |
4 | / struct S { 4 | / struct S {
5 | | #[serde(getter = "S::get")] 5 | | #[serde(getter = "S::get")]
@@ -1,11 +1,11 @@
error[E0609]: no field `b` on type `&remote::S` error[E0609]: no field `b` on type `&remote::S`
--> $DIR/unknown_field.rs:12:5 --> tests/ui/remote/unknown_field.rs:12:5
| |
12 | b: u8, 12 | b: u8,
| ^ help: a field with a similar name exists: `a` | ^ help: a field with a similar name exists: `a`
error[E0560]: struct `remote::S` has no field named `b` error[E0560]: struct `remote::S` has no field named `b`
--> $DIR/unknown_field.rs:12:5 --> tests/ui/remote/unknown_field.rs:12:5
| |
12 | b: u8, 12 | b: u8,
| ^ help: a field with a similar name exists: `a` | ^ help: a field with a similar name exists: `a`
+6 -5
View File
@@ -1,10 +1,11 @@
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/wrong_de.rs:7:10 --> tests/ui/remote/wrong_de.rs:7:10
| |
7 | #[derive(Deserialize)] 7 | #[derive(Deserialize)]
| ^^^^^^^^^^^ | ^^^^^^^^^^^ expected `u16`, found `u8`
| |
| expected `u16`, found `u8`
| help: you can convert a `u8` to a `u16`: `Deserialize.into()`
| |
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you can convert a `u8` to a `u16`
|
7 | #[derive(Deserialize.into())]
| +++++++
@@ -1,5 +1,5 @@
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/wrong_getter.rs:15:10 --> tests/ui/remote/wrong_getter.rs:15:10
| |
15 | #[derive(Serialize)] 15 | #[derive(Serialize)]
| ^^^^^^^^^ expected `u8`, found `u16` | ^^^^^^^^^ expected `u8`, found `u16`
+1 -1
View File
@@ -1,5 +1,5 @@
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/wrong_ser.rs:9:10 --> tests/ui/remote/wrong_ser.rs:9:10
| |
9 | #[derive(Serialize)] 9 | #[derive(Serialize)]
| ^^^^^^^^^ expected `u8`, found `u16` | ^^^^^^^^^ expected `u8`, found `u16`
@@ -1,5 +1,5 @@
error: unknown rename rule `rename_all = "abc"`, expected one of "lowercase", "UPPERCASE", "PascalCase", "camelCase", "snake_case", "SCREAMING_SNAKE_CASE", "kebab-case", "SCREAMING-KEBAB-CASE" error: unknown rename rule `rename_all = "abc"`, expected one of "lowercase", "UPPERCASE", "PascalCase", "camelCase", "snake_case", "SCREAMING_SNAKE_CASE", "kebab-case", "SCREAMING-KEBAB-CASE"
--> $DIR/container_unknown_rename_rule.rs:4:22 --> tests/ui/rename/container_unknown_rename_rule.rs:4:22
| |
4 | #[serde(rename_all = "abc")] 4 | #[serde(rename_all = "abc")]
| ^^^^^ | ^^^^^
@@ -1,5 +1,5 @@
error: unknown rename rule `rename_all = "abc"`, expected one of "lowercase", "UPPERCASE", "PascalCase", "camelCase", "snake_case", "SCREAMING_SNAKE_CASE", "kebab-case", "SCREAMING-KEBAB-CASE" error: unknown rename rule `rename_all = "abc"`, expected one of "lowercase", "UPPERCASE", "PascalCase", "camelCase", "snake_case", "SCREAMING_SNAKE_CASE", "kebab-case", "SCREAMING-KEBAB-CASE"
--> $DIR/variant_unknown_rename_rule.rs:5:26 --> tests/ui/rename/variant_unknown_rename_rule.rs:5:26
| |
5 | #[serde(rename_all = "abc")] 5 | #[serde(rename_all = "abc")]
| ^^^^^ | ^^^^^
@@ -1,5 +1,5 @@
error: #[serde(tag = "...")] can only be used on enums and structs with named fields error: #[serde(tag = "...")] can only be used on enums and structs with named fields
--> $DIR/internally-tagged-tuple.rs:5:9 --> tests/ui/struct-representation/internally-tagged-tuple.rs:5:9
| |
5 | struct S(u8, u8); 5 | struct S(u8, u8);
| ^^^^^^^^ | ^^^^^^^^
@@ -1,5 +1,5 @@
error: #[serde(tag = "...")] can only be used on enums and structs with named fields error: #[serde(tag = "...")] can only be used on enums and structs with named fields
--> $DIR/internally-tagged-unit.rs:3:10 --> tests/ui/struct-representation/internally-tagged-unit.rs:3:10
| |
3 | #[derive(Serialize)] 3 | #[derive(Serialize)]
| ^^^^^^^^^ | ^^^^^^^^^
@@ -1,5 +1,5 @@
error: #[serde(transparent)] requires struct to have at most one transparent field error: #[serde(transparent)] requires struct to have at most one transparent field
--> $DIR/at_most_one.rs:4:1 --> tests/ui/transparent/at_most_one.rs:4:1
| |
4 | / #[serde(transparent)] 4 | / #[serde(transparent)]
5 | | struct S { 5 | | struct S {
@@ -1,5 +1,5 @@
error: #[serde(transparent)] requires at least one field that is neither skipped nor has a default error: #[serde(transparent)] requires at least one field that is neither skipped nor has a default
--> $DIR/de_at_least_one.rs:4:1 --> tests/ui/transparent/de_at_least_one.rs:4:1
| |
4 | / #[serde(transparent)] 4 | / #[serde(transparent)]
5 | | struct S { 5 | | struct S {
+1 -1
View File
@@ -1,5 +1,5 @@
error: #[serde(transparent)] is not allowed on an enum error: #[serde(transparent)] is not allowed on an enum
--> $DIR/enum.rs:4:1 --> tests/ui/transparent/enum.rs:4:1
| |
4 | / #[serde(transparent)] 4 | / #[serde(transparent)]
5 | | enum E {} 5 | | enum E {}
@@ -1,5 +1,5 @@
error: #[serde(transparent)] requires at least one field that is not skipped error: #[serde(transparent)] requires at least one field that is not skipped
--> $DIR/ser_at_least_one.rs:4:1 --> tests/ui/transparent/ser_at_least_one.rs:4:1
| |
4 | / #[serde(transparent)] 4 | / #[serde(transparent)]
5 | | struct S { 5 | | struct S {
@@ -1,5 +1,5 @@
error: #[serde(transparent)] is not allowed on a unit struct error: #[serde(transparent)] is not allowed on a unit struct
--> $DIR/unit_struct.rs:4:1 --> tests/ui/transparent/unit_struct.rs:4:1
| |
4 | / #[serde(transparent)] 4 | / #[serde(transparent)]
5 | | struct S; 5 | | struct S;
@@ -1,5 +1,5 @@
error: #[serde(transparent)] is not allowed with #[serde(from = "...")] error: #[serde(transparent)] is not allowed with #[serde(from = "...")]
--> $DIR/with_from.rs:4:1 --> tests/ui/transparent/with_from.rs:4:1
| |
4 | / #[serde(transparent, from = "u64")] 4 | / #[serde(transparent, from = "u64")]
5 | | struct S { 5 | | struct S {
@@ -1,5 +1,5 @@
error: #[serde(transparent)] is not allowed with #[serde(into = "...")] error: #[serde(transparent)] is not allowed with #[serde(into = "...")]
--> $DIR/with_into.rs:4:1 --> tests/ui/transparent/with_into.rs:4:1
| |
4 | / #[serde(transparent, into = "u64")] 4 | / #[serde(transparent, into = "u64")]
5 | | struct S { 5 | | struct S {

Some files were not shown because too many files have changed in this diff Show More