]> git.lizzy.rs Git - rust.git/blob - src/test/ui/resolve/issue-2356.rs
Auto merge of #46713 - Manishearth:memchr, r=bluss
[rust.git] / src / test / ui / resolve / issue-2356.rs
1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 trait Groom {
12     fn shave(other: usize);
13 }
14
15 pub struct cat {
16   whiskers: isize,
17 }
18
19 pub enum MaybeDog {
20     Dog,
21     NoDog
22 }
23
24 impl MaybeDog {
25   fn bark() {
26     // If this provides a suggestion, it's a bug as MaybeDog doesn't impl Groom
27     shave();
28     //~^ ERROR cannot find function `shave`
29   }
30 }
31
32 impl Clone for cat {
33   fn clone(&self) -> Self {
34     clone();
35     //~^ ERROR cannot find function `clone`
36     loop {}
37   }
38 }
39 impl Default for cat {
40   fn default() -> Self {
41     default();
42     //~^ ERROR cannot find function `default`
43     loop {}
44   }
45 }
46
47 impl Groom for cat {
48   fn shave(other: usize) {
49     whiskers -= other;
50     //~^ ERROR cannot find value `whiskers`
51     shave(4);
52     //~^ ERROR cannot find function `shave`
53     purr();
54     //~^ ERROR cannot find function `purr`
55   }
56 }
57
58 impl cat {
59     fn static_method() {}
60
61     fn purr_louder() {
62         static_method();
63         //~^ ERROR cannot find function `static_method`
64         purr();
65         //~^ ERROR cannot find function `purr`
66         purr();
67         //~^ ERROR cannot find function `purr`
68         purr();
69         //~^ ERROR cannot find function `purr`
70     }
71 }
72
73 impl cat {
74   fn meow() {
75     if self.whiskers > 3 {
76         //~^ ERROR expected value, found module `self`
77         println!("MEOW");
78     }
79   }
80
81   fn purr(&self) {
82     grow_older();
83     //~^ ERROR cannot find function `grow_older`
84     shave();
85     //~^ ERROR cannot find function `shave`
86   }
87
88   fn burn_whiskers(&mut self) {
89     whiskers = 0;
90     //~^ ERROR cannot find value `whiskers`
91   }
92
93   pub fn grow_older(other:usize) {
94     whiskers = 4;
95     //~^ ERROR cannot find value `whiskers`
96     purr_louder();
97     //~^ ERROR cannot find function `purr_louder`
98   }
99 }
100
101 fn main() {
102     self += 1;
103     //~^ ERROR expected value, found module `self`
104 }