add testcase for suggest self

This commit is contained in:
yukang 2022-10-26 05:32:19 +08:00
parent 32a2f0dddb
commit 2716449588
2 changed files with 28 additions and 1 deletions

View File

@ -13,4 +13,16 @@ impl S {
}
}
// https://github.com/rust-lang/rust/pull/103531#discussion_r1004728080
struct Foo {
i: i32,
}
impl Foo {
fn needs_self() {
this.i
//~^ ERROR cannot find value `this` in this scope
}
}
fn main() {}

View File

@ -1,3 +1,18 @@
error[E0425]: cannot find value `this` in this scope
--> $DIR/issue-103474.rs:23:9
|
LL | this.i
| ^^^^ not found in this scope
|
help: you might have meant to use `self` here instead
|
LL | self.i
| ~~~~
help: if you meant to use `self`, you are also missing a `self` receiver argument
|
LL | fn needs_self(&self) {
| +++++
error[E0425]: cannot find function `first` in this scope
--> $DIR/issue-103474.rs:6:9
|
@ -15,6 +30,6 @@ error[E0425]: cannot find function `no_method_err` in this scope
LL | no_method_err()
| ^^^^^^^^^^^^^ not found in this scope
error: aborting due to 2 previous errors
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0425`.