Skip to content

Commit

Permalink
add testcase for suggest self
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Oct 25, 2022
1 parent 32a2f0d commit 2716449
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/test/ui/resolve/issue-103474.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
17 changes: 16 additions & 1 deletion src/test/ui/resolve/issue-103474.stderr
Original file line number Diff line number Diff line change
@@ -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
|
Expand All @@ -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`.

0 comments on commit 2716449

Please sign in to comment.