]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/suggest-fully-qualified-path-with-adjustment.rs
Rollup merge of #93080 - SkiFire13:itermut-as_mut_slice, r=m-ou-se
[rust.git] / src / test / ui / traits / suggest-fully-qualified-path-with-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 trait MethodRef<T> {
20     fn by_self(self);
21 }
22 impl MethodRef<i32> for &Thing {
23     fn by_self(self) {}
24 }
25 impl MethodRef<u32> for &Thing {
26     fn by_self(self) {}
27 }
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 thing = Thing;
45     thing.method();
46     //~^ ERROR type annotations needed
47     //~| ERROR type annotations needed
48     thing.mut_method(); //~ ERROR type annotations needed
49     thing.by_self(); //~ ERROR type annotations needed
50
51     let mut deref_to = DerefsTo(Thing);
52     deref_to.method(); //~ ERROR type annotations needed
53     deref_to.mut_method(); //~ ERROR type annotations needed
54     deref_to.by_self(); //~ ERROR type annotations needed
55
56     let mut deref_deref_to = DerefsTo(DerefsTo(Thing));
57     deref_deref_to.method(); //~ ERROR type annotations needed
58     deref_deref_to.mut_method(); //~ ERROR type annotations needed
59     deref_deref_to.by_self(); //~ ERROR type annotations needed
60 }