]> git.proxmox.com Git - rustc.git/blob - src/test/ui/resolve/issue-2356.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / src / test / ui / resolve / issue-2356.rs
1 trait Groom {
2 fn shave(other: usize);
3 }
4
5 pub struct Cat {
6 whiskers: isize,
7 }
8
9 pub enum MaybeDog {
10 Dog,
11 NoDog
12 }
13
14 impl MaybeDog {
15 fn bark() {
16 // If this provides a suggestion, it's a bug as MaybeDog doesn't impl Groom
17 shave();
18 //~^ ERROR cannot find function `shave`
19 }
20 }
21
22 impl Clone for Cat {
23 fn clone(&self) -> Self {
24 clone();
25 //~^ ERROR cannot find function `clone`
26 loop {}
27 }
28 }
29 impl Default for Cat {
30 fn default() -> Self {
31 default();
32 //~^ ERROR cannot find function `default` in this scope [E0425]
33 loop {}
34 }
35 }
36
37 impl Groom for Cat {
38 fn shave(other: usize) {
39 whiskers -= other;
40 //~^ ERROR cannot find value `whiskers`
41 shave(4);
42 //~^ ERROR cannot find function `shave`
43 purr();
44 //~^ ERROR cannot find function `purr`
45 }
46 }
47
48 impl Cat {
49 fn static_method() {}
50
51 fn purr_louder() {
52 static_method();
53 //~^ ERROR cannot find function `static_method`
54 purr();
55 //~^ ERROR cannot find function `purr`
56 purr();
57 //~^ ERROR cannot find function `purr`
58 purr();
59 //~^ ERROR cannot find function `purr`
60 }
61 }
62
63 impl Cat {
64 fn meow() {
65 if self.whiskers > 3 {
66 //~^ ERROR expected value, found module `self`
67 println!("MEOW");
68 }
69 }
70
71 fn purr(&self) {
72 grow_older();
73 //~^ ERROR cannot find function `grow_older`
74 shave();
75 //~^ ERROR cannot find function `shave`
76 }
77
78 fn burn_whiskers(&mut self) {
79 whiskers = 0;
80 //~^ ERROR cannot find value `whiskers`
81 }
82
83 pub fn grow_older(other:usize) {
84 whiskers = 4;
85 //~^ ERROR cannot find value `whiskers`
86 purr_louder();
87 //~^ ERROR cannot find function `purr_louder`
88 }
89 }
90
91 fn main() {
92 self += 1;
93 //~^ ERROR expected value, found module `self`
94 }