]> git.proxmox.com Git - rustc.git/blob - src/test/ui/traits/suggest-fully-qualified-path-without-adjustment.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / traits / suggest-fully-qualified-path-without-adjustment.rs
1 use std::ops::{Deref, DerefMut};
2
3 struct Thing;
4
5 trait Method<T> {
6 fn method(&self) -> T;
7 fn mut_method(&mut self) -> T;
8 }
9
10 impl Method<i32> for Thing {
11 fn method(&self) -> i32 { 0 }
12 fn mut_method(&mut self) -> i32 { 0 }
13 }
14
15 impl Method<u32> for Thing {
16 fn method(&self) -> u32 { 0 }
17 fn mut_method(&mut self) -> u32 { 0 }
18 }
19
20 trait MethodRef<T> {
21 fn by_self(self);
22 }
23 impl MethodRef<i32> for &Thing {
24 fn by_self(self) {}
25 }
26 impl MethodRef<u32> for &Thing {
27 fn by_self(self) {}
28 }
29
30 struct DerefsTo<T>(T);
31 impl<T> Deref for DerefsTo<T> {
32 type Target = T;
33 fn deref(&self) -> &Self::Target {
34 &self.0
35 }
36 }
37 impl<T> DerefMut for DerefsTo<T> {
38 fn deref_mut(&mut self) -> &mut Self::Target {
39 &mut self.0
40 }
41 }
42
43 fn main() {
44 let mut ref_thing = &Thing;
45 ref_thing.method();
46 //~^ ERROR type annotations needed
47 //~| ERROR type annotations needed
48 ref_thing.by_self(); //~ ERROR type annotations needed
49
50 let mut mut_thing = &mut Thing;
51 mut_thing.method(); //~ ERROR type annotations needed
52 mut_thing.mut_method(); //~ ERROR type annotations needed
53 mut_thing.by_self(); //~ ERROR type annotations needed
54
55 let mut deref_to = &DerefsTo(Thing);
56 deref_to.method(); //~ ERROR type annotations needed
57 deref_to.mut_method(); //~ ERROR type annotations needed
58 deref_to.by_self(); //~ ERROR type annotations needed
59
60 let mut deref_deref_to = &DerefsTo(DerefsTo(Thing));
61 deref_deref_to.method(); //~ ERROR type annotations needed
62 deref_deref_to.mut_method(); //~ ERROR type annotations needed
63 deref_deref_to.by_self(); //~ ERROR type annotations needed
64 }