966 Commits

Author SHA1 Message Date
David Tolnay 5a44519a9a Raise required compiler for serde_derive to Rust 1.68 2025-10-19 15:02:17 -07:00
David Tolnay fae23fea97 Resolve manual_let_else pedantic clippy lint
warning: this could be rewritten as `let...else`
        --> serde_derive/src/internals/attr.rs:1460:5
         |
    1460 | /     let string = match get_lit_str(cx, attr_name, meta)? {
    1461 | |         Some(string) => string,
    1462 | |         None => return Ok(None),
    1463 | |     };
         | |______^ help: consider writing: `let Some(string) = get_lit_str(cx, attr_name, meta)? else { return Ok(None) };`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
         = note: `-W clippy::manual-let-else` implied by `-W clippy::pedantic`
         = help: to override `-W clippy::pedantic` add `#[allow(clippy::manual_let_else)]`

    warning: this could be rewritten as `let...else`
        --> serde_derive/src/internals/attr.rs:1482:5
         |
    1482 | /     let string = match get_lit_str(cx, attr_name, meta)? {
    1483 | |         Some(string) => string,
    1484 | |         None => return Ok(None),
    1485 | |     };
         | |______^ help: consider writing: `let Some(string) = get_lit_str(cx, attr_name, meta)? else { return Ok(None) };`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else

    warning: this could be rewritten as `let...else`
        --> serde_derive/src/internals/attr.rs:1505:5
         |
    1505 | /     let string = match get_lit_str2(cx, attr_name, meta_item_name, meta)? {
    1506 | |         Some(string) => string,
    1507 | |         None => return Ok(Vec::new()),
    1508 | |     };
         | |______^ help: consider writing: `let Some(string) = get_lit_str2(cx, attr_name, meta_item_name, meta)? else { return Ok(Vec::new()) };`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else

    warning: this could be rewritten as `let...else`
        --> serde_derive/src/internals/attr.rs:1526:5
         |
    1526 | /     let string = match get_lit_str(cx, attr_name, meta)? {
    1527 | |         Some(string) => string,
    1528 | |         None => return Ok(None),
    1529 | |     };
         | |______^ help: consider writing: `let Some(string) = get_lit_str(cx, attr_name, meta)? else { return Ok(None) };`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else

    warning: this could be rewritten as `let...else`
        --> serde_derive/src/internals/attr.rs:1549:5
         |
    1549 | /     let string = match get_lit_str(cx, BORROW, meta)? {
    1550 | |         Some(string) => string,
    1551 | |         None => return Ok(BTreeSet::new()),
    1552 | |     };
         | |______^ help: consider writing: `let Some(string) = get_lit_str(cx, BORROW, meta)? else { return Ok(BTreeSet::new()) };`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else

    warning: this could be rewritten as `let...else`
        --> serde_derive/src/internals/attr.rs:1621:5
         |
    1621 | /     let seg = match path.segments.last() {
    1622 | |         Some(seg) => seg,
    1623 | |         None => {
    1624 | |             return false;
    1625 | |         }
    1626 | |     };
         | |______^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
    help: consider writing
         |
    1621 ~     let Some(seg) = path.segments.last() else {
    1622 +             return false;
    1623 +         };
         |

    warning: this could be rewritten as `let...else`
        --> serde_derive/src/internals/attr.rs:1648:5
         |
    1648 | /     let seg = match path.segments.last() {
    1649 | |         Some(seg) => seg,
    1650 | |         None => {
    1651 | |             return false;
    1652 | |         }
    1653 | |     };
         | |______^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
    help: consider writing
         |
    1648 ~     let Some(seg) = path.segments.last() else {
    1649 +             return false;
    1650 +         };
         |

    warning: this could be rewritten as `let...else`
      --> serde_derive/src/internals/ctxt.rs:49:9
       |
    49 | /         let mut combined = match errors.next() {
    50 | |             Some(first) => first,
    51 | |             None => return Ok(()),
    52 | |         };
       | |__________^ help: consider writing: `let Some(mut combined) = errors.next() else { return Ok(()) };`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else

    warning: this could be rewritten as `let...else`
      --> serde_derive/src/de.rs:29:5
       |
    29 | /     let cont = match Container::from_ast(&ctxt, input, Derive::Deserialize, &private...
    30 | |         Some(cont) => cont,
    31 | |         None => return Err(ctxt.check().unwrap_err()),
    32 | |     };
       | |______^ help: consider writing: `let Some(cont) = Container::from_ast(&ctxt, input, Derive::Deserialize, &private.ident()) else { return Err(ctxt.check().unwrap_err()) };`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else

    warning: this could be rewritten as `let...else`
      --> serde_derive/src/ser.rs:16:5
       |
    16 | /     let cont = match Container::from_ast(&ctxt, input, Derive::Serialize, &private.i...
    17 | |         Some(cont) => cont,
    18 | |         None => return Err(ctxt.check().unwrap_err()),
    19 | |     };
       | |______^ help: consider writing: `let Some(cont) = Container::from_ast(&ctxt, input, Derive::Serialize, &private.ident()) else { return Err(ctxt.check().unwrap_err()) };`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else
2025-10-19 15:02:16 -07:00
David Tolnay d656b4dd6a Raise required compiler for serde_derive to Rust 1.65 2025-10-19 15:02:12 -07:00
Nik Revenco 086353c581 refactor: remove 1 level of nesting 2025-10-17 18:29:26 +01:00
Mingun 9f9a1ea35e Do not use ? operator in the generated code where possible
This may slightly improve compilation time and costs nothing
2025-09-28 23:21:26 +05:00
David Tolnay a866b336f1 Release 1.0.228 2025-09-27 09:51:07 -07:00
David Tolnay 415d9fc560 Release 1.0.227 2025-09-25 16:42:33 -07:00
David Tolnay 3a7c11c82c Rename enum_untagged::generate_newtype_variant -> deserialize_newtype_variant 2025-09-25 09:41:34 -07:00
David Tolnay 11ce4402bd Rename enum_untagged::generate_variant -> deserialize_variant 2025-09-25 09:41:34 -07:00
David Tolnay 8047570160 Rename generate_body_in_place -> deserialize_in_place 2025-09-25 09:41:34 -07:00
David Tolnay b395215875 Rename all other generate_body -> deserialize 2025-09-25 09:41:33 -07:00
David Tolnay a437ff6bf7 Rename identifier::generate_identifier -> deserialize_generated 2025-09-25 09:41:33 -07:00
David Tolnay 20fc31c78a Rename identifier::generate_body -> deserialize_custom 2025-09-25 09:41:33 -07:00
David Tolnay ad2b064b0a Adjust variable names 2025-09-25 09:41:33 -07:00
David Tolnay dec153b8fa Adjust comments 2025-09-25 09:41:33 -07:00
David Tolnay e219a0d4b7 Replace unnecessary use of generics_with_de_lifetime 2025-09-25 09:41:33 -07:00
David Tolnay c78f7d2e30 Rename Parameters::generics -> generics_with_de_lifetime 2025-09-25 09:41:33 -07:00
Mingun 027112eccb Visibility fix for Rust 1.61 2025-09-21 20:58:53 +05:00
Mingun 8c3445efe4 Group some functions that used together 2025-09-21 20:40:22 +05:00
Mingun 88b6a9abf4 Rename functions and run cargo fmt 2025-09-21 20:40:21 +05:00
Mingun fa298c9df4 Move generator for identifiers to its own module
Cut-paste
2025-09-21 20:40:21 +05:00
Mingun c4a07ed4e8 Move body generator for unit structs to its own module
Cut-paste
2025-09-21 20:40:21 +05:00
Mingun c4986f10b9 Move body generator for tuple structs to its own module
Cut-paste
2025-09-21 20:40:21 +05:00
Mingun 2d607de146 Move body generator for structs to its own module
Cut-paste
2025-09-21 20:40:21 +05:00
Mingun 19956e6b8e Move body generator for enums to its own module
Cut-paste
2025-09-21 20:40:20 +05:00
Mingun ec13eb4ed6 Move body generator for untagged enums to its own module
Cut-paste
2025-09-21 20:40:20 +05:00
Mingun ae00c4acb7 Move body generator for internally tagged enums to its own module
Cut-paste
2025-09-21 20:40:20 +05:00
Mingun 85d0b9ccd8 Move body generator for externally tagged enums to its own module
Cut-paste
2025-09-21 20:40:20 +05:00
Mingun e60f62a289 Move body generator for adjacently tagged enums to its own module
Cut-paste
2025-09-21 20:40:20 +05:00
Mingun e04f0ba2de StructForm::InternallyTagged always instantiated with the same deserializer, so remove that parameter 2025-09-21 20:40:20 +05:00
Mingun c8184be238 StructForm::Untagged always instantiated with the same deserializer, so remove that parameter 2025-09-21 20:40:19 +05:00
Mingun 896d91f0bb TupleForm::Untagged always instantiated with the same deserializer, so remove that parameter 2025-09-21 20:40:19 +05:00
Mingun 915686d0ec deserialize_untagged_newtype_variant always called with the same deserializer, so remove that parameter 2025-09-21 20:40:19 +05:00
Mingun 3a682c951b deserialize_untagged_variant always called with the same deserializer, so remove that parameter 2025-09-21 20:40:19 +05:00
Mingun ca79f61d0f deserialize_internally_tagged_variant always called with the same deserializer, so remove that parameter 2025-09-21 20:40:19 +05:00
Mingun ddb7c4b30f Convert split_with_de_lifetime to method of Parameters 2025-09-21 15:39:11 +05:00
Mingun 4855fb467f Move code for injecting tagged variants to untagged generator to the place where the decision was made 2025-09-21 15:39:11 +05:00
Mingun 6dffc0b1c8 Remove one-line intermediate function 2025-09-21 15:39:11 +05:00
Mingun 15be2a600a Remove confusing call to deserialize_untagged_variant in deserialize_internally_tagged_variant
deserialize_untagged_variant in that place is called when deserialzie_with attribute is set.
In that case it performs special actions that is better to use explicitly in deserialize_untagged_variant
for readability
2025-09-21 15:39:11 +05:00
David Tolnay 1799547846 Release 1.0.226 2025-09-20 16:34:44 -07:00
David Tolnay 2dbeefb11b Merge pull request #2935 from Mingun/dedupe-adj-enums
Remove code duplication when deriving Deserialize for adjacently tagged enums
2025-09-20 16:33:32 -07:00
David Tolnay ee3c2372fb Opt in to generate-macro-expansion when building on docs.rs 2025-09-16 16:29:21 -07:00
Mingun bfb020d975 Use variant name for field instead of field 2025-09-17 00:09:51 +05:00
Mingun 6805bba308 Inline variables that used only once 2025-09-17 00:09:14 +05:00
Mingun 2659b94a62 Create deserializer only when needed 2025-09-17 00:08:07 +05:00
Mingun c451415d9f Do not duplicate variant deserialization code 2025-09-17 00:07:00 +05:00
Mingun 553a9ff15f Document functions that are entry points for generating bodies of different deserialization forms 2025-09-17 00:05:53 +05:00
David Tolnay 1d7899d671 Release 1.0.225 2025-09-15 20:43:08 -07:00
David Tolnay 97168d3a24 Touch up PR 2879 2025-09-15 20:38:57 -07:00
David Tolnay 373b11dda7 Merge pull request 2879 from rcrisanti/fix/silence-deprecation-warnings-derive 2025-09-15 20:26:40 -07:00