diff options
| author | yukang <moorekang@gmail.com> | 2022-10-26 05:32:19 +0800 |
|---|---|---|
| committer | yukang <moorekang@gmail.com> | 2022-10-26 05:32:19 +0800 |
| commit | 27164495881d2d3d1bb1ef79850b00f1e9989ba7 (patch) | |
| tree | 600641c572b08cd6ef0e2a49caede203608b9fa3 | |
| parent | 32a2f0dddb7aae3bef2939af5079eb2bcbfdf6c5 (diff) | |
| download | rust-27164495881d2d3d1bb1ef79850b00f1e9989ba7.tar.gz rust-27164495881d2d3d1bb1ef79850b00f1e9989ba7.zip | |
add testcase for suggest self
| -rw-r--r-- | src/test/ui/resolve/issue-103474.rs | 12 | ||||
| -rw-r--r-- | src/test/ui/resolve/issue-103474.stderr | 17 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/test/ui/resolve/issue-103474.rs b/src/test/ui/resolve/issue-103474.rs index 408139ca011..14f2259e1d4 100644 --- a/src/test/ui/resolve/issue-103474.rs +++ b/src/test/ui/resolve/issue-103474.rs @@ -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() {} diff --git a/src/test/ui/resolve/issue-103474.stderr b/src/test/ui/resolve/issue-103474.stderr index 78fa13fbd2e..415d231552a 100644 --- a/src/test/ui/resolve/issue-103474.stderr +++ b/src/test/ui/resolve/issue-103474.stderr @@ -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`. |
