Skip to content

Commit

Permalink
Avoid parsing const unsafe/extern functions as async
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h
	(Parser::parse_vis_item):
	Call parse_function instead of parse_async_item when finding
	UNSAFE or EXTERN_KW during lookahead.

gcc/testsuite/ChangeLog:

	* rust/compile/func-const-unsafe.rs: New test.

Signed-off-by: Owen Avery <[email protected]>
  • Loading branch information
powerboat9 authored and P-E-P committed Mar 27, 2024
1 parent fd621e1 commit 01092b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gcc/rust/parse/rust-parse-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1382,10 +1382,10 @@ Parser<ManagedTokenSource>::parse_vis_item (AST::AttrVec outer_attrs)
case IDENTIFIER:
case UNDERSCORE:
return parse_const_item (std::move (vis), std::move (outer_attrs));
case UNSAFE:
case EXTERN_KW:
case ASYNC:
return parse_async_item (std::move (vis), std::move (outer_attrs));
case UNSAFE:
case EXTERN_KW:
case FN_KW:
return parse_function (std::move (vis), std::move (outer_attrs));
default:
Expand Down
1 change: 1 addition & 0 deletions gcc/testsuite/rust/compile/func-const-unsafe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub const unsafe fn foo() {}

0 comments on commit 01092b8

Please sign in to comment.