rust/tests/ui/serde.rs

50 lines
1.1 KiB
Rust
Raw Normal View History

2018-07-28 10:34:52 -05:00
#![warn(clippy::serde_api_misuse)]
2024-08-18 06:31:47 -05:00
#![allow(dead_code, clippy::needless_lifetimes)]
extern crate serde;
struct A;
2017-05-09 08:23:10 -05:00
impl<'de> serde::de::Visitor<'de> for A {
type Value = ();
fn expecting(&self, _: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
unimplemented!()
}
fn visit_str<E>(self, _v: &str) -> Result<Self::Value, E>
2018-12-09 16:26:16 -06:00
where
E: serde::de::Error,
{
unimplemented!()
}
fn visit_string<E>(self, _v: String) -> Result<Self::Value, E>
2018-12-09 16:26:16 -06:00
where
E: serde::de::Error,
{
unimplemented!()
}
}
struct B;
2017-05-09 08:23:10 -05:00
impl<'de> serde::de::Visitor<'de> for B {
type Value = ();
fn expecting(&self, _: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
unimplemented!()
}
fn visit_string<E>(self, _v: String) -> Result<Self::Value, E>
//~^ ERROR: you should not implement `visit_string` without also implementing `visit_s
//~| NOTE: `-D clippy::serde-api-misuse` implied by `-D warnings`
2018-12-09 16:26:16 -06:00
where
E: serde::de::Error,
{
unimplemented!()
}
}
2018-12-09 16:26:16 -06:00
fn main() {}