Skip to content

Commit 2716449

Browse files
committed
add testcase for suggest self
1 parent 32a2f0d commit 2716449

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/test/ui/resolve/issue-103474.rs

+12
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,16 @@ impl S {
1313
}
1414
}
1515

16+
// https://github.com/rust-lang/rust/pull/103531#discussion_r1004728080
17+
struct Foo {
18+
i: i32,
19+
}
20+
21+
impl Foo {
22+
fn needs_self() {
23+
this.i
24+
//~^ ERROR cannot find value `this` in this scope
25+
}
26+
}
27+
1628
fn main() {}

src/test/ui/resolve/issue-103474.stderr

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
error[E0425]: cannot find value `this` in this scope
2+
--> $DIR/issue-103474.rs:23:9
3+
|
4+
LL | this.i
5+
| ^^^^ not found in this scope
6+
|
7+
help: you might have meant to use `self` here instead
8+
|
9+
LL | self.i
10+
| ~~~~
11+
help: if you meant to use `self`, you are also missing a `self` receiver argument
12+
|
13+
LL | fn needs_self(&self) {
14+
| +++++
15+
116
error[E0425]: cannot find function `first` in this scope
217
--> $DIR/issue-103474.rs:6:9
318
|
@@ -15,6 +30,6 @@ error[E0425]: cannot find function `no_method_err` in this scope
1530
LL | no_method_err()
1631
| ^^^^^^^^^^^^^ not found in this scope
1732

18-
error: aborting due to 2 previous errors
33+
error: aborting due to 3 previous errors
1934

2035
For more information about this error, try `rustc --explain E0425`.

0 commit comments

Comments
 (0)