Commit Graph

3427 Commits

Author SHA1 Message Date
David Tolnay
4f157a8b81
Prevent build.rs rerunning unnecessarily on all source changes 2022-12-12 14:37:41 -08:00
David Tolnay
d493649f52
Release 1.0.150 2022-12-11 16:24:46 -08:00
David Tolnay
0e947e6c3b
Merge pull request #2338 from serde-rs/atomic
Deduplicate atomic_impl implementations and atomic_impl calls from PR 2337
2022-12-11 16:22:28 -08:00
David Tolnay
9249dab54c
Deduplicate atomic_impl macro calls 2022-12-11 16:12:51 -08:00
David Tolnay
7440e56c53
Deduplicate atomic_impl macro implementations 2022-12-11 16:09:26 -08:00
David Tolnay
0d79306285
Update atomic_impl macros to have same input syntax in all cfgs 2022-12-11 16:01:58 -08:00
David Tolnay
37faaf295e
Mention target_has_atomic stabilization 2022-12-11 15:56:31 -08:00
David Tolnay
650358fa00
Replace obsolete comment about target_has_atomic support 2022-12-11 15:55:19 -08:00
David Tolnay
6159ead404
Invert use_target_has_atomic cfg
This way, a build system that does not want to run Cargo build scripts
can build serde without any cfgs defined, and get the most modern
feature set.
2022-12-11 15:51:19 -08:00
David Tolnay
692ac99c69
Format PR 2337 with rustfmt 2022-12-11 15:48:30 -08:00
David Tolnay
86161ce15f
Adjust spacing in some macro matchers 2022-12-11 15:48:30 -08:00
David Tolnay
5361c790bb
Merge pull request #2337 from badboy/use-target_has_atomic-when-available
Use `target_has_atomic` on Rust 1.60+ to enable atomic (de)serialization
2022-12-11 15:42:00 -08:00
Jan-Erik Rediger
126730edc8 Use target_has_atomic on Rust 1.60+ to enable atomic (de)serialization 2022-12-11 13:34:07 +01:00
David Tolnay
3aec2a96a8
Merge pull request #2334 from dtolnay/mapimpl
Reduce trait bounds in HashMap and BTreeMap serialize
2022-12-04 23:27:03 -08:00
David Tolnay
227d039b1e
Reduce trait bounds in HashMap and BTreeMap serialize 2022-12-04 23:18:02 -08:00
David Tolnay
0353354d61
Release 1.0.149 2022-12-04 23:11:59 -08:00
David Tolnay
34ae0422f4
Merge pull request #2333 from jonasbb/remove-trait-bounds
Remove some Serialize trait bounds
2022-12-03 09:22:27 -08:00
Jonas Bushart
cc128feb4c Remove some Serialize trait bounds
Containers for the most part do not have any trait requirements for
iterating over them. So these bounds are unnecessary when Serializing
only.

This relaxation is part of Rust 1.34
2022-12-03 16:03:37 +01:00
David Tolnay
7766103174
Release 1.0.148 2022-11-27 17:58:18 -08:00
David Tolnay
30f7c7110d
Merge pull request #2331 from dtolnay/remote
Improve error message on remote derive duplicate generics
2022-11-27 17:57:35 -08:00
David Tolnay
50354c2d0b
Improve error message on remote derive duplicate generics 2022-11-27 17:48:48 -08:00
David Tolnay
c4f67e679f
Add ui test of duplicate generics in remote derive 2022-11-27 17:48:48 -08:00
David Tolnay
0daafe423f
Merge pull request #2330 from dtolnay/remote
Fix generated Into conversion involving generic remote derive with getter
2022-11-27 17:48:37 -08:00
David Tolnay
37021910c9
Fix Into conversion involving generic remote derive with getter 2022-11-27 17:18:10 -08:00
David Tolnay
7328b34810
Add test of generic remote derive with getter
Currently fails to compile.

    error[E0107]: missing generics for struct `StructGeneric`
       --> test_suite/tests/test_remote.rs:181:18
        |
    181 | #[serde(remote = "remote::StructGeneric")]
        |                  ^^^^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument
        |
    note: struct defined here, with 1 generic parameter: `T`
       --> test_suite/tests/test_remote.rs:78:16
        |
    78  |     pub struct StructGeneric<T> {
        |                ^^^^^^^^^^^^^ -
    help: add missing generic argument
        |
    181 | #[serde(remote = StructGeneric<T>)]
        |                  ~~~~~~~~~~~~~~~~
2022-11-27 17:17:52 -08:00
David Tolnay
fabbd2b097
Merge pull request #2329 from dtolnay/safety
Revert Buf::as_str safety change from PR 2319
2022-11-27 17:05:41 -08:00
David Tolnay
6814f978d7
Revert Buf::as_str safety change from PR 2319 2022-11-27 16:56:31 -08:00
David Tolnay
4ea403c54a
Merge pull request #2328 from dtolnay/remote
Handle remote type written without turbofish
2022-11-27 16:41:23 -08:00
David Tolnay
f4f6b5af3a
Remove unneeded turbofish from remote attr test 2022-11-27 16:32:06 -08:00
David Tolnay
2062a3c16d
Handle remote type written without turbofish 2022-11-27 16:32:06 -08:00
David Tolnay
9a53bd9125
Add tests of concrete def of generic remote type 2022-11-27 16:05:56 -08:00
David Tolnay
4873b48b02
Time out workflows after 45 minutes
GitHub's default timeout is 6 hours. Recently some of my GitHub Actions
jobs have started randomly stalling for that long, which is inconvenient
because it ties up a chunk of my runner quota. It apepars to be very
rare for a job to recover after stalling. It's better to time out
quicker and retry on a different runner.
2022-11-25 18:56:19 -08:00
David Tolnay
e19844c659
Fix renamed let_underscore_drop lint
warning: lint `clippy::let_underscore_drop` has been renamed to `let_underscore_drop`
      --> serde_derive/src/lib.rs:46:5
       |
    46 |     clippy::let_underscore_drop,
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `let_underscore_drop`
       |
       = note: `#[warn(renamed_and_removed_lints)]` on by default
2022-11-22 19:04:29 -08:00
David Tolnay
93bb9e147c
Resolve manual_let_else clippy lints
error: this could be rewritten as `let...else`
        --> test_suite/tests/test_annotations.rs:1247:5
         |
    1247 | /     let f1 = match pieces.next() {
    1248 | |         Some(x) => x,
    1249 | |         None => return Err(de::Error::invalid_length(0, &"2")),
    1250 | |     };
         | |______^ help: consider writing: `let Some(x) = pieces.next() else { return Err(de::Error::invalid_length(0, &"2")) };`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
         = note: `-D clippy::manual-let-else` implied by `-D clippy::pedantic`

    error: this could be rewritten as `let...else`
        --> test_suite/tests/test_annotations.rs:1251:5
         |
    1251 | /     let f2 = match pieces.next() {
    1252 | |         Some(x) => x,
    1253 | |         None => return Err(de::Error::invalid_length(1, &"2")),
    1254 | |     };
         | |______^ help: consider writing: `let Some(x) = pieces.next() else { return Err(de::Error::invalid_length(1, &"2")) };`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else

    error: this could be rewritten as `let...else`
        --> test_suite/tests/test_annotations.rs:1255:5
         |
    1255 | /     let f2 = match f2.parse() {
    1256 | |         Ok(n) => n,
    1257 | |         Err(_) => {
    1258 | |             return Err(de::Error::invalid_value(
    ...    |
    1262 | |         }
    1263 | |     };
         | |______^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
    help: consider writing
         |
    1255 ~     let Ok(n) = f2.parse() else {
    1256 +             return Err(de::Error::invalid_value(
    1257 +                 Unexpected::Str(f2),
    1258 +                 &"an 8-bit signed integer",
    1259 +             ));
    1260 +         };
         |
2022-11-22 18:45:27 -08:00
David Tolnay
ab230e6e44
Resolve needless_lifetimes clippy lints
error: the following explicit lifetimes could be elided: 'a
       --> serde_derive/src/ser.rs:869:1
        |
    869 | / fn serialize_struct_variant<'a>(
    870 | |     context: StructVariant<'a>,
    871 | |     params: &Parameters,
    872 | |     fields: &[Field],
    873 | |     name: &str,
    874 | | ) -> Fragment {
        | |_____________^
        |
    help: replace with `'_` in generic arguments such as here
       --> serde_derive/src/ser.rs:870:28
        |
    870 |     context: StructVariant<'a>,
        |                            ^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
        = note: `-D clippy::needless-lifetimes` implied by `-D clippy::all`

    error: the following explicit lifetimes could be elided: 'a
       --> serde_derive/src/ser.rs:953:1
        |
    953 | / fn serialize_struct_variant_with_flatten<'a>(
    954 | |     context: StructVariant<'a>,
    955 | |     params: &Parameters,
    956 | |     fields: &[Field],
    957 | |     name: &str,
    958 | | ) -> Fragment {
        | |_____________^
        |
    help: replace with `'_` in generic arguments such as here
       --> serde_derive/src/ser.rs:954:28
        |
    954 |     context: StructVariant<'a>,
        |                            ^^
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
2022-11-22 18:41:37 -08:00
David Tolnay
51ea34b217
Resolve needless_borrowed_reference clippy lints
error: dereferencing a tuple pattern where every element takes a reference
        --> serde/src/private/de.rs:1813:39
         |
    1813 |         let map = content.iter().map(|&(ref k, ref v)| {
         |                                       ^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference
         = note: `-D clippy::needless-borrowed-reference` implied by `-D clippy::all`
    help: try removing the `&` and `ref` parts
         |
    1813 -         let map = content.iter().map(|&(ref k, ref v)| {
    1813 +         let map = content.iter().map(|(k, v)| {
         |

    error: dereferencing a tuple pattern where every element takes a reference
        --> serde/src/private/de.rs:2110:25
         |
    2110 |                     let &(ref variant, ref value) = match iter.next() {
         |                         ^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference
    help: try removing the `&` and `ref` parts
         |
    2110 -                     let &(ref variant, ref value) = match iter.next() {
    2110 +                     let (variant, value) = match iter.next() {
         |

    error: dereferencing a tuple pattern where every element takes a reference
        --> serde/src/private/de.rs:2257:22
         |
    2257 |                 Some(&Content::Seq(ref v)) => {
         |                      ^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference
    help: try removing the `&` and `ref` parts
         |
    2257 -                 Some(&Content::Seq(ref v)) => {
    2257 +                 Some(Content::Seq(v)) => {
         |

    error: dereferencing a tuple pattern where every element takes a reference
        --> serde/src/private/de.rs:2280:22
         |
    2280 |                 Some(&Content::Map(ref v)) => {
         |                      ^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference
    help: try removing the `&` and `ref` parts
         |
    2280 -                 Some(&Content::Map(ref v)) => {
    2280 +                 Some(Content::Map(v)) => {
         |

    error: dereferencing a tuple pattern where every element takes a reference
        --> serde/src/private/de.rs:2283:22
         |
    2283 |                 Some(&Content::Seq(ref v)) => {
         |                      ^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference
    help: try removing the `&` and `ref` parts
         |
    2283 -                 Some(&Content::Seq(ref v)) => {
    2283 +                 Some(Content::Seq(v)) => {
         |

    error: dereferencing a tuple pattern where every element takes a reference
        --> serde/src/private/de.rs:2406:22
         |
    2406 |                 Some(&(ref key, ref value)) => {
         |                      ^^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference
    help: try removing the `&` and `ref` parts
         |
    2406 -                 Some(&(ref key, ref value)) => {
    2406 +                 Some((key, value)) => {
         |

    error: dereferencing a tuple pattern where every element takes a reference
       --> serde/src/private/ser.rs:528:25
        |
    528 |                     for &(ref k, ref v) in entries {
        |                         ^^^^^^^^^^^^^^^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference
    help: try removing the `&` and `ref` parts
        |
    528 -                     for &(ref k, ref v) in entries {
    528 +                     for (k, v) in entries {
        |
2022-11-22 18:40:34 -08:00
Erick Tryzelaar
1050f6b808 Change comment to // Safety: ...
This changes a comment to be explicit on how it's safe we can avoid
validating UTF-8.
2022-11-09 22:44:24 +00:00
Erick Tryzelaar
15ec95a98d Make Buf::as_str private and unsafe, add safety docs
serde:🇩🇪:format::Buf is a private type, so this makes it explicit by
declaring the type `pub(super)`. In addition, it marks the function
`Buf::as_str` as unsafe, which lets us document the callsites with
`// Safety: ...` comments to explain why it is safe to use.
2022-11-09 22:40:40 +00:00
David Tolnay
072145e0e9
Update TOML link to a page that covers usage with serde 2022-11-08 17:33:39 -08:00
David Tolnay
92957f17f2
Merge pull request #2317 from TomAFrench/patch-1
Update link to `toml` crate repo
2022-11-08 17:32:56 -08:00
Tom French
667db558b6
chore: update link to toml crate repo 2022-11-09 01:07:53 +00:00
David Tolnay
f41509261e
Release 1.0.147 2022-10-21 10:04:43 -07:00
David Tolnay
6d009711a2
Merge pull request #2305 from serde-rs/enumaccessdeserializer
Add EnumAccessDeserializer to turn EnumAccess into a Deserializer
2022-10-21 10:04:08 -07:00
David Tolnay
354b48fd40
Add EnumAccessDeserializer to turn EnumAccess into a Deserializer 2022-10-21 09:51:42 -07:00
David Tolnay
3fd8e52f0c
Release 1.0.146 2022-10-21 01:03:47 -07:00
David Tolnay
142dce0d3d
Touch up PR 2303 2022-10-21 01:02:46 -07:00
David Tolnay
6aed101630
Merge pull request #2303 from tage64/master
Serialize and deserialize a tagged newtype variant over unit () as if it was a unit variant
2022-10-21 00:59:40 -07:00
Tage Johansson
e2ccfd9ea7 Remove bad deserialization from sequence to internally tagged newtype variant over . 2022-10-21 09:07:27 +02:00
tage64
a07d794f74
Update test_suite/tests/test_annotations.rs
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2022-10-21 08:53:55 +02:00
Tage Johansson
90d28fc314 Serialize and deserialize a tagged newtype variant over unit () as if it was a unit variant. 2022-10-21 00:27:46 +02:00