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#68764 - Centril:self-semantic, r=petrochenkov
parser: syntactically allow `self` in all `fn` contexts Part of rust-lang#68728. `self` parameters are now *syntactically* allowed as the first parameter irrespective of item context (and in function pointers). Instead, semantic validation (`ast_validation`) is used. r? @petrochenkov
- Loading branch information
Showing
20 changed files
with
453 additions
and
87 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
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,6 +1,6 @@ | ||
fn a(&self) { } | ||
//~^ 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 | ||
//~^ ERROR `self` parameter is only allowed in associated functions | ||
//~| NOTE not semantically valid as function parameter | ||
//~| NOTE associated functions are those in `impl` or `trait` definitions | ||
|
||
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,10 +1,10 @@ | ||
error: unexpected `self` parameter in function | ||
error: `self` parameter is only allowed in associated functions | ||
--> $DIR/bare-fn-start.rs:1:6 | ||
| | ||
LL | fn a(&self) { } | ||
| ^^^^^ not valid as function parameter | ||
| ^^^^^ not semantically valid as function parameter | ||
| | ||
= note: `self` is only valid as the first parameter of an associated function | ||
= note: associated functions are those in `impl` or `trait` definitions | ||
|
||
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,6 +1,5 @@ | ||
fn b(foo: u32, &mut self) { } | ||
//~^ 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 | ||
//~| NOTE must be 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
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
Oops, something went wrong.