Compare commits

...

15 Commits

Author SHA1 Message Date
David Tolnay d17902059e Merge pull request #3019 from xibeiyoumian/master
chore: improve code comments clarity
2025-12-22 03:29:10 -08:00
xibeiyoumian a27948e209 chore: improve code comments clarity
Signed-off-by: xibeiyoumian <xibeiyoumian@outlook.com>
2025-12-22 14:38:55 +08:00
David Tolnay 576e2ef9d8 Update actions/upload-artifact@v5 -> v6 2025-12-19 21:10:59 -08:00
David Tolnay dd0eb0f2ca Update actions/upload-artifact@v4 -> v5 2025-12-18 18:58:13 -08:00
David Tolnay f7fc3e0d67 Update actions/checkout@v5 -> v6 2025-11-20 10:19:51 -08:00
David Tolnay 1c396d223b Update actions/checkout@v4 -> v5 2025-11-20 10:19:04 -08:00
David Tolnay e42684f9a7 Update ui test suite to nightly-2025-11-02 2025-11-01 22:38:40 -07:00
David Tolnay 56c29b3c5d Update name of empty_enum clippy lint
warning: lint `clippy::empty_enum` has been renamed to `clippy::empty_enums`
       --> serde/src/lib.rs:122:5
        |
    122 |     clippy::empty_enum,
        |     ^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::empty_enums`
        |
        = note: `#[warn(renamed_and_removed_lints)]` on by default

    warning: lint `clippy::empty_enum` has been renamed to `clippy::empty_enums`
      --> serde_core/src/lib.rs:57:5
       |
    57 |     clippy::empty_enum,
       |     ^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::empty_enums`
       |
       = note: `#[warn(renamed_and_removed_lints)]` on by default

    warning: lint `clippy::empty_enum` has been renamed to `clippy::empty_enums`
     --> test_suite/tests/test_de.rs:5:5
      |
    5 |     clippy::empty_enum,
      |     ^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::empty_enums`
      |
      = note: `#[warn(renamed_and_removed_lints)]` on by default

    warning: lint `clippy::empty_enum` has been renamed to `clippy::empty_enums`
     --> test_suite/tests/test_de_error.rs:3:5
      |
    3 |     clippy::empty_enum,
      |     ^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::empty_enums`
      |
      = note: `#[warn(renamed_and_removed_lints)]` on by default
2025-11-01 22:37:05 -07:00
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
David Tolnay b517ec9fd7 Merge pull request #3001 from nik-contrib/refactor
refactor: remove 1 level of nesting
2025-10-17 10:35:18 -07:00
Nik Revenco 086353c581 refactor: remove 1 level of nesting 2025-10-17 18:29:26 +01:00
David Tolnay 4e278703c6 Merge pull request #2936 from Mingun/remove-fixme
Remove some ? from generated code
2025-09-28 11:34:47 -07: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
19 changed files with 93 additions and 86 deletions
+14 -14
View File
@@ -18,10 +18,10 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@nightly
- run: cd test_suite && cargo test --features unstable
- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v6
if: always()
with:
name: Cargo.lock
@@ -33,7 +33,7 @@ jobs:
runs-on: windows-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@nightly
- run: cd test_suite && cargo test --features unstable -- --skip ui --exact
@@ -46,7 +46,7 @@ jobs:
rust: [stable, beta]
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust}}
@@ -63,7 +63,7 @@ jobs:
os: [ubuntu, windows]
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@nightly
- run: cd serde && cargo build
- run: cd serde && cargo build --no-default-features
@@ -87,7 +87,7 @@ jobs:
rust: [1.56.0, 1.60.0]
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust}}
@@ -98,12 +98,12 @@ jobs:
- run: cd serde && cargo build
derive:
name: Rust 1.61.0
name: Rust 1.68.0
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.61.0
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@1.68.0
- run: |
sed -i 's/proc-macro2 = { workspace = true/proc-macro2 = { version = "1"/' serde_derive*/Cargo.toml
sed -i 's/quote = { workspace = true/quote = { version = "1"/' serde_derive*/Cargo.toml
@@ -117,7 +117,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@nightly
- run: cargo generate-lockfile -Z minimal-versions
- run: cargo check --locked --workspace
@@ -129,7 +129,7 @@ jobs:
env:
RUSTDOCFLAGS: -Dwarnings
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@nightly
- uses: dtolnay/install@cargo-docs-rs
- run: cargo docs-rs -p serde
@@ -143,7 +143,7 @@ jobs:
if: github.event_name != 'pull_request'
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@clippy
- run: cd serde && cargo clippy --features rc,unstable -- -Dclippy::all -Dclippy::pedantic
- run: cd serde_core && cargo clippy --features rc,unstable -- -Dclippy::all -Dclippy::pedantic
@@ -157,7 +157,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@miri
with:
toolchain: nightly-2025-05-16 # https://github.com/rust-lang/miri/issues/4323
@@ -175,7 +175,7 @@ jobs:
if: github.event_name != 'pull_request'
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/install@cargo-outdated
- run: cargo outdated --workspace --exit-code 1
+3 -3
View File
@@ -1,4 +1,4 @@
# Serde &emsp; [![Build Status]][actions] [![Latest Version]][crates.io] [![serde msrv]][Rust 1.56] [![serde_derive msrv]][Rust 1.61]
# Serde &emsp; [![Build Status]][actions] [![Latest Version]][crates.io] [![serde msrv]][Rust 1.56] [![serde_derive msrv]][Rust 1.68]
[Build Status]: https://img.shields.io/github/actions/workflow/status/serde-rs/serde/ci.yml?branch=master
[actions]: https://github.com/serde-rs/serde/actions?query=branch%3Amaster
@@ -6,8 +6,8 @@
[crates.io]: https://crates.io/crates/serde
[serde msrv]: https://img.shields.io/crates/msrv/serde.svg?label=serde%20msrv&color=lightgray
[serde_derive msrv]: https://img.shields.io/crates/msrv/serde_derive.svg?label=serde_derive%20msrv&color=lightgray
[Rust 1.56]: https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html
[Rust 1.61]: https://blog.rust-lang.org/2022/05/19/Rust-1.61.0.html
[Rust 1.56]: https://blog.rust-lang.org/2021/10/21/Rust-1.56.0/
[Rust 1.68]: https://blog.rust-lang.org/2023/03/09/Rust-1.68.0/
**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
+2 -2
View File
@@ -45,8 +45,8 @@ fn main() {
println!("cargo:rustc-check-cfg=cfg(no_target_has_atomic)");
}
// Current minimum supported version of serde_derive crate is Rust 1.61.
if minor < 61 {
// Current minimum supported version of serde_derive crate is Rust 1.68.
if minor < 68 {
println!("cargo:rustc-cfg=no_serde_derive");
}
+1 -1
View File
@@ -119,7 +119,7 @@
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/7768
clippy::semicolon_if_nothing_returned,
// not available in our oldest supported compiler
clippy::empty_enum,
clippy::empty_enums,
clippy::type_repetition_in_bounds, // https://github.com/rust-lang/rust-clippy/issues/8772
// integer and float ser/de requires these sorts of casts
clippy::cast_possible_truncation,
+5 -5
View File
@@ -65,17 +65,17 @@ fn main() {
}
}
// Current minimum supported version of serde_derive crate is Rust 1.61.
if minor < 61 {
println!("cargo:rustc-cfg=no_serde_derive");
}
// Support for core::ffi::CStr and alloc::ffi::CString stabilized in Rust 1.64.
// https://blog.rust-lang.org/2022/09/22/Rust-1.64.0.html#c-compatible-ffi-types-in-core-and-alloc
if minor < 64 {
println!("cargo:rustc-cfg=no_core_cstr");
}
// Current minimum supported version of serde_derive crate is Rust 1.68.
if minor < 68 {
println!("cargo:rustc-cfg=no_serde_derive");
}
// Support for core::num::Saturating and std::num::Saturating stabilized in Rust 1.74
// https://blog.rust-lang.org/2023/11/16/Rust-1.74.0.html#stabilized-apis
if minor < 74 {
+1 -1
View File
@@ -54,7 +54,7 @@
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/7768
clippy::semicolon_if_nothing_returned,
// not available in our oldest supported compiler
clippy::empty_enum,
clippy::empty_enums,
clippy::type_repetition_in_bounds, // https://github.com/rust-lang/rust-clippy/issues/8772
// integer and float ser/de requires these sorts of casts
clippy::cast_possible_truncation,
+1 -1
View File
@@ -12,7 +12,7 @@ keywords = ["serde", "serialization", "no_std", "derive"]
license = "MIT OR Apache-2.0"
readme = "crates-io.md"
repository = "https://github.com/serde-rs/serde"
rust-version = "1.61"
rust-version = "1.68"
[features]
default = []
+9 -6
View File
@@ -26,9 +26,9 @@ pub fn expand_derive_deserialize(input: &mut syn::DeriveInput) -> syn::Result<To
replace_receiver(input);
let ctxt = Ctxt::new();
let cont = match Container::from_ast(&ctxt, input, Derive::Deserialize, &private.ident()) {
Some(cont) => cont,
None => return Err(ctxt.check().unwrap_err()),
let Some(cont) = Container::from_ast(&ctxt, input, Derive::Deserialize, &private.ident())
else {
return Err(ctxt.check().unwrap_err());
};
precondition(&ctxt, &cont);
ctxt.check()?;
@@ -594,13 +594,16 @@ fn deserialize_seq_in_place(
let (wrapper, wrapper_ty) = wrap_deserialize_field_with(params, field.ty, path);
quote!({
#wrapper
match _serde::de::SeqAccess::next_element::<#wrapper_ty>(&mut __seq)? {
_serde::#private::Some(__wrap) => {
match _serde::de::SeqAccess::next_element::<#wrapper_ty>(&mut __seq) {
_serde::#private::Ok(_serde::#private::Some(__wrap)) => {
self.place.#member = __wrap.value;
}
_serde::#private::None => {
_serde::#private::Ok(_serde::#private::None) => {
#value_if_none;
}
_serde::#private::Err(__err) => {
return _serde::#private::Err(__err);
}
}
})
}
+8 -6
View File
@@ -282,8 +282,8 @@ pub(super) fn deserialize(
__A: _serde::de::SeqAccess<#delife>,
{
// Visit the first element - the tag.
match _serde::de::SeqAccess::next_element(&mut __seq)? {
_serde::#private::Some(__variant) => {
match _serde::de::SeqAccess::next_element(&mut __seq) {
_serde::#private::Ok(_serde::#private::Some(__variant)) => {
// Visit the second element - the content.
match _serde::de::SeqAccess::next_element_seed(
&mut __seq,
@@ -292,18 +292,20 @@ pub(super) fn deserialize(
marker: _serde::#private::PhantomData,
lifetime: _serde::#private::PhantomData,
},
)? {
_serde::#private::Some(__ret) => _serde::#private::Ok(__ret),
) {
_serde::#private::Ok(_serde::#private::Some(__ret)) => _serde::#private::Ok(__ret),
// There is no second element.
_serde::#private::None => {
_serde::#private::Ok(_serde::#private::None) => {
_serde::#private::Err(_serde::de::Error::invalid_length(1, &self))
}
_serde::#private::Err(__err) => _serde::#private::Err(__err),
}
}
// There is no first element.
_serde::#private::None => {
_serde::#private::Ok(_serde::#private::None) => {
_serde::#private::Err(_serde::de::Error::invalid_length(0, &self))
}
_serde::#private::Err(__err) => _serde::#private::Err(__err),
}
}
}
+3 -2
View File
@@ -49,7 +49,7 @@ pub(super) fn deserialize(
));
quote! {
(__Field::#variant_name, __variant) => #block
_serde::#private::Ok((__Field::#variant_name, __variant)) => #block
}
});
@@ -69,8 +69,9 @@ pub(super) fn deserialize(
}
} else {
quote! {
match _serde::de::EnumAccess::variant(__data)? {
match _serde::de::EnumAccess::variant(__data) {
#(#variant_arms)*
_serde::#private::Err(__err) => _serde::#private::Err(__err),
}
}
};
+17 -30
View File
@@ -1185,13 +1185,11 @@ impl Field {
}
}
// Is skip_deserializing, initialize the field to Default::default() unless a
// If skip_deserializing, initialize the field to Default::default() unless a
// different default is specified by `#[serde(default = "...")]` on
// ourselves or our container (e.g. the struct we are in).
if let Default::None = *container_default {
if skip_deserializing.0.value.is_some() {
default.set_if_none(Default::Default);
}
if container_default.is_none() && skip_deserializing.0.value.is_some() {
default.set_if_none(Default::Default);
}
let mut borrowed_lifetimes = borrowed_lifetimes.get().unwrap_or_default();
@@ -1459,9 +1457,8 @@ fn parse_lit_into_path(
attr_name: Symbol,
meta: &ParseNestedMeta,
) -> syn::Result<Option<syn::Path>> {
let string = match get_lit_str(cx, attr_name, meta)? {
Some(string) => string,
None => return Ok(None),
let Some(string) = get_lit_str(cx, attr_name, meta)? else {
return Ok(None);
};
Ok(match string.parse() {
@@ -1481,9 +1478,8 @@ fn parse_lit_into_expr_path(
attr_name: Symbol,
meta: &ParseNestedMeta,
) -> syn::Result<Option<syn::ExprPath>> {
let string = match get_lit_str(cx, attr_name, meta)? {
Some(string) => string,
None => return Ok(None),
let Some(string) = get_lit_str(cx, attr_name, meta)? else {
return Ok(None);
};
Ok(match string.parse() {
@@ -1504,9 +1500,8 @@ fn parse_lit_into_where(
meta_item_name: Symbol,
meta: &ParseNestedMeta,
) -> syn::Result<Vec<syn::WherePredicate>> {
let string = match get_lit_str2(cx, attr_name, meta_item_name, meta)? {
Some(string) => string,
None => return Ok(Vec::new()),
let Some(string) = get_lit_str2(cx, attr_name, meta_item_name, meta)? else {
return Ok(Vec::new());
};
Ok(
@@ -1525,9 +1520,8 @@ fn parse_lit_into_ty(
attr_name: Symbol,
meta: &ParseNestedMeta,
) -> syn::Result<Option<syn::Type>> {
let string = match get_lit_str(cx, attr_name, meta)? {
Some(string) => string,
None => return Ok(None),
let Some(string) = get_lit_str(cx, attr_name, meta)? else {
return Ok(None);
};
Ok(match string.parse() {
@@ -1548,9 +1542,8 @@ fn parse_lit_into_lifetimes(
cx: &Ctxt,
meta: &ParseNestedMeta,
) -> syn::Result<BTreeSet<syn::Lifetime>> {
let string = match get_lit_str(cx, BORROW, meta)? {
Some(string) => string,
None => return Ok(BTreeSet::new()),
let Some(string) = get_lit_str(cx, BORROW, meta)? else {
return Ok(BTreeSet::new());
};
if let Ok(lifetimes) = string.parse_with(|input: ParseStream| {
@@ -1620,11 +1613,8 @@ fn is_cow(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
return false;
}
};
let seg = match path.segments.last() {
Some(seg) => seg,
None => {
return false;
}
let Some(seg) = path.segments.last() else {
return false;
};
let args = match &seg.arguments {
syn::PathArguments::AngleBracketed(bracketed) => &bracketed.args,
@@ -1647,11 +1637,8 @@ fn is_option(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
return false;
}
};
let seg = match path.segments.last() {
Some(seg) => seg,
None => {
return false;
}
let Some(seg) = path.segments.last() else {
return false;
};
let args = match &seg.arguments {
syn::PathArguments::AngleBracketed(bracketed) => &bracketed.args,
+2 -3
View File
@@ -46,9 +46,8 @@ impl Ctxt {
pub fn check(self) -> syn::Result<()> {
let mut errors = self.errors.borrow_mut().take().unwrap().into_iter();
let mut combined = match errors.next() {
Some(first) => first,
None => return Ok(()),
let Some(mut combined) = errors.next() else {
return Ok(());
};
for rest in errors {
+2 -3
View File
@@ -13,9 +13,8 @@ pub fn expand_derive_serialize(input: &mut syn::DeriveInput) -> syn::Result<Toke
replace_receiver(input);
let ctxt = Ctxt::new();
let cont = match Container::from_ast(&ctxt, input, Derive::Serialize, &private.ident()) {
Some(cont) => cont,
None => return Err(ctxt.check().unwrap_err()),
let Some(cont) = Container::from_ast(&ctxt, input, Derive::Serialize, &private.ident()) else {
return Err(ctxt.check().unwrap_err());
};
precondition(&ctxt, &cont);
ctxt.check()?;
+1 -1
View File
@@ -10,7 +10,7 @@ homepage = "https://serde.rs"
keywords = ["serde", "serialization"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/serde-rs/serde"
rust-version = "1.61"
rust-version = "1.68"
[lib]
path = "lib.rs"
+1 -1
View File
@@ -2,7 +2,7 @@
clippy::cast_lossless,
clippy::decimal_literal_representation,
clippy::derive_partial_eq_without_eq,
clippy::empty_enum,
clippy::empty_enums,
clippy::manual_assert,
clippy::needless_pass_by_value,
clippy::uninlined_format_args,
+1 -1
View File
@@ -1,6 +1,6 @@
#![allow(
clippy::derive_partial_eq_without_eq,
clippy::empty_enum,
clippy::empty_enums,
clippy::unreadable_literal
)]
#![cfg_attr(feature = "unstable", feature(never_type))]
@@ -11,7 +11,7 @@ struct T0(u8, u8);
struct T1(u8, #[serde(default)] u8);
// ERROR: The first field can get default value only if sequence is empty, but
// that mean that all other fields cannot be deserialized without errors.
// that means that all other fields cannot be deserialized without errors.
#[derive(Deserialize)]
struct T2(#[serde(default)] u8, u8, u8);
@@ -11,7 +11,7 @@ fn d<T>() -> T {
struct T1(u8, #[serde(default = "d")] u8);
// ERROR: The first field can get default value only if sequence is empty, but
// that mean that all other fields cannot be deserialized without errors.
// that means that all other fields cannot be deserialized without errors.
#[derive(Deserialize)]
struct T2(#[serde(default = "d")] u8, u8, u8);
+20 -4
View File
@@ -6,7 +6,11 @@ error[E0277]: the trait bound `&u8: serde::Serializer` is not satisfied
15 | struct W(#[serde(with = "w")] u8, u8);
| --- required by a bound introduced by this call
|
= help: the trait `Serializer` is implemented for `&mut Formatter<'a>`
help: the trait `Serializer` is implemented for `&mut Formatter<'a>`
--> $WORKSPACE/serde_core/src/ser/fmt.rs
|
| impl<'a> Serializer for &mut fmt::Formatter<'a> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `w::serialize`
--> tests/ui/with/incorrect_type.rs:9:28
|
@@ -33,7 +37,11 @@ error[E0277]: the trait bound `&u8: serde::Serializer` is not satisfied
15 | struct W(#[serde(with = "w")] u8, u8);
| ^^^ the trait `Serializer` is not implemented for `&u8`
|
= help: the trait `Serializer` is implemented for `&mut Formatter<'a>`
help: the trait `Serializer` is implemented for `&mut Formatter<'a>`
--> $WORKSPACE/serde_core/src/ser/fmt.rs
|
| impl<'a> Serializer for &mut fmt::Formatter<'a> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: `?` operator has incompatible types
--> tests/ui/with/incorrect_type.rs:15:25
@@ -51,7 +59,11 @@ error[E0277]: the trait bound `&u8: serde::Serializer` is not satisfied
18 | struct S(#[serde(serialize_with = "w::serialize")] u8, u8);
| -------------- required by a bound introduced by this call
|
= help: the trait `Serializer` is implemented for `&mut Formatter<'a>`
help: the trait `Serializer` is implemented for `&mut Formatter<'a>`
--> $WORKSPACE/serde_core/src/ser/fmt.rs
|
| impl<'a> Serializer for &mut fmt::Formatter<'a> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `w::serialize`
--> tests/ui/with/incorrect_type.rs:9:28
|
@@ -78,7 +90,11 @@ error[E0277]: the trait bound `&u8: serde::Serializer` is not satisfied
18 | struct S(#[serde(serialize_with = "w::serialize")] u8, u8);
| ^^^^^^^^^^^^^^ the trait `Serializer` is not implemented for `&u8`
|
= help: the trait `Serializer` is implemented for `&mut Formatter<'a>`
help: the trait `Serializer` is implemented for `&mut Formatter<'a>`
--> $WORKSPACE/serde_core/src/ser/fmt.rs
|
| impl<'a> Serializer for &mut fmt::Formatter<'a> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: `?` operator has incompatible types
--> tests/ui/with/incorrect_type.rs:21:37