blob: da640c8c8c26a883638ee2fe48a58c59fa8e5f04 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
use std::ops::{Deref, DerefMut};
struct Thing;
trait Method<T> {
fn method(&self) -> T;
fn mut_method(&mut self) -> T;
}
impl Method<i32> for Thing {
fn method(&self) -> i32 { 0 }
fn mut_method(&mut self) -> i32 { 0 }
}
impl Method<u32> for Thing {
fn method(&self) -> u32 { 0 }
fn mut_method(&mut self) -> u32 { 0 }
}
trait MethodRef<T> {
fn by_self(self);
}
impl MethodRef<i32> for &Thing {
fn by_self(self) {}
}
impl MethodRef<u32> for &Thing {
fn by_self(self) {}
}
struct DerefsTo<T>(T);
impl<T> Deref for DerefsTo<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<T> DerefMut for DerefsTo<T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
fn main() {
let mut ref_thing = &Thing;
ref_thing.method();
//~^ ERROR type annotations needed
//~| ERROR type annotations needed
ref_thing.by_self(); //~ ERROR type annotations needed
let mut mut_thing = &mut Thing;
mut_thing.method(); //~ ERROR type annotations needed
mut_thing.mut_method(); //~ ERROR type annotations needed
mut_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
}
|