From: Owen Avery <[email protected]>

Fixes https://github.com/Rust-GCC/gccrs/issues/4054

gcc/rust/ChangeLog:

        * parse/rust-parse-impl.h
        (Parser::parse_identifier_or_keyword_token): Record error on
        failure.

gcc/testsuite/ChangeLog:

        * rust/compile/macros/mbe/macro-issue4054.rs: New test.

Signed-off-by: Owen Avery <[email protected]>
---
 gcc/rust/parse/rust-parse-impl.h                   |  1 +
 .../rust/compile/macros/mbe/macro-issue4054.rs     | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
 create mode 100644 gcc/testsuite/rust/compile/macros/mbe/macro-issue4054.rs

diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 5d7c5309fb0..38bf85e49d8 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -1053,6 +1053,7 @@ 
Parser<ManagedTokenSource>::parse_identifier_or_keyword_token ()
     }
   else
     {
+      add_error (Error (t->get_locus (), "expected keyword or identifier"));
       return nullptr;
     }
 }
diff --git a/gcc/testsuite/rust/compile/macros/mbe/macro-issue4054.rs 
b/gcc/testsuite/rust/compile/macros/mbe/macro-issue4054.rs
new file mode 100644
index 00000000000..6dcab23289f
--- /dev/null
+++ b/gcc/testsuite/rust/compile/macros/mbe/macro-issue4054.rs
@@ -0,0 +1,14 @@
+#[allow(path_statements)]
+
+macro_rules! array_impl_default {
+    {$t:ident} => {
+        $t;
+        array_impl_default!{}
+    };
+    {} => {}
+}
+
+pub fn foo() {
+    let x = 12;
+    array_impl_default! {x}
+}
-- 
2.50.1

Reply via email to