Compare commits

...

8 Commits

Author SHA1 Message Date
David Tolnay 930401b0dd Release 1.0.217 2024-12-27 12:41:22 -08:00
Mingun cb6eaea151 Fix roundtrip inconsistency:
- deserialization of flatten unit variant is possible
- serialization of such variant gives Err("can only flatten structs and maps (got an enum)")
2024-12-27 08:21:07 +00:00
David Tolnay b6f339ca36 Resolve repr_packed_without_abi clippy lint in tests
warning: item uses `packed` representation without ABI-qualification
       --> test_suite/tests/test_gen.rs:774:5
        |
    772 |       #[repr(packed)]
        |              ------ `packed` representation set here
    773 |       #[allow(dead_code)]
    774 | /     struct Packed {
    775 | |         x: u8,
    776 | |         y: u16,
    777 | |     }
        | |_____^
        |
        = warning: unqualified `#[repr(packed)]` defaults to `#[repr(Rust, packed)]`, which has no stable ABI
        = help: qualify the desired ABI explicity via `#[repr(C, packed)]` or `#[repr(Rust, packed)]`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#repr_packed_without_abi
    note: the lint level is defined here
       --> test_suite/tests/test_gen.rs:5:9
        |
    5   | #![deny(warnings)]
        |         ^^^^^^^^
        = note: `#[warn(clippy::repr_packed_without_abi)]` implied by `#[warn(warnings)]`

    warning: item uses `packed` representation without ABI-qualification
       --> test_suite/tests/test_gen.rs:919:1
        |
    918 |   #[repr(packed)]
        |          ------ `packed` representation set here
    919 | / pub struct RemotePacked {
    920 | |     pub a: u16,
    921 | |     pub b: u32,
    922 | | }
        | |_^
        |
        = warning: unqualified `#[repr(packed)]` defaults to `#[repr(Rust, packed)]`, which has no stable ABI
        = help: qualify the desired ABI explicity via `#[repr(C, packed)]` or `#[repr(Rust, packed)]`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#repr_packed_without_abi

    warning: item uses `packed` representation without ABI-qualification
       --> test_suite/tests/test_gen.rs:927:1
        |
    925 |   #[repr(packed)]
        |          ------ `packed` representation set here
    926 |   #[serde(remote = "RemotePacked")]
    927 | / pub struct RemotePackedDef {
    928 | |     a: u16,
    929 | |     b: u32,
    930 | | }
        | |_^
        |
        = warning: unqualified `#[repr(packed)]` defaults to `#[repr(Rust, packed)]`, which has no stable ABI
        = help: qualify the desired ABI explicity via `#[repr(C, packed)]` or `#[repr(Rust, packed)]`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#repr_packed_without_abi

    warning: item uses `packed` representation without ABI-qualification
       --> test_suite/tests/test_gen.rs:937:1
        |
    936 |   #[repr(packed)]
        |          ------ `packed` representation set here
    937 | / pub struct RemotePackedNonCopy {
    938 | |     pub a: u16,
    939 | |     pub b: String,
    940 | | }
        | |_^
        |
        = warning: unqualified `#[repr(packed)]` defaults to `#[repr(Rust, packed)]`, which has no stable ABI
        = help: qualify the desired ABI explicity via `#[repr(C, packed)]` or `#[repr(Rust, packed)]`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#repr_packed_without_abi

    warning: item uses `packed` representation without ABI-qualification
       --> test_suite/tests/test_gen.rs:945:1
        |
    943 |   #[repr(packed)]
        |          ------ `packed` representation set here
    944 |   #[serde(remote = "RemotePackedNonCopy")]
    945 | / pub struct RemotePackedNonCopyDef {
    946 | |     a: u16,
    947 | |     b: String,
    948 | | }
        | |_^
        |
        = warning: unqualified `#[repr(packed)]` defaults to `#[repr(Rust, packed)]`, which has no stable ABI
        = help: qualify the desired ABI explicity via `#[repr(C, packed)]` or `#[repr(Rust, packed)]`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#repr_packed_without_abi
2024-12-26 18:33:33 -08:00
David Tolnay 2a5caea1a8 Merge pull request #2872 from dtolnay/ehpersonality
Drop #[lang = "eh_personality"] from no-std test
2024-12-20 04:33:24 -08:00
David Tolnay b9f93f99aa Add no-std CI on stable compiler 2024-12-20 04:30:14 -08:00
David Tolnay eb5cd476ba Drop #[lang = "eh_personality"] from no-std test 2024-12-20 04:28:35 -08:00
David Tolnay 8478a3b7dd Merge pull request #2871 from dtolnay/nostdstart
Replace #[start] with extern fn main
2024-12-20 04:28:27 -08:00
David Tolnay dbb909136e Replace #[start] with extern fn main 2024-12-20 04:20:26 -08:00
10 changed files with 61 additions and 20 deletions
+1
View File
@@ -52,6 +52,7 @@ jobs:
toolchain: ${{matrix.rust}} toolchain: ${{matrix.rust}}
- run: cd serde && cargo build --features rc - run: cd serde && cargo build --features rc
- run: cd serde && cargo build --no-default-features - run: cd serde && cargo build --no-default-features
- run: cd test_suite/no_std && cargo build
nightly: nightly:
name: Rust nightly ${{matrix.os == 'windows' && '(windows)' || ''}} name: Rust nightly ${{matrix.os == 'windows' && '(windows)' || ''}}
+2 -2
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "serde" name = "serde"
version = "1.0.216" version = "1.0.217"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"] authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
build = "build.rs" build = "build.rs"
categories = ["encoding", "no-std", "no-std::no-alloc"] categories = ["encoding", "no-std", "no-std::no-alloc"]
@@ -37,7 +37,7 @@ rustdoc-args = ["--generate-link-to-definition"]
# is compatible with exactly one serde release because the generated code # is compatible with exactly one serde release because the generated code
# involves nonpublic APIs which are not bound by semver. # involves nonpublic APIs which are not bound by semver.
[target.'cfg(any())'.dependencies] [target.'cfg(any())'.dependencies]
serde_derive = { version = "=1.0.216", path = "../serde_derive" } serde_derive = { version = "=1.0.217", path = "../serde_derive" }
### FEATURES ################################################################# ### FEATURES #################################################################
+1 -1
View File
@@ -95,7 +95,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Serde types in rustdoc of other crates get linked to here. // Serde types in rustdoc of other crates get linked to here.
#![doc(html_root_url = "https://docs.rs/serde/1.0.216")] #![doc(html_root_url = "https://docs.rs/serde/1.0.217")]
// Support using Serde without the standard library! // Support using Serde without the standard library!
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
// Show which crate feature enables conditionally compiled APIs in documentation. // Show which crate feature enables conditionally compiled APIs in documentation.
+4 -2
View File
@@ -54,6 +54,7 @@ enum Unsupported {
Sequence, Sequence,
Tuple, Tuple,
TupleStruct, TupleStruct,
#[cfg(not(any(feature = "std", feature = "alloc")))]
Enum, Enum,
} }
@@ -70,6 +71,7 @@ impl Display for Unsupported {
Unsupported::Sequence => formatter.write_str("a sequence"), Unsupported::Sequence => formatter.write_str("a sequence"),
Unsupported::Tuple => formatter.write_str("a tuple"), Unsupported::Tuple => formatter.write_str("a tuple"),
Unsupported::TupleStruct => formatter.write_str("a tuple struct"), Unsupported::TupleStruct => formatter.write_str("a tuple struct"),
#[cfg(not(any(feature = "std", feature = "alloc")))]
Unsupported::Enum => formatter.write_str("an enum"), Unsupported::Enum => formatter.write_str("an enum"),
} }
} }
@@ -1095,9 +1097,9 @@ where
self, self,
_: &'static str, _: &'static str,
_: u32, _: u32,
_: &'static str, variant: &'static str,
) -> Result<Self::Ok, Self::Error> { ) -> Result<Self::Ok, Self::Error> {
Err(Self::bad_type(Unsupported::Enum)) self.0.serialize_entry(variant, &())
} }
fn serialize_newtype_struct<T>( fn serialize_newtype_struct<T>(
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "serde_derive" name = "serde_derive"
version = "1.0.216" version = "1.0.217"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"] authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
categories = ["no-std", "no-std::no-alloc"] categories = ["no-std", "no-std::no-alloc"]
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]" description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
+1 -1
View File
@@ -13,7 +13,7 @@
//! //!
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html //! [https://serde.rs/derive.html]: https://serde.rs/derive.html
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.216")] #![doc(html_root_url = "https://docs.rs/serde_derive/1.0.217")]
#![cfg_attr(not(check_cfg), allow(unexpected_cfgs))] #![cfg_attr(not(check_cfg), allow(unexpected_cfgs))]
// Ignored clippy lints // Ignored clippy lints
#![allow( #![allow(
+6
View File
@@ -10,4 +10,10 @@ libc = { version = "0.2", default-features = false }
serde = { path = "../../serde", default-features = false } serde = { path = "../../serde", default-features = false }
serde_derive = { path = "../../serde_derive" } serde_derive = { path = "../../serde_derive" }
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
[workspace] [workspace]
+5 -8
View File
@@ -1,16 +1,13 @@
#![allow(internal_features)]
#![feature(lang_items, start)]
#![no_std] #![no_std]
#![no_main]
#[start] use core::ffi::c_int;
fn start(_argc: isize, _argv: *const *const u8) -> isize {
#[no_mangle]
extern "C" fn main(_argc: c_int, _argv: *const *const u8) -> c_int {
0 0
} }
#[lang = "eh_personality"]
#[no_mangle]
pub extern "C" fn rust_eh_personality() {}
#[panic_handler] #[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! { fn panic(_info: &core::panic::PanicInfo) -> ! {
unsafe { unsafe {
+35
View File
@@ -2655,11 +2655,46 @@ mod flatten {
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
enum Enum { enum Enum {
Unit,
Newtype(HashMap<String, String>), Newtype(HashMap<String, String>),
Tuple(u32, u32), Tuple(u32, u32),
Struct { index: u32, value: u32 }, Struct { index: u32, value: u32 },
} }
#[test]
fn unit() {
let value = Flatten {
data: Enum::Unit,
extra: HashMap::from_iter([("extra_key".into(), "extra value".into())]),
};
assert_tokens(
&value,
&[
Token::Map { len: None },
// data
Token::Str("Unit"), // variant
Token::Unit,
// extra
Token::Str("extra_key"),
Token::Str("extra value"),
Token::MapEnd,
],
);
assert_de_tokens(
&value,
&[
Token::Map { len: None },
// extra
Token::Str("extra_key"),
Token::Str("extra value"),
// data
Token::Str("Unit"), // variant
Token::Unit,
Token::MapEnd,
],
);
}
#[test] #[test]
fn newtype() { fn newtype() {
assert_tokens( assert_tokens(
+5 -5
View File
@@ -769,7 +769,7 @@ fn test_gen() {
} }
#[derive(Serialize)] #[derive(Serialize)]
#[repr(packed)] #[repr(C, packed)]
#[allow(dead_code)] #[allow(dead_code)]
struct Packed { struct Packed {
x: u8, x: u8,
@@ -915,14 +915,14 @@ where
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
#[repr(packed)] #[repr(C, packed)]
pub struct RemotePacked { pub struct RemotePacked {
pub a: u16, pub a: u16,
pub b: u32, pub b: u32,
} }
#[derive(Serialize)] #[derive(Serialize)]
#[repr(packed)] #[repr(C, packed)]
#[serde(remote = "RemotePacked")] #[serde(remote = "RemotePacked")]
pub struct RemotePackedDef { pub struct RemotePackedDef {
a: u16, a: u16,
@@ -933,14 +933,14 @@ impl Drop for RemotePackedDef {
fn drop(&mut self) {} fn drop(&mut self) {}
} }
#[repr(packed)] #[repr(C, packed)]
pub struct RemotePackedNonCopy { pub struct RemotePackedNonCopy {
pub a: u16, pub a: u16,
pub b: String, pub b: String,
} }
#[derive(Deserialize)] #[derive(Deserialize)]
#[repr(packed)] #[repr(C, packed)]
#[serde(remote = "RemotePackedNonCopy")] #[serde(remote = "RemotePackedNonCopy")]
pub struct RemotePackedNonCopyDef { pub struct RemotePackedNonCopyDef {
a: u16, a: u16,