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::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} +}