diff --git a/Cargo.toml b/Cargo.toml index a21afc7d..7657eb2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,10 @@ unused_import_braces = "warn" variant_size_differences = "warn" # Unsafe code is needed for array initialization using MaybeUninit. # unsafe_code = "forbid" +# FIXME: For tarpaulin some code is excluded, since tarpaulin does not detect the line coverage well +# Statements like: #![cfg(not(tarpaulin_include))] +# but the lint doesn't like them and it is probably better to not have a build.rs just for that. +unexpected_cfgs = "allow" [workspace.lints.clippy] # These lints have false positives and are disabled until they are fixed. diff --git a/serde_with/src/guide/serde_as.md b/serde_with/src/guide/serde_as.md index c99af85a..b96fe42a 100644 --- a/serde_with/src/guide/serde_as.md +++ b/serde_with/src/guide/serde_as.md @@ -144,7 +144,7 @@ Our goal is to serialize this `Data` struct. Currently, we do not have anything we can use to replace `???` with, since `_` only works if `RemoteType` would implement `Serialize`, which it does not. ```rust -# #[cfg(FALSE)] { +# #[cfg(any())] { #[serde_as] #[derive(serde::Serialize)] struct Data { @@ -159,7 +159,7 @@ The `SerializeAs` implementation is **always** written for a local type. This allows it to seamlessly work with types from dependencies without running into orphan rule problems. ```rust -# #[cfg(FALSE)] { +# #[cfg(any())] { struct LocalType; impl SerializeAs for LocalType { @@ -188,7 +188,7 @@ As can be seen, this is mostly boilerplate, since the most part is encapsulated The final `Data` struct will now look like: ```rust -# #[cfg(FALSE)] { +# #[cfg(any())] { #[serde_as] #[derive(serde::Serialize)] struct Data { @@ -205,7 +205,7 @@ This is a special functionality of serde, where it derives the de/serialization You can find all the details in the [official serde documentation](https://serde.rs/remote-derive.html). ```rust -# #[cfg(FALSE)] { +# #[cfg(any())] { // Pretend that this is somebody else's crate, not a module. mod other_crate { // Neither Serde nor the other crate provides Serialize and Deserialize @@ -238,7 +238,7 @@ We can write this implementation. The implementation for `DeserializeAs` works analogue. ```rust -# #[cfg(FALSE)] { +# #[cfg(any())] { impl SerializeAs for DurationDef { fn serialize_as(value: &Duration, serializer: S) -> Result where @@ -253,7 +253,7 @@ impl SerializeAs for DurationDef { This now allows us to use `Duration` for serialization. ```rust -# #[cfg(FALSE)] { +# #[cfg(any())] { use other_crate::Duration; #[serde_as] diff --git a/serde_with/src/lib.rs b/serde_with/src/lib.rs index bbe42316..5f7338a2 100644 --- a/serde_with/src/lib.rs +++ b/serde_with/src/lib.rs @@ -1767,7 +1767,7 @@ pub struct PickFirst(PhantomData); /// Deserializing works analogue, by deserializing a `T` and then converting into `O`. /// /// ```rust -/// # #[cfg(FALSE)] { +/// # #[cfg(any())] { /// struct S { /// #[serde_as(as = "FromInto")] /// value: O, @@ -1849,7 +1849,7 @@ pub struct FromInto(PhantomData); /// Deserializing works analogue, by deserializing a `T` and then converting into `O`. /// /// ```rust -/// # #[cfg(FALSE)] { +/// # #[cfg(any())] { /// struct S { /// #[serde_as(as = "FromIntoRef")] /// value: O, @@ -1930,7 +1930,7 @@ pub struct FromIntoRef(PhantomData); /// Deserializing works analogue, by deserializing a `T` and then converting into `O`. /// /// ```rust -/// # #[cfg(FALSE)] { +/// # #[cfg(any())] { /// struct S { /// #[serde_as(as = "TryFromInto")] /// value: O, @@ -2019,7 +2019,7 @@ pub struct TryFromInto(PhantomData); /// Deserializing works analogue, by deserializing a `T` and then converting into `O`. /// /// ```rust -/// # #[cfg(FALSE)] { +/// # #[cfg(any())] { /// struct S { /// #[serde_as(as = "TryFromIntoRef")] /// value: O, diff --git a/serde_with/src/rust.rs b/serde_with/src/rust.rs index bab925c6..71fb394f 100644 --- a/serde_with/src/rust.rs +++ b/serde_with/src/rust.rs @@ -18,7 +18,7 @@ use crate::prelude::*; /// This cannot work, since there is no way to tell the `Vec` to skip the inner `DoubleOption` if it is `None`. /// /// ```rust -/// # #[cfg(FALSE)] { +/// # #[cfg(any())] { /// # struct Foobar { /// #[serde_as(as = "Vec>")] /// data: Vec>>, @@ -184,7 +184,7 @@ pub mod unwrap_or_skip { /// The `_` is a placeholder which works for any type which implements [`Serialize`]/[`Deserialize`]. /// /// ```rust -/// # #[cfg(FALSE)] { +/// # #[cfg(any())] { /// #[serde_as] /// #[derive(Deserialize, Serialize)] /// struct A { @@ -300,7 +300,7 @@ pub mod sets_duplicate_value_is_error { /// The `_` is a placeholder which works for any type which implements [`Serialize`]/[`Deserialize`]. /// /// ```rust -/// # #[cfg(FALSE)] { +/// # #[cfg(any())] { /// #[serde_as] /// #[derive(Deserialize, Serialize)] /// struct A { @@ -420,7 +420,7 @@ pub mod maps_duplicate_key_is_error { /// The `_` is a placeholder which works for any type which implements [`Serialize`]/[`Deserialize`]. /// /// ```rust -/// # #[cfg(FALSE)] { +/// # #[cfg(any())] { /// #[serde_as] /// #[derive(Deserialize, Serialize)] /// struct A { @@ -508,7 +508,7 @@ pub mod sets_last_value_wins { /// The `_` is a placeholder which works for any type which implements [`Serialize`]/[`Deserialize`]. /// /// ```rust -/// # #[cfg(FALSE)] { +/// # #[cfg(any())] { /// #[serde_as] /// #[derive(Deserialize, Serialize)] /// struct A {