]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/issue-14254.rs
Make name resolution errors non-fatal
[rust.git] / src / test / compile-fail / issue-14254.rs
1 // Copyright 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 Foo {
12     fn bar(&self);
13     fn baz(&self) { }
14     fn bah(_: Option<&Self>) { }
15 }
16
17 struct BarTy {
18     x : isize,
19     y : f64,
20 }
21
22 impl BarTy {
23     fn a() {}
24     fn b(&self) {}
25 }
26
27 impl Foo for *const BarTy {
28     fn bar(&self) {
29         baz();
30         //~^ ERROR: unresolved name `baz`. Did you mean to call `self.baz`?
31         a;
32         //~^ ERROR: unresolved name `a`
33     }
34 }
35
36 impl<'a> Foo for &'a BarTy {
37     fn bar(&self) {
38         baz();
39         //~^ ERROR: unresolved name `baz`. Did you mean to call `self.baz`?
40         x;
41         //~^ ERROR: unresolved name `x`. Did you mean `self.x`?
42         y;
43         //~^ ERROR: unresolved name `y`. Did you mean `self.y`?
44         a;
45         //~^ ERROR: unresolved name `a`
46         bah;
47         //~^ ERROR: unresolved name `bah`. Did you mean to call `Foo::bah`?
48         b;
49         //~^ ERROR: unresolved name `b`
50     }
51 }
52
53 impl<'a> Foo for &'a mut BarTy {
54     fn bar(&self) {
55         baz();
56         //~^ ERROR: unresolved name `baz`. Did you mean to call `self.baz`?
57         x;
58         //~^ ERROR: unresolved name `x`. Did you mean `self.x`?
59         y;
60         //~^ ERROR: unresolved name `y`. Did you mean `self.y`?
61         a;
62         //~^ ERROR: unresolved name `a`
63         bah;
64         //~^ ERROR: unresolved name `bah`. Did you mean to call `Foo::bah`?
65         b;
66         //~^ ERROR: unresolved name `b`
67     }
68 }
69
70 impl Foo for Box<BarTy> {
71     fn bar(&self) {
72         baz();
73         //~^ ERROR: unresolved name `baz`. Did you mean to call `self.baz`?
74         bah;
75         //~^ ERROR: unresolved name `bah`. Did you mean to call `Foo::bah`?
76     }
77 }
78
79 impl Foo for *const isize {
80     fn bar(&self) {
81         baz();
82         //~^ ERROR: unresolved name `baz`. Did you mean to call `self.baz`?
83         bah;
84         //~^ ERROR: unresolved name `bah`. Did you mean to call `Foo::bah`?
85     }
86 }
87
88 impl<'a> Foo for &'a isize {
89     fn bar(&self) {
90         baz();
91         //~^ ERROR: unresolved name `baz`. Did you mean to call `self.baz`?
92         bah;
93         //~^ ERROR: unresolved name `bah`. Did you mean to call `Foo::bah`?
94     }
95 }
96
97 impl<'a> Foo for &'a mut isize {
98     fn bar(&self) {
99         baz();
100         //~^ ERROR: unresolved name `baz`. Did you mean to call `self.baz`?
101         bah;
102         //~^ ERROR: unresolved name `bah`. Did you mean to call `Foo::bah`?
103     }
104 }
105
106 impl Foo for Box<isize> {
107     fn bar(&self) {
108         baz();
109         //~^ ERROR: unresolved name `baz`. Did you mean to call `self.baz`?
110         bah;
111         //~^ ERROR: unresolved name `bah`. Did you mean to call `Foo::bah`?
112     }
113 }