]> git.lizzy.rs Git - rust.git/blob - src/test/ui/resolve/issue-14254.rs
Rollup merge of #97812 - TaKO8Ki:suggest-to-swap-struct-and-trait, r=estebank
[rust.git] / src / test / ui / resolve / issue-14254.rs
1 trait Foo {
2     fn bar(&self);
3     fn baz(&self) { }
4     fn bah(_: Option<&Self>) { }
5 }
6
7 struct BarTy {
8     x : isize,
9     y : f64,
10 }
11
12 impl BarTy {
13     fn a() {}
14     fn b(&self) {}
15 }
16
17 impl Foo for *const BarTy {
18     fn bar(&self) {
19         baz();
20         //~^ ERROR cannot find function `baz`
21         a;
22         //~^ ERROR cannot find value `a`
23     }
24 }
25
26 impl<'a> Foo for &'a BarTy {
27     fn bar(&self) {
28         baz();
29         //~^ ERROR cannot find function `baz`
30         x;
31         //~^ ERROR cannot find value `x`
32         y;
33         //~^ ERROR cannot find value `y`
34         a;
35         //~^ ERROR cannot find value `a`
36         bah;
37         //~^ ERROR cannot find value `bah`
38         b;
39         //~^ ERROR cannot find value `b`
40     }
41 }
42
43 impl<'a> Foo for &'a mut BarTy {
44     fn bar(&self) {
45         baz();
46         //~^ ERROR cannot find function `baz`
47         x;
48         //~^ ERROR cannot find value `x`
49         y;
50         //~^ ERROR cannot find value `y`
51         a;
52         //~^ ERROR cannot find value `a`
53         bah;
54         //~^ ERROR cannot find value `bah`
55         b;
56         //~^ ERROR cannot find value `b`
57     }
58 }
59
60 impl Foo for Box<BarTy> {
61     fn bar(&self) {
62         baz();
63         //~^ ERROR cannot find function `baz`
64         bah;
65         //~^ ERROR cannot find value `bah`
66     }
67 }
68
69 impl Foo for *const isize {
70     fn bar(&self) {
71         baz();
72         //~^ ERROR cannot find function `baz`
73         bah;
74         //~^ ERROR cannot find value `bah`
75     }
76 }
77
78 impl<'a> Foo for &'a isize {
79     fn bar(&self) {
80         baz();
81         //~^ ERROR cannot find function `baz`
82         bah;
83         //~^ ERROR cannot find value `bah`
84     }
85 }
86
87 impl<'a> Foo for &'a mut isize {
88     fn bar(&self) {
89         baz();
90         //~^ ERROR cannot find function `baz`
91         bah;
92         //~^ ERROR cannot find value `bah`
93     }
94 }
95
96 impl Foo for Box<isize> {
97     fn bar(&self) {
98         baz();
99         //~^ ERROR cannot find function `baz`
100         bah;
101         //~^ ERROR cannot find value `bah`
102     }
103 }
104
105 fn main() {}