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