Require getters to return the correct type

This commit is contained in:
David Tolnay
2017-04-09 10:59:54 -07:00
parent a6d172111b
commit 9d8987bde8
3 changed files with 33 additions and 1 deletions
@@ -0,0 +1,23 @@
#[macro_use]
extern crate serde_derive;
mod remote {
pub struct S {
a: u8,
}
impl S {
pub fn get(&self) -> u16 {
self.a as u16
}
}
}
#[derive(Serialize)] //~ ERROR: mismatched types
#[serde(remote = "remote::S")]
struct S {
#[serde(getter = "remote::S::get")]
a: u8, //~^^^^ expected u8, found u16
}
fn main() {}