Commit Message
Arthur Cohen
Aug. 1, 2024, 2:57 p.m. UTC
From: Owen Avery <powerboat9.gamer@gmail.com> 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 <powerboat9.gamer@gmail.com> --- gcc/rust/parse/rust-parse-impl.h | 4 ++-- gcc/testsuite/rust/compile/func-const-unsafe.rs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/rust/compile/func-const-unsafe.rs
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index b6c2ca3fc0c..263ca634ea5 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -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: diff --git a/gcc/testsuite/rust/compile/func-const-unsafe.rs b/gcc/testsuite/rust/compile/func-const-unsafe.rs new file mode 100644 index 00000000000..9c932bd1cb5 --- /dev/null +++ b/gcc/testsuite/rust/compile/func-const-unsafe.rs @@ -0,0 +1 @@ +pub const unsafe fn foo() {}