use std::ops::{Deref, DerefMut}; struct Thing; trait Method { fn method(&self) -> T; fn mut_method(&mut self) -> T; } impl Method for Thing { fn method(&self) -> i32 { 0 } fn mut_method(&mut self) -> i32 { 0 } } impl Method for Thing { fn method(&self) -> u32 { 0 } fn mut_method(&mut self) -> u32 { 0 } } trait MethodRef { fn by_self(self); } impl MethodRef for &Thing { fn by_self(self) {} } impl MethodRef for &Thing { fn by_self(self) {} } struct DerefsTo(T); impl Deref for DerefsTo { type Target = T; fn deref(&self) -> &Self::Target { &self.0 } } impl DerefMut for DerefsTo { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } fn main() { let mut thing = Thing; thing.method(); //~^ ERROR type annotations needed //~| ERROR type annotations needed thing.mut_method(); //~ ERROR type annotations needed thing.by_self(); //~ ERROR type annotations needed let mut deref_to = DerefsTo(Thing); deref_to.method(); //~ ERROR type annotations needed deref_to.mut_method(); //~ ERROR type annotations needed deref_to.by_self(); //~ ERROR type annotations needed let mut deref_deref_to = DerefsTo(DerefsTo(Thing)); deref_deref_to.method(); //~ ERROR type annotations needed deref_deref_to.mut_method(); //~ ERROR type annotations needed deref_deref_to.by_self(); //~ ERROR type annotations needed }