846f865de2
warning: trait `AssertNotSerdeSerialize` is never used --> test_suite/tests/test_serde_path.rs:39:7 | 39 | trait AssertNotSerdeSerialize {} | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: trait `AssertNotSerdeDeserialize` is never used --> test_suite/tests/test_serde_path.rs:43:7 | 43 | trait AssertNotSerdeDeserialize<'a> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: method `serialize` is never used --> test_suite/tests/test_serde_path.rs:31:12 | 30 | pub trait Serialize { | --------- method in this trait 31 | fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>; | ^^^^^^^^^ warning: associated function `deserialize` is never used --> test_suite/tests/test_serde_path.rs:35:12 | 34 | pub trait Deserialize<'a>: Sized { | ----------- associated function in this trait 35 | fn deserialize<D: Deserializer<'a>>(deserializer: D) -> Result<Self, D::Error>; | ^^^^^^^^^^^
48 lines
1.2 KiB
Rust
48 lines
1.2 KiB
Rust
#![allow(
|
|
clippy::extra_unused_type_parameters,
|
|
clippy::type_repetition_in_bounds
|
|
)]
|
|
|
|
#[test]
|
|
fn test_gen_custom_serde() {
|
|
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
|
|
#[serde(crate = "fake_serde")]
|
|
struct Foo;
|
|
|
|
// Would be overlapping if serde::Serialize were implemented
|
|
impl AssertNotSerdeSerialize for Foo {}
|
|
// Would be overlapping if serde::Deserialize were implemented
|
|
impl<'a> AssertNotSerdeDeserialize<'a> for Foo {}
|
|
|
|
fake_serde::assert::<Foo>();
|
|
}
|
|
|
|
mod fake_serde {
|
|
pub use serde::*;
|
|
|
|
pub fn assert<T>()
|
|
where
|
|
T: Serialize,
|
|
T: for<'a> Deserialize<'a>,
|
|
{
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub trait Serialize {
|
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>;
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub trait Deserialize<'a>: Sized {
|
|
fn deserialize<D: Deserializer<'a>>(deserializer: D) -> Result<Self, D::Error>;
|
|
}
|
|
}
|
|
|
|
pub trait AssertNotSerdeSerialize {}
|
|
|
|
impl<T: serde::Serialize> AssertNotSerdeSerialize for T {}
|
|
|
|
pub trait AssertNotSerdeDeserialize<'a> {}
|
|
|
|
impl<'a, T: serde::Deserialize<'a>> AssertNotSerdeDeserialize<'a> for T {}
|