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#61087 - estebank:parsepalooza, r=Centril
Tweak `self` arg not as first argument of a method diagnostic Mention that `self` is only valid on "associated functions" ``` error: unexpected `self` argument in function --> $DIR/self-in-function-arg.rs:1:15 | LL | fn foo(x:i32, self: i32) -> i32 { self } | ^^^^ not valid as function argument | = note: `self` is only valid as the first argument of an associated function ``` When it is a method, mention it must be first ``` error: unexpected `self` argument in function --> $DIR/trait-fn.rs:4:20 | LL | fn c(foo: u32, self) {} | ^^^^ must be the first associated function argument ``` Move a bunch of error recovery methods to `diagnostics.rs` away from `parser.rs`. Fix rust-lang#51547. CC rust-lang#60015.
- Loading branch information
Showing
10 changed files
with
656 additions
and
566 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,5 +1,6 @@ | ||
fn a(&self) { } | ||
//~^ ERROR unexpected `self` argument in function | ||
//~| NOTE `self` is only valid as the first argument of an associated function | ||
//~^ ERROR unexpected `self` parameter in function | ||
//~| NOTE not valid as function parameter | ||
//~| NOTE `self` is only valid as the first parameter of an associated function | ||
|
||
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,8 +1,10 @@ | ||
error: unexpected `self` argument in function | ||
--> $DIR/bare-fn-start.rs:1:7 | ||
error: unexpected `self` parameter in function | ||
--> $DIR/bare-fn-start.rs:1:6 | ||
| | ||
LL | fn a(&self) { } | ||
| ^^^^ `self` is only valid as the first argument of an associated function | ||
| ^^^^^ not valid as function parameter | ||
| | ||
= note: `self` is only valid as the first parameter of an associated function | ||
|
||
error: aborting due to previous error | ||
|
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,5 +1,6 @@ | ||
fn b(foo: u32, &mut self) { } | ||
//~^ ERROR unexpected `self` argument in function | ||
//~| NOTE `self` is only valid as the first argument of an associated function | ||
//~^ ERROR unexpected `self` parameter in function | ||
//~| NOTE not valid as function parameter | ||
//~| NOTE `self` is only valid as the first parameter of an associated function | ||
|
||
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,8 +1,10 @@ | ||
error: unexpected `self` argument in function | ||
--> $DIR/bare-fn.rs:1:21 | ||
error: unexpected `self` parameter in function | ||
--> $DIR/bare-fn.rs:1:16 | ||
| | ||
LL | fn b(foo: u32, &mut self) { } | ||
| ^^^^ `self` is only valid as the first argument of an associated function | ||
| ^^^^^^^^^ not valid as function parameter | ||
| | ||
= note: `self` is only valid as the first parameter of an associated function | ||
|
||
error: aborting due to previous error | ||
|
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,8 +1,8 @@ | ||
error: unexpected `self` argument in function | ||
error: unexpected `self` parameter in function | ||
--> $DIR/trait-fn.rs:4:20 | ||
| | ||
LL | fn c(foo: u32, self) {} | ||
| ^^^^ `self` is only valid as the first argument of an associated function | ||
| ^^^^ must be the first associated function parameter | ||
|
||
error: aborting due to previous error | ||
|
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,3 @@ | ||
fn foo(x:i32, self: i32) -> i32 { self } //~ ERROR unexpected `self` parameter in function | ||
|
||
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,10 @@ | ||
error: unexpected `self` parameter in function | ||
--> $DIR/self-in-function-arg.rs:1:15 | ||
| | ||
LL | fn foo(x:i32, self: i32) -> i32 { self } | ||
| ^^^^ not valid as function parameter | ||
| | ||
= note: `self` is only valid as the first parameter of an associated function | ||
|
||
error: aborting due to previous error | ||
|