-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suggest calling method when first argument is
self
- Loading branch information
Showing
6 changed files
with
95 additions
and
14 deletions.
There are no files selected for viewing
Submodule rustc-guide
updated
from 7c5670 to 934380
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
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,22 @@ | ||
struct Foo {} | ||
|
||
impl Foo { | ||
fn foo(&self) { | ||
bar(self); | ||
//~^ ERROR cannot find function `bar` in this scope | ||
//~| HELP try calling method instead of passing `self` as parameter | ||
|
||
|
||
bar(&self); | ||
//~^ ERROR cannot find function `bar` in this scope | ||
//~| HELP try calling method instead of passing `self` as parameter | ||
|
||
bar(); | ||
//~^ ERROR cannot find function `bar` in this scope | ||
|
||
self.bar(); | ||
//~^ ERROR no method named `bar` found for type | ||
} | ||
} | ||
|
||
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,28 @@ | ||
error[E0425]: cannot find function `bar` in this scope | ||
--> $DIR/suggest-self-2.rs:5:9 | ||
| | ||
LL | bar(self); | ||
| ^^^ help: try calling method instead of passing `self` as parameter: `self.bar` | ||
|
||
error[E0425]: cannot find function `bar` in this scope | ||
--> $DIR/suggest-self-2.rs:10:9 | ||
| | ||
LL | bar(&self); | ||
| ^^^ help: try calling method instead of passing `self` as parameter: `self.bar` | ||
|
||
error[E0425]: cannot find function `bar` in this scope | ||
--> $DIR/suggest-self-2.rs:14:9 | ||
| | ||
LL | bar(); | ||
| ^^^ not found in this scope | ||
|
||
error[E0599]: no method named `bar` found for type `&Foo` in the current scope | ||
--> $DIR/suggest-self-2.rs:17:14 | ||
| | ||
LL | self.bar(); | ||
| ^^^ method not found in `&Foo` | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
Some errors have detailed explanations: E0425, E0599. | ||
For more information about an error, try `rustc --explain E0425`. |