mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-18 21:21:01 +00:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 17c3c0cf86 | |||
| 210e6c354e | |||
| 41823a96df | |||
| 7ca13ff240 | |||
| 52391fd868 | |||
| 9b2d8dfc6b | |||
| 07ba7ea8dd | |||
| 9f29f6bb4a | |||
| f6c104fd1d | |||
| 8a3a6fb101 | |||
| b5c3b5e8e5 | |||
| 996d171461 | |||
| e1c4517335 | |||
| 6e94a27c76 | |||
| b23a768414 | |||
| 7e19ae8c94 | |||
| 404a1d142a | |||
| 02bd79a0ba | |||
| c3ce2c934a | |||
| 0d71ac84b5 | |||
| 82c3eb7ba4 |
+28
-11
@@ -13,7 +13,7 @@ jobs:
|
|||||||
name: Test suite
|
name: Test suite
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- 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
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ jobs:
|
|||||||
name: Test suite (windows)
|
name: Test suite (windows)
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- 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
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
rust: [stable, beta]
|
rust: [stable, beta]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: dtolnay/rust-toolchain@master
|
- uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
toolchain: ${{matrix.rust}}
|
toolchain: ${{matrix.rust}}
|
||||||
@@ -50,7 +50,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu, windows]
|
os: [ubuntu, windows]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- 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
|
||||||
@@ -59,12 +59,16 @@ jobs:
|
|||||||
- run: cd serde && cargo test --features derive,rc,unstable
|
- run: cd serde && cargo test --features derive,rc,unstable
|
||||||
- run: cd test_suite/no_std && cargo build
|
- run: cd test_suite/no_std && cargo build
|
||||||
if: matrix.os != 'windows'
|
if: matrix.os != 'windows'
|
||||||
|
- run: cd serde_derive && cargo check --tests
|
||||||
|
env:
|
||||||
|
RUSTFLAGS: --cfg exhaustive ${{env.RUSTFLAGS}}
|
||||||
|
if: matrix.os != 'windows'
|
||||||
|
|
||||||
msrv:
|
msrv:
|
||||||
name: Rust 1.13.0
|
name: Rust 1.13.0
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: dtolnay/rust-toolchain@1.13.0
|
- uses: dtolnay/rust-toolchain@1.13.0
|
||||||
- name: Get timestamp for cache
|
- name: Get timestamp for cache
|
||||||
id: date
|
id: date
|
||||||
@@ -85,7 +89,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
rust: [1.19.0, 1.20.0, 1.21.0, 1.25.0, 1.26.0, 1.34.0]
|
rust: [1.19.0, 1.20.0, 1.21.0, 1.25.0, 1.26.0, 1.34.0]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: dtolnay/rust-toolchain@master
|
- uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
toolchain: ${{matrix.rust}}
|
toolchain: ${{matrix.rust}}
|
||||||
@@ -100,7 +104,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
rust: [1.27.0, 1.28.0]
|
rust: [1.27.0, 1.28.0]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: dtolnay/rust-toolchain@master
|
- uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
toolchain: ${{matrix.rust}}
|
toolchain: ${{matrix.rust}}
|
||||||
@@ -113,7 +117,7 @@ jobs:
|
|||||||
name: Rust 1.31.0
|
name: Rust 1.31.0
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: dtolnay/rust-toolchain@1.31.0
|
- uses: dtolnay/rust-toolchain@1.31.0
|
||||||
- run: cd serde && cargo check --no-default-features
|
- run: cd serde && cargo check --no-default-features
|
||||||
- run: cd serde && cargo check
|
- run: cd serde && cargo check
|
||||||
@@ -123,7 +127,7 @@ jobs:
|
|||||||
name: Rust 1.36.0
|
name: Rust 1.36.0
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: dtolnay/rust-toolchain@1.36.0
|
- uses: dtolnay/rust-toolchain@1.36.0
|
||||||
- run: cd serde && cargo build --no-default-features --features alloc
|
- run: cd serde && cargo build --no-default-features --features alloc
|
||||||
|
|
||||||
@@ -131,7 +135,7 @@ jobs:
|
|||||||
name: Emscripten
|
name: Emscripten
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: dtolnay/rust-toolchain@nightly
|
- uses: dtolnay/rust-toolchain@nightly
|
||||||
- uses: actions/setup-node@v1
|
- uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
@@ -154,7 +158,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- 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_derive && cargo clippy -- -Dclippy::all -Dclippy::pedantic
|
- run: cd serde_derive && cargo clippy -- -Dclippy::all -Dclippy::pedantic
|
||||||
@@ -162,3 +166,16 @@ jobs:
|
|||||||
- run: cd serde_test && cargo clippy -- -Dclippy::all -Dclippy::pedantic
|
- run: cd serde_test && cargo clippy -- -Dclippy::all -Dclippy::pedantic
|
||||||
- run: cd test_suite && cargo clippy --tests --features unstable -- -Dclippy::all -Dclippy::pedantic
|
- run: cd test_suite && cargo clippy --tests --features unstable -- -Dclippy::all -Dclippy::pedantic
|
||||||
- run: cd test_suite/no_std && cargo clippy -- -Dclippy::all -Dclippy::pedantic
|
- run: cd test_suite/no_std && cargo clippy -- -Dclippy::all -Dclippy::pedantic
|
||||||
|
|
||||||
|
miri:
|
||||||
|
name: Miri
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: dtolnay/rust-toolchain@miri
|
||||||
|
- run: cd serde && cargo miri test --features derive,rc,unstable
|
||||||
|
env:
|
||||||
|
MIRIFLAGS: -Zmiri-tag-raw-pointers
|
||||||
|
- run: cd test_suite && cargo miri test --features unstable
|
||||||
|
env:
|
||||||
|
MIRIFLAGS: -Zmiri-tag-raw-pointers
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
msrv = "1.13.0"
|
||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.135" # remember to update html_root_url and serde_derive dependency
|
version = "1.0.137" # remember to update html_root_url and serde_derive dependency
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
rust-version = "1.15"
|
rust-version = "1.13"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "A generic serialization/deserialization framework"
|
description = "A generic serialization/deserialization framework"
|
||||||
homepage = "https://serde.rs"
|
homepage = "https://serde.rs"
|
||||||
@@ -15,7 +15,7 @@ include = ["build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APAC
|
|||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde_derive = { version = "=1.0.135", optional = true, path = "../serde_derive" }
|
serde_derive = { version = "=1.0.137", optional = true, path = "../serde_derive" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde_derive = { version = "1.0", path = "../serde_derive" }
|
serde_derive = { version = "1.0", path = "../serde_derive" }
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
use lib::fmt::{self, Write};
|
||||||
|
use lib::str;
|
||||||
|
|
||||||
|
pub struct Buf<'a> {
|
||||||
|
bytes: &'a mut [u8],
|
||||||
|
offset: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Buf<'a> {
|
||||||
|
pub fn new(bytes: &'a mut [u8]) -> Self {
|
||||||
|
Buf { bytes, offset: 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
let slice = &self.bytes[..self.offset];
|
||||||
|
unsafe { str::from_utf8_unchecked(slice) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Write for Buf<'a> {
|
||||||
|
fn write_str(&mut self, s: &str) -> fmt::Result {
|
||||||
|
if self.offset + s.len() > self.bytes.len() {
|
||||||
|
Err(fmt::Error)
|
||||||
|
} else {
|
||||||
|
self.bytes[self.offset..self.offset + s.len()].copy_from_slice(s.as_bytes());
|
||||||
|
self.offset += s.len();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
-5
@@ -104,7 +104,7 @@
|
|||||||
//! [`Deserialize`]: ../trait.Deserialize.html
|
//! [`Deserialize`]: ../trait.Deserialize.html
|
||||||
//! [`Deserializer`]: ../trait.Deserializer.html
|
//! [`Deserializer`]: ../trait.Deserializer.html
|
||||||
//! [`LinkedHashMap<K, V>`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html
|
//! [`LinkedHashMap<K, V>`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html
|
||||||
//! [`bincode`]: https://github.com/servo/bincode
|
//! [`bincode`]: https://github.com/bincode-org/bincode
|
||||||
//! [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
|
//! [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
|
||||||
//! [`serde_derive`]: https://crates.io/crates/serde_derive
|
//! [`serde_derive`]: https://crates.io/crates/serde_derive
|
||||||
//! [`serde_json`]: https://github.com/serde-rs/json
|
//! [`serde_json`]: https://github.com/serde-rs/json
|
||||||
@@ -118,6 +118,8 @@ use lib::*;
|
|||||||
|
|
||||||
pub mod value;
|
pub mod value;
|
||||||
|
|
||||||
|
#[cfg(not(no_integer128))]
|
||||||
|
mod format;
|
||||||
mod ignored_any;
|
mod ignored_any;
|
||||||
mod impls;
|
mod impls;
|
||||||
mod utf8;
|
mod utf8;
|
||||||
@@ -1366,8 +1368,10 @@ pub trait Visitor<'de>: Sized {
|
|||||||
where
|
where
|
||||||
E: Error,
|
E: Error,
|
||||||
{
|
{
|
||||||
let _ = v;
|
let mut buf = [0u8; 58];
|
||||||
Err(Error::invalid_type(Unexpected::Other("i128"), &self))
|
let mut writer = format::Buf::new(&mut buf);
|
||||||
|
fmt::Write::write_fmt(&mut writer, format_args!("integer `{}` as i128", v)).unwrap();
|
||||||
|
Err(Error::invalid_type(Unexpected::Other(writer.as_str()), &self))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1426,8 +1430,10 @@ pub trait Visitor<'de>: Sized {
|
|||||||
where
|
where
|
||||||
E: Error,
|
E: Error,
|
||||||
{
|
{
|
||||||
let _ = v;
|
let mut buf = [0u8; 57];
|
||||||
Err(Error::invalid_type(Unexpected::Other("u128"), &self))
|
let mut writer = format::Buf::new(&mut buf);
|
||||||
|
fmt::Write::write_fmt(&mut writer, format_args!("integer `{}` as u128", v)).unwrap();
|
||||||
|
Err(Error::invalid_type(Unexpected::Other(writer.as_str()), &self))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-7
@@ -59,14 +59,14 @@
|
|||||||
//! and from DynamoDB.
|
//! and from DynamoDB.
|
||||||
//!
|
//!
|
||||||
//! [JSON]: https://github.com/serde-rs/json
|
//! [JSON]: https://github.com/serde-rs/json
|
||||||
//! [Bincode]: https://github.com/servo/bincode
|
//! [Bincode]: https://github.com/bincode-org/bincode
|
||||||
//! [CBOR]: https://github.com/enarx/ciborium
|
//! [CBOR]: https://github.com/enarx/ciborium
|
||||||
//! [YAML]: https://github.com/dtolnay/serde-yaml
|
//! [YAML]: https://github.com/dtolnay/serde-yaml
|
||||||
//! [MessagePack]: https://github.com/3Hren/msgpack-rust
|
//! [MessagePack]: https://github.com/3Hren/msgpack-rust
|
||||||
//! [TOML]: https://github.com/alexcrichton/toml-rs
|
//! [TOML]: https://github.com/alexcrichton/toml-rs
|
||||||
//! [Pickle]: https://github.com/birkenfeld/serde-pickle
|
//! [Pickle]: https://github.com/birkenfeld/serde-pickle
|
||||||
//! [RON]: https://github.com/ron-rs/ron
|
//! [RON]: https://github.com/ron-rs/ron
|
||||||
//! [BSON]: https://github.com/zonyitoo/bson-rs
|
//! [BSON]: https://github.com/mongodb/bson-rust
|
||||||
//! [Avro]: https://github.com/flavray/avro-rs
|
//! [Avro]: https://github.com/flavray/avro-rs
|
||||||
//! [JSON5]: https://github.com/callum-oakley/json5-rs
|
//! [JSON5]: https://github.com/callum-oakley/json5-rs
|
||||||
//! [Postcard]: https://github.com/jamesmunns/postcard
|
//! [Postcard]: https://github.com/jamesmunns/postcard
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
//! [Envy]: https://github.com/softprops/envy
|
//! [Envy]: https://github.com/softprops/envy
|
||||||
//! [Envy Store]: https://github.com/softprops/envy-store
|
//! [Envy Store]: https://github.com/softprops/envy-store
|
||||||
//! [Cargo]: https://doc.rust-lang.org/cargo/reference/manifest.html
|
//! [Cargo]: https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
//! [AWS Parameter Store]: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html
|
//! [AWS Parameter Store]: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html
|
||||||
//! [S-expressions]: https://github.com/rotty/lexpr-rs
|
//! [S-expressions]: https://github.com/rotty/lexpr-rs
|
||||||
//! [D-Bus]: https://docs.rs/zvariant
|
//! [D-Bus]: https://docs.rs/zvariant
|
||||||
//! [FlexBuffers]: https://github.com/google/flatbuffers/tree/master/rust/flexbuffers
|
//! [FlexBuffers]: https://github.com/google/flatbuffers/tree/master/rust/flexbuffers
|
||||||
@@ -84,7 +84,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.135")]
|
#![doc(html_root_url = "https://docs.rs/serde/1.0.137")]
|
||||||
// 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)]
|
||||||
// Unstable functionality only if the user asks for it. For tracking and
|
// Unstable functionality only if the user asks for it. For tracking and
|
||||||
@@ -103,10 +103,8 @@
|
|||||||
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/7768
|
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/7768
|
||||||
semicolon_if_nothing_returned,
|
semicolon_if_nothing_returned,
|
||||||
// not available in our oldest supported compiler
|
// not available in our oldest supported compiler
|
||||||
checked_conversions,
|
|
||||||
empty_enum,
|
empty_enum,
|
||||||
redundant_field_names,
|
type_repetition_in_bounds, // https://github.com/rust-lang/rust-clippy/issues/8772
|
||||||
redundant_static_lifetimes,
|
|
||||||
// integer and float ser/de requires these sorts of casts
|
// integer and float ser/de requires these sorts of casts
|
||||||
cast_possible_truncation,
|
cast_possible_truncation,
|
||||||
cast_possible_wrap,
|
cast_possible_wrap,
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
//! [`LinkedHashMap<K, V>`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html
|
//! [`LinkedHashMap<K, V>`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html
|
||||||
//! [`Serialize`]: ../trait.Serialize.html
|
//! [`Serialize`]: ../trait.Serialize.html
|
||||||
//! [`Serializer`]: ../trait.Serializer.html
|
//! [`Serializer`]: ../trait.Serializer.html
|
||||||
//! [`bincode`]: https://github.com/servo/bincode
|
//! [`bincode`]: https://github.com/bincode-org/bincode
|
||||||
//! [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
|
//! [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
|
||||||
//! [`serde_derive`]: https://crates.io/crates/serde_derive
|
//! [`serde_derive`]: https://crates.io/crates/serde_derive
|
||||||
//! [`serde_json`]: https://github.com/serde-rs/json
|
//! [`serde_json`]: https://github.com/serde-rs/json
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
msrv = "1.31.0"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.135" # remember to update html_root_url
|
version = "1.0.137" # remember to update html_root_url
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
rust-version = "1.31"
|
rust-version = "1.31"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
@@ -23,7 +23,7 @@ proc-macro = true
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
syn = "1.0.60"
|
syn = "1.0.90"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde = { version = "1.0", path = "../serde" }
|
serde = { version = "1.0", path = "../serde" }
|
||||||
|
|||||||
@@ -184,9 +184,7 @@ pub fn with_bound(
|
|||||||
|
|
||||||
syn::Type::Infer(_) | syn::Type::Never(_) | syn::Type::Verbatim(_) => {}
|
syn::Type::Infer(_) | syn::Type::Never(_) | syn::Type::Verbatim(_) => {}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
|
||||||
syn::Type::__TestExhaustive(_) => unimplemented!(),
|
|
||||||
#[cfg(not(test))]
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1912,9 +1912,7 @@ fn collect_lifetimes(ty: &syn::Type, out: &mut BTreeSet<syn::Lifetime>) {
|
|||||||
| syn::Type::Infer(_)
|
| syn::Type::Infer(_)
|
||||||
| syn::Type::Verbatim(_) => {}
|
| syn::Type::Verbatim(_) => {}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
|
||||||
syn::Type::__TestExhaustive(_) => unimplemented!(),
|
|
||||||
#[cfg(not(test))]
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,9 +147,7 @@ impl ReplaceReceiver<'_> {
|
|||||||
|
|
||||||
Type::Infer(_) | Type::Never(_) | Type::Verbatim(_) => {}
|
Type::Infer(_) | Type::Never(_) | Type::Verbatim(_) => {}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
|
||||||
Type::__TestExhaustive(_) => unimplemented!(),
|
|
||||||
#[cfg(not(test))]
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.135")]
|
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.137")]
|
||||||
#![allow(unknown_lints, bare_trait_objects)]
|
#![allow(unknown_lints, bare_trait_objects)]
|
||||||
// Ignored clippy lints
|
// Ignored clippy lints
|
||||||
#![allow(
|
#![allow(
|
||||||
@@ -60,6 +60,7 @@
|
|||||||
clippy::use_self,
|
clippy::use_self,
|
||||||
clippy::wildcard_imports
|
clippy::wildcard_imports
|
||||||
)]
|
)]
|
||||||
|
#![cfg_attr(all(test, exhaustive), feature(non_exhaustive_omitted_patterns_lint))]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate quote;
|
extern crate quote;
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
msrv = "1.31.0"
|
||||||
@@ -17,7 +17,7 @@ path = "lib.rs"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
syn = { version = "1.0.60", default-features = false, features = ["derive", "parsing", "printing", "clone-impls"] }
|
syn = { version = "1.0.90", default-features = false, features = ["derive", "parsing", "printing", "clone-impls"] }
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
msrv = "1.13.0"
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_test"
|
name = "serde_test"
|
||||||
version = "1.0.135" # remember to update html_root_url
|
version = "1.0.137" # remember to update html_root_url
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
rust-version = "1.15"
|
rust-version = "1.13"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "Token De/Serializer for testing De/Serialize implementations"
|
description = "Token De/Serializer for testing De/Serialize implementations"
|
||||||
homepage = "https://serde.rs"
|
homepage = "https://serde.rs"
|
||||||
|
|||||||
@@ -144,7 +144,7 @@
|
|||||||
//! # }
|
//! # }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.135")]
|
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.137")]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
||||||
// Ignored clippy lints
|
// Ignored clippy lints
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(float_cmp, needless_doctest_main))]
|
#![cfg_attr(feature = "cargo-clippy", allow(float_cmp, needless_doctest_main))]
|
||||||
@@ -161,6 +161,7 @@
|
|||||||
must_use_candidate,
|
must_use_candidate,
|
||||||
redundant_field_names,
|
redundant_field_names,
|
||||||
too_many_lines,
|
too_many_lines,
|
||||||
|
type_repetition_in_bounds, // https://github.com/rust-lang/rust-clippy/issues/8772
|
||||||
use_debug,
|
use_debug,
|
||||||
use_self
|
use_self
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(target_os = "emscripten", ignore)]
|
||||||
#[rustversion::attr(not(nightly), ignore)]
|
#[rustversion::attr(not(nightly), ignore)]
|
||||||
|
#[cfg_attr(miri, ignore)]
|
||||||
|
#[allow(unused_attributes)]
|
||||||
#[test]
|
#[test]
|
||||||
fn ui() {
|
fn ui() {
|
||||||
let t = trybuild::TestCases::new();
|
let t = trybuild::TestCases::new();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(target_os = "emscripten", ignore)]
|
||||||
#[cfg_attr(not(expandtest), ignore)]
|
#[cfg_attr(not(expandtest), ignore)]
|
||||||
#[rustversion::attr(not(nightly), ignore)]
|
#[rustversion::attr(not(nightly), ignore)]
|
||||||
|
#[cfg_attr(miri, ignore)]
|
||||||
#[allow(unused_attributes)]
|
#[allow(unused_attributes)]
|
||||||
#[test]
|
#[test]
|
||||||
fn expandtest() {
|
fn expandtest() {
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
// Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422
|
// Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422
|
||||||
clippy::nonstandard_macro_braces,
|
clippy::nonstandard_macro_braces,
|
||||||
clippy::too_many_lines,
|
clippy::too_many_lines,
|
||||||
clippy::trivially_copy_pass_by_ref
|
clippy::trivially_copy_pass_by_ref,
|
||||||
|
clippy::type_repetition_in_bounds
|
||||||
)]
|
)]
|
||||||
|
|
||||||
use serde::de::{self, MapAccess, Unexpected, Visitor};
|
use serde::de::{self, MapAccess, Unexpected, Visitor};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#![allow(clippy::empty_enum, clippy::unreadable_literal)]
|
#![allow(clippy::empty_enum, clippy::unreadable_literal)]
|
||||||
#![cfg_attr(feature = "unstable", feature(never_type))]
|
#![cfg_attr(feature = "unstable", feature(never_type))]
|
||||||
|
|
||||||
|
use serde::de::IntoDeserializer;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_test::{assert_de_tokens_error, Token};
|
use serde_test::{assert_de_tokens_error, Token};
|
||||||
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
||||||
@@ -185,6 +186,16 @@ fn test_i64() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_i128() {
|
||||||
|
let deserializer = <i128 as IntoDeserializer>::into_deserializer(1);
|
||||||
|
let error = <&str>::deserialize(deserializer).unwrap_err();
|
||||||
|
assert_eq!(
|
||||||
|
error.to_string(),
|
||||||
|
"invalid type: integer `1` as i128, expected a borrowed string",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_u8() {
|
fn test_u8() {
|
||||||
let test = assert_de_tokens_error::<u8>;
|
let test = assert_de_tokens_error::<u8>;
|
||||||
@@ -326,6 +337,13 @@ fn test_u64() {
|
|||||||
&[Token::I64(-1)],
|
&[Token::I64(-1)],
|
||||||
"invalid value: integer `-1`, expected u64",
|
"invalid value: integer `-1`, expected u64",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let deserializer = <u64 as IntoDeserializer>::into_deserializer(1);
|
||||||
|
let error = <&str>::deserialize(deserializer).unwrap_err();
|
||||||
|
assert_eq!(
|
||||||
|
error.to_string(),
|
||||||
|
"invalid type: integer `1`, expected a borrowed string",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -349,6 +367,13 @@ fn test_u128() {
|
|||||||
&[Token::I64(-1)],
|
&[Token::I64(-1)],
|
||||||
"invalid value: integer `-1`, expected u128",
|
"invalid value: integer `-1`, expected u128",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let deserializer = <u128 as IntoDeserializer>::into_deserializer(1);
|
||||||
|
let error = <&str>::deserialize(deserializer).unwrap_err();
|
||||||
|
assert_eq!(
|
||||||
|
error.to_string(),
|
||||||
|
"invalid type: integer `1` as u128, expected a borrowed string",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -14,7 +14,8 @@
|
|||||||
clippy::nonstandard_macro_braces,
|
clippy::nonstandard_macro_braces,
|
||||||
clippy::ptr_arg,
|
clippy::ptr_arg,
|
||||||
clippy::too_many_lines,
|
clippy::too_many_lines,
|
||||||
clippy::trivially_copy_pass_by_ref
|
clippy::trivially_copy_pass_by_ref,
|
||||||
|
clippy::type_repetition_in_bounds
|
||||||
)]
|
)]
|
||||||
|
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
|
|||||||
@@ -3,7 +3,14 @@ error[E0308]: mismatched types
|
|||||||
|
|
|
|
||||||
7 | #[derive(Deserialize)]
|
7 | #[derive(Deserialize)]
|
||||||
| ^^^^^^^^^^^ expected `u16`, found `u8`
|
| ^^^^^^^^^^^ expected `u16`, found `u8`
|
||||||
|
8 | #[serde(remote = "remote::S")]
|
||||||
|
| ----------- arguments to this struct are incorrect
|
||||||
|
|
|
|
||||||
|
note: tuple struct defined here
|
||||||
|
--> tests/ui/remote/wrong_de.rs:4:16
|
||||||
|
|
|
||||||
|
4 | pub struct S(pub u16);
|
||||||
|
| ^
|
||||||
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
help: you can convert a `u8` to a `u16`
|
help: you can convert a `u8` to a `u16`
|
||||||
|
|
|
|
||||||
|
|||||||
@@ -2,8 +2,16 @@ error[E0308]: mismatched types
|
|||||||
--> tests/ui/remote/wrong_getter.rs:15:10
|
--> tests/ui/remote/wrong_getter.rs:15:10
|
||||||
|
|
|
|
||||||
15 | #[derive(Serialize)]
|
15 | #[derive(Serialize)]
|
||||||
| ^^^^^^^^^ expected `u8`, found `u16`
|
| ^^^^^^^^^
|
||||||
|
| |
|
||||||
|
| expected `u8`, found `u16`
|
||||||
|
| arguments to this function are incorrect
|
||||||
|
|
|
|
||||||
= note: expected reference `&u8`
|
= note: expected reference `&u8`
|
||||||
found reference `&u16`
|
found reference `&u16`
|
||||||
|
note: function defined here
|
||||||
|
--> $WORKSPACE/serde/src/private/ser.rs
|
||||||
|
|
|
||||||
|
| pub fn constrain<T: ?Sized>(t: &T) -> &T {
|
||||||
|
| ^^^^^^^^^
|
||||||
= note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> tests/ui/remote/wrong_ser.rs:9:10
|
--> tests/ui/remote/wrong_ser.rs:9:10
|
||||||
|
|
|
|
||||||
9 | #[derive(Serialize)]
|
9 | #[derive(Serialize)]
|
||||||
| ^^^^^^^^^ expected `u8`, found `u16`
|
| ^^^^^^^^^
|
||||||
|
|
| |
|
||||||
= note: expected reference `&u8`
|
| expected `u8`, found `u16`
|
||||||
found reference `&u16`
|
| arguments to this function are incorrect
|
||||||
= note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|
||||||
|
= note: expected reference `&u8`
|
||||||
|
found reference `&u16`
|
||||||
|
note: function defined here
|
||||||
|
--> $WORKSPACE/serde/src/private/ser.rs
|
||||||
|
|
|
||||||
|
| pub fn constrain<T: ?Sized>(t: &T) -> &T {
|
||||||
|
| ^^^^^^^^^
|
||||||
|
= note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|||||||
Reference in New Issue
Block a user