forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#103531 - chenyukang:yukang/fix-103474, r=es…
…tebank Suggest calling the instance method of the same name when method not found Fixes rust-lang#103474
- Loading branch information
Showing
6 changed files
with
88 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
struct S {} | ||
impl S { | ||
fn first(&self) {} | ||
|
||
fn second(&self) { | ||
first() | ||
//~^ ERROR cannot find function `first` in this scope | ||
} | ||
|
||
fn third(&self) { | ||
no_method_err() | ||
//~^ ERROR cannot find function `no_method_err` in this scope | ||
} | ||
} | ||
|
||
// 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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
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 | ||
| | ||
LL | first() | ||
| ^^^^^ not found in this scope | ||
| | ||
help: consider using the associated function | ||
| | ||
LL | self.first() | ||
| +++++ | ||
|
||
error[E0425]: cannot find function `no_method_err` in this scope | ||
--> $DIR/issue-103474.rs:11:9 | ||
| | ||
LL | no_method_err() | ||
| ^^^^^^^^^^^^^ not found in this scope | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0425`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters