Skip to content

Commit 7d8559a

Browse files
committed
Add test
1 parent ac5e187 commit 7d8559a

2 files changed

+36
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
struct Foo {
2+
field: u32,
3+
}
4+
5+
impl Foo {
6+
fn field(&self) -> u32 {
7+
self.field
8+
}
9+
10+
fn new() -> Foo {
11+
field; //~ ERROR cannot find value `field` in this scope
12+
Foo { field } //~ ERROR cannot find value `field` in this scope
13+
}
14+
}
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0425]: cannot find value `field` in this scope
2+
--> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:11:9
3+
|
4+
LL | fn field(&self) -> u32 {
5+
| ----- a method by that name is available on `Self` here
6+
...
7+
LL | field;
8+
| ^^^^^ a field by this name exists in `Self`
9+
10+
error[E0425]: cannot find value `field` in this scope
11+
--> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:12:15
12+
|
13+
LL | fn field(&self) -> u32 {
14+
| ----- a method by that name is available on `Self` here
15+
...
16+
LL | Foo { field }
17+
| ^^^^^ a field by this name exists in `Self`
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0425`.

0 commit comments

Comments
 (0)