-
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.
Expect extern fn with no body when parsing
Also add a test case for inserting a semicolon on extern fns. Without this fix, we got an error like this: error: expected one of `->`, `where`, or `{`, found `}` --> chk.rs:3:1 | 2 | fn foo() | --- - expected one of `->`, `where`, or `{` | | | while parsing this `fn` 3 | } | ^ unexpected token Since this is inside an extern block, you're required to write function prototypes with no body. This fixes a regression, and adds a test case for it.
- Loading branch information
Showing
4 changed files
with
29 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
9 changes: 9 additions & 0 deletions
9
src/test/ui/suggestions/suggest-semicolon-for-fn-in-extern-block.fixed
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,9 @@ | ||
// run-rustfix | ||
|
||
#[allow(dead_code)] | ||
|
||
extern "C" { | ||
fn foo(); //~ERROR expected `;` | ||
} | ||
|
||
fn main() {} |
9 changes: 9 additions & 0 deletions
9
src/test/ui/suggestions/suggest-semicolon-for-fn-in-extern-block.rs
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,9 @@ | ||
// run-rustfix | ||
|
||
#[allow(dead_code)] | ||
|
||
extern "C" { | ||
fn foo() //~ERROR expected `;` | ||
} | ||
|
||
fn main() {} |
10 changes: 10 additions & 0 deletions
10
src/test/ui/suggestions/suggest-semicolon-for-fn-in-extern-block.stderr
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: expected `;`, found `}` | ||
--> $DIR/suggest-semicolon-for-fn-in-extern-block.rs:6:11 | ||
| | ||
LL | fn foo() | ||
| ^ help: add `;` here | ||
LL | } | ||
| - unexpected token | ||
|
||
error: aborting due to previous error | ||
|