serde/test_suite/tests/test_serde_path.rs
David Tolnay a9a9903107
Ignore extra_unused_type_parameters clippy lint in test
error: type parameter goes unused in function definition
       --> test_suite/tests/test_gen.rs:756:10
        |
    756 | fn assert<T: Serialize + DeserializeOwned>() {}
        |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: consider removing the parameter
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_type_parameters
        = note: `-D clippy::extra-unused-type-parameters` implied by `-D clippy::all`

    error: type parameter goes unused in function definition
       --> test_suite/tests/test_gen.rs:757:14
        |
    757 | fn assert_ser<T: Serialize>() {}
        |              ^^^^^^^^^^^^^^
        |
        = help: consider removing the parameter
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_type_parameters

    error: type parameter goes unused in function definition
      --> test_suite/tests/test_serde_path.rs:20:18
       |
    20 |     pub fn assert<T>()
       |                  ^^^
       |
       = help: consider removing the parameter
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_type_parameters
       = note: `-D clippy::extra-unused-type-parameters` implied by `-D clippy::all`
2023-02-10 19:14:43 -08:00

46 lines
1.1 KiB
Rust

#![allow(
clippy::extra_unused_type_parameters,
clippy::type_repetition_in_bounds
)]
#[test]
fn test_gen_custom_serde() {
#[derive(serde::Serialize, serde::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>,
{
}
pub trait Serialize {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>;
}
pub trait Deserialize<'a>: Sized {
fn deserialize<D: Deserializer<'a>>(deserializer: D) -> Result<Self, D::Error>;
}
}
trait AssertNotSerdeSerialize {}
impl<T: serde::Serialize> AssertNotSerdeSerialize for T {}
trait AssertNotSerdeDeserialize<'a> {}
impl<'a, T: serde::Deserialize<'a>> AssertNotSerdeDeserialize<'a> for T {}