Commit Graph

3561 Commits

Author SHA1 Message Date
David Tolnay
7a8e4977e2
Merge pull request #2401 from dtolnay/docderive
Show derive macros in serde's rustdoc
2023-03-14 00:37:06 -07:00
David Tolnay
fb7b6ea7ea
Enable serde derive feature when built by docs.rs 2023-03-14 00:33:41 -07:00
David Tolnay
063dd5b93f
Show derive macros in serde's rustdoc 2023-03-14 00:28:20 -07:00
David Tolnay
a38aa31ade
Merge pull request #2400 from Nilstrieb/explicit-reexport
Use explicit re-export of `serde_derive` to give rustc more info
2023-03-14 00:26:01 -07:00
nils
f42b2581da Use explicit re-export of serde_derive to give rustc more info
rustc will start looking behind `#[cfg(FALSE)]` items to start giving
better diagnostics. By using an explicit re-export instead of a glob
export, we tell rustc that `Deserialize` and `Serialize` exist here.
2023-03-14 08:11:38 +01:00
David Tolnay
2ba406726f
Release 1.0.155 2023-03-11 12:57:53 -08:00
David Tolnay
7e9826e17b
Add link to core CStr stabilization announcement 2023-03-11 12:57:16 -08:00
David Tolnay
f4dcc5c918
Merge pull request #2374 from safarir/master
Enable CStr and CString in no-std enviroment
2023-03-11 12:55:49 -08:00
David Tolnay
8b1887c440
Remove unneeded attr_name argument when parsing borrow attr 2023-03-11 11:35:03 -08:00
David Tolnay
bbfb1d3504
Merge pull request #2399 from dtolnay/borrow
Eagerly parse variant-level borrow attribute instead of deferring entire Meta
2023-03-11 11:29:55 -08:00
David Tolnay
e106feb5ec
Eagerly parse variant-level borrow attribute instead of deferring entire Meta 2023-03-11 11:25:00 -08:00
David Tolnay
696f6f56db
Merge pull request #2398 from dtolnay/borrow
Treat field-level borrow attr as duplicate of variant-level borrow attr
2023-03-11 11:24:50 -08:00
David Tolnay
b7b636a23f
Treat field-level borrow attr as duplicate of variant-level borrow attr 2023-03-11 11:17:40 -08:00
David Tolnay
183b91775e
Fix some comments in parsing of from/try_from/into attributes 2023-03-10 14:16:11 -08:00
David Tolnay
0e70f59021
Merge pull request #2396 from dtolnay/msg
Rearrange parts of attr.rs that rustfmt has been refusing to format
2023-03-09 20:29:50 -08:00
David Tolnay
4d9b76db73
Rearrange parts of attr.rs that rustfmt has been refusing to format 2023-03-09 20:17:43 -08:00
David Tolnay
9af132f594
Factor out duplicated error messages into reused variable 2023-03-09 20:17:20 -08:00
David Tolnay
6c063569c0
Eliminate closure from Punctuated to Vec conversion 2023-03-09 00:43:33 -08:00
David Tolnay
7e9b98401d
Merge pull request #2395 from dtolnay/parsewhere
Simplify parsing of where-predicates in bound attribute
2023-03-09 00:38:57 -08:00
David Tolnay
f301e09e02
Simplify parsing of where-predicates in bound attribute 2023-03-09 00:20:51 -08:00
David Tolnay
b80e722f81
Merge pull request #2394 from dtolnay/emptybound
Eliminate special case on empty string passed to bound=""
2023-03-08 19:53:07 -08:00
David Tolnay
1714c262c4
Eliminate special case on empty string passed to bound=""
This works just fine if we make syn parse "where " as a syn::WhereClause.

The serde(bound = "") attribute is definitely not common enough that it
would warrant a micro-optimization.
2023-03-08 19:20:06 -08:00
David Tolnay
a42cdafdcd
Merge pull request #2393 from dtolnay/testbound
Add a test of serde(bound = "") attribute
2023-03-08 19:19:59 -08:00
David Tolnay
eb4c3f16f7
Add a test of serde(bound = "") attribute
Without serde(bound = ""), serde_derive infers a bound of `T: Serialize`
for the generated Serialize impl and `T: Deserialize<'de> + Default` for
the Deserialize impl. `X` implements none of these so the generated code
would fail to compile.

    error[E0277]: the trait bound `X: Serialize` is not satisfied
       --> test_suite/tests/test_gen.rs:268:14
        |
    268 |     assert::<PhantomDataWrapper<X>>();
        |              ^^^^^^^^^^^^^^^^^^^^^ the trait `Serialize` is not implemented for `X`
        |
        = help: the following other types implement trait `Serialize`:
                  &'a T
                  &'a mut T
                  ()
                  (T0, T1)
                  (T0, T1, T2)
                  (T0, T1, T2, T3)
                  (T0, T1, T2, T3, T4)
                  (T0, T1, T2, T3, T4, T5)
                and 248 others
    note: required for `PhantomDataWrapper<X>` to implement `Serialize`
       --> test_suite/tests/test_gen.rs:262:14
        |
    262 |     #[derive(Serialize, Deserialize)]
        |              ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
    263 |     //#[serde(bound = "")]
    264 |     struct PhantomDataWrapper<T> {
        |            ^^^^^^^^^^^^^^^^^^^^^
    note: required by a bound in `assert`
       --> test_suite/tests/test_gen.rs:767:14
        |
    767 | fn assert<T: Serialize + DeserializeOwned>() {}
        |              ^^^^^^^^^ required by this bound in `assert`
        = note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)

    error[E0277]: the trait bound `X: Deserialize<'_>` is not satisfied
       --> test_suite/tests/test_gen.rs:268:14
        |
    268 |     assert::<PhantomDataWrapper<X>>();
        |              ^^^^^^^^^^^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `X`
        |
        = help: the following other types implement trait `Deserialize<'de>`:
                  <&'a Path as Deserialize<'de>>
                  <&'a [u8] as Deserialize<'de>>
                  <&'a str as Deserialize<'de>>
                  <() as Deserialize<'de>>
                  <(T0, T1) as Deserialize<'de>>
                  <(T0, T1, T2) as Deserialize<'de>>
                  <(T0, T1, T2, T3) as Deserialize<'de>>
                  <(T0, T1, T2, T3, T4) as Deserialize<'de>>
                and 331 others
    note: required for `PhantomDataWrapper<X>` to implement `for<'de> Deserialize<'de>`
       --> test_suite/tests/test_gen.rs:262:25
        |
    262 |     #[derive(Serialize, Deserialize)]
        |                         ^^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
    263 |     //#[serde(bound = "")]
    264 |     struct PhantomDataWrapper<T> {
        |            ^^^^^^^^^^^^^^^^^^^^^
        = note: required for `PhantomDataWrapper<X>` to implement `DeserializeOwned`
    note: required by a bound in `assert`
       --> test_suite/tests/test_gen.rs:767:26
        |
    767 | fn assert<T: Serialize + DeserializeOwned>() {}
        |                          ^^^^^^^^^^^^^^^^ required by this bound in `assert`
        = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)

    error[E0277]: the trait bound `X: Default` is not satisfied
       --> test_suite/tests/test_gen.rs:268:14
        |
    268 |     assert::<PhantomDataWrapper<X>>();
        |              ^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `X`
        |
    note: required for `PhantomDataWrapper<X>` to implement `for<'de> Deserialize<'de>`
       --> test_suite/tests/test_gen.rs:262:25
        |
    262 |     #[derive(Serialize, Deserialize)]
        |                         ^^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
    263 |     //#[serde(bound = "")]
    264 |     struct PhantomDataWrapper<T> {
        |            ^^^^^^^^^^^^^^^^^^^^^
        = note: required for `PhantomDataWrapper<X>` to implement `DeserializeOwned`
    note: required by a bound in `assert`
       --> test_suite/tests/test_gen.rs:767:26
        |
    767 | fn assert<T: Serialize + DeserializeOwned>() {}
        |                          ^^^^^^^^^^^^^^^^ required by this bound in `assert`
        = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
    help: consider annotating `X` with `#[derive(Default)]`
        |
    779 | #[derive(Default)]
        |
2023-03-08 19:11:25 -08:00
David Tolnay
ce86f351d6
Make a directory dedicated to regression tests
I have had a good experience with this pattern in many of my other
libraries.
2023-03-08 19:02:42 -08:00
David Tolnay
0b90f6c96a
Remove the need for allow(dead_code) added by PR 2383 2023-03-08 18:59:56 -08:00
David Tolnay
2198463218
Merge pull request #2392 from dtolnay/emptylifetimes
Eliminate special case on empty string passed to borrow=""
2023-03-08 18:55:51 -08:00
David Tolnay
be57a5e00a
Eliminate special case on empty string passed to borrow="" 2023-03-08 18:50:19 -08:00
David Tolnay
b1b09eba60
Add ui test with nonempty string containing no lifetimes 2023-03-08 18:49:59 -08:00
David Tolnay
eb1e8c140d
Merge pull request #2391 from dtolnay/parselifetimes
Simplify parsing of borrow="..." attributes
2023-03-08 18:44:57 -08:00
David Tolnay
43da87939d
Simplify parsing of borrow="..." attributes 2023-03-08 18:38:12 -08:00
David Tolnay
06d99a13a6
Merge pull request #2390 from dtolnay/litstrparse
Replace serde_derive_internal's parse_lit_str with syn::LitStr::parse
2023-03-08 18:30:18 -08:00
David Tolnay
49a911d7de
Replace serde_derive_internal's parse_lit_str with syn::LitStr::parse 2023-03-08 18:23:35 -08:00
David Tolnay
27d6628785
Refer to syn's parse result via syn instead of parse module 2023-03-08 18:20:30 -08:00
David Tolnay
e4e2956e79
Handle repr attribute consistently with every other serde attribute 2023-03-08 13:57:43 -08:00
David Tolnay
ea2f7b81d9
Sort symbol list in alphabetical order
PR 1916 put EXPECTING at the end instead of in order.
2023-03-08 13:14:45 -08:00
David Tolnay
f0dfdb5247
Resolve wildcard_imports pedantic clippy lint in test suite
error: usage of wildcard import
       --> test_suite/tests/test_gen.rs:901:9
        |
    901 |     use super::*;
        |         ^^^^^^^^ help: try: `super::Deserialize`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_imports
        = note: `-D clippy::wildcard-imports` implied by `-D clippy::pedantic`
2023-03-08 12:14:04 -08:00
David Tolnay
6a5da85fcd
Release 1.0.154 2023-03-08 12:09:05 -08:00
David Tolnay
0750eee4ff
Merge pull request #2383 from Mingun/fix-flatten+static
Fix generation of non-existent lifetime `'de` when enum contains a #[serde(flatten)] field and a `'static` reference
2023-03-08 12:05:41 -08:00
David Tolnay
ef551a517c
Merge pull request #2389 from dtolnay/trimstart
Replace use of deprecated trim_left_matches with trim_start_matches
2023-03-08 12:00:34 -08:00
David Tolnay
1c5ea24f76
Replace use of deprecated trim_left_matches with trim_start_matches 2023-03-08 11:54:44 -08:00
David Tolnay
88d73e5250
Format PR 2387 with rustfmt 2023-03-08 11:54:28 -08:00
David Tolnay
1ff2a972c6
Merge pull request #2388 from serde-rs/exhaustivepatterns
Update the comment on simpler exhaustive matching in derive
2023-03-08 11:53:45 -08:00
David Tolnay
bb72fe2726
Update the comment on simpler exhaustive matching in derive 2023-03-08 11:46:26 -08:00
David Tolnay
e50b14afee
Release 1.0.153 2023-03-07 10:50:02 -08:00
David Tolnay
cbd1cbef07
Merge pull request #2387 from bebecue/fix-1504
Make #[serde(alias)] works in #[serde(flatten)] context
2023-03-07 10:48:38 -08:00
bebecue
01da3f79c9 Add tests for #2387 2023-03-07 08:09:01 +08:00
bebecue
f5e0fbcb14 Make #[serde(alias)] works in #[serde(flatten)] context
fix #1504
2023-03-05 15:14:51 +08:00
Mingun
38c130a303 Do not generate DeserializeSeed impl when not needed
This function is called for untagged, internally and externally tagged enums,
but `deserializer` parameter is `None` only for the latest. Only when it's `None`
`DeserializeSeed` impl is used
2023-02-27 21:08:30 +05:00
Mingun
c7393614ff Fix generation of non-existent lifetime 'de when enum contains a #[serde(flatten)] field and a 'static reference 2023-02-27 21:03:34 +05:00