-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #128185 - surechen:fix_128042_2, r=compiler-errors
Fix a span error when parsing a wrong param of function. fixes #128042 Before this change, the span of param `*mut Self` in `fn oof(*mut Self)` contains `(` before it, so the suggestion in E0424 will be error.
- Loading branch information
Showing
3 changed files
with
42 additions
and
1 deletion.
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,12 @@ | ||
struct Thing { | ||
state: u8, | ||
} | ||
|
||
impl Thing { | ||
fn oof(*mut Self) { //~ ERROR expected parameter name, found `*` | ||
self.state = 1; | ||
//~^ ERROR expected value, found module `self` | ||
} | ||
} | ||
|
||
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,22 @@ | ||
error: expected parameter name, found `*` | ||
--> $DIR/suggest-add-self-issue-128042.rs:6:12 | ||
| | ||
LL | fn oof(*mut Self) { | ||
| ^ expected parameter name | ||
|
||
error[E0424]: expected value, found module `self` | ||
--> $DIR/suggest-add-self-issue-128042.rs:7:9 | ||
| | ||
LL | fn oof(*mut Self) { | ||
| --- this function doesn't have a `self` parameter | ||
LL | self.state = 1; | ||
| ^^^^ `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 oof(&self, *mut Self) { | ||
| ++++++ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0424`. |