-
Notifications
You must be signed in to change notification settings - Fork 13k
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 #75509 - estebank:coming-merrily-from-java-land, r=lcnr
Tweak suggestion for `this` -> `self` * When referring to `this` in associated `fn`s always suggest `self`. * Point at ident for `fn` lacking `self` * Suggest adding `self` to assoc `fn`s when appropriate _Improvements based on the narrative in https://fasterthanli.me/articles/i-am-a-java-csharp-c-or-cplusplus-dev-time-to-do-some-rust_
- Loading branch information
Showing
7 changed files
with
148 additions
and
35 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
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 |
---|---|---|
@@ -1,21 +1,37 @@ | ||
error[E0424]: expected value, found module `self` | ||
--> $DIR/E0424.rs:7:9 | ||
| | ||
LL | / fn foo() { | ||
LL | | self.bar(); | ||
| | ^^^^ `self` value is a keyword only available in methods with a `self` parameter | ||
LL | | } | ||
| |_____- this function doesn't have a `self` parameter | ||
LL | fn foo() { | ||
| --- this function doesn't have a `self` parameter | ||
LL | self.bar(); | ||
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter | ||
| | ||
help: add a `self` receiver parameter to make the associated `fn` a method | ||
| | ||
LL | fn foo(&self) { | ||
| ^^^^^ | ||
|
||
error[E0424]: expected value, found module `self` | ||
--> $DIR/E0424.rs:11:9 | ||
| | ||
LL | fn baz(_: i32) { | ||
| --- this function doesn't have a `self` parameter | ||
LL | self.bar(); | ||
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter | ||
| | ||
help: add a `self` receiver parameter to make the associated `fn` a method | ||
| | ||
LL | fn baz(&self, _: i32) { | ||
| ^^^^^^ | ||
|
||
error[E0424]: expected unit struct, unit variant or constant, found module `self` | ||
--> $DIR/E0424.rs:12:9 | ||
--> $DIR/E0424.rs:16:9 | ||
| | ||
LL | / fn main () { | ||
LL | | let self = "self"; | ||
| | ^^^^ `self` value is a keyword and may not be bound to variables or shadowed | ||
LL | | } | ||
| |_- this function doesn't have a `self` parameter | ||
LL | fn main () { | ||
| ---- this function can't have a `self` parameter | ||
LL | let self = "self"; | ||
| ^^^^ `self` value is a keyword and may not be bound to variables or shadowed | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0424`. |
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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
trait B < A > { fn a() -> A { this.a } } //~ ERROR cannot find value `this` in this scope | ||
trait B <A> { | ||
fn a() -> A { | ||
this.a //~ ERROR cannot find value `this` in this scope | ||
} | ||
fn b(x: i32) { | ||
this.b(x); //~ 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 |
---|---|---|
@@ -1,9 +1,33 @@ | ||
error[E0425]: cannot find value `this` in this scope | ||
--> $DIR/issue-5099.rs:1:31 | ||
--> $DIR/issue-5099.rs:3:9 | ||
| | ||
LL | trait B < A > { fn a() -> A { this.a } } | ||
| ^^^^ not found in this scope | ||
LL | this.a | ||
| ^^^^ not found in this scope | ||
| | ||
help: you might have meant to use `self` here instead | ||
| | ||
LL | self.a | ||
| ^^^^ | ||
help: if you meant to use `self`, you are also missing a `self` receiver argument | ||
| | ||
LL | fn a(&self) -> A { | ||
| ^^^^^ | ||
|
||
error[E0425]: cannot find value `this` in this scope | ||
--> $DIR/issue-5099.rs:6:9 | ||
| | ||
LL | this.b(x); | ||
| ^^^^ not found in this scope | ||
| | ||
help: you might have meant to use `self` here instead | ||
| | ||
LL | self.b(x); | ||
| ^^^^ | ||
help: if you meant to use `self`, you are also missing a `self` receiver argument | ||
| | ||
LL | fn b(&self, x: i32) { | ||
| ^^^^^^ | ||
|
||
error: aborting due to previous error | ||
error: aborting due to 2 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