Skip to content

Commit 4790db4

Browse files
committed
Fix Attr metavariable binding
gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_attr_input): Handle more delimeter tokens and the END_OF_FILE token. (Parser::skip_after_end_attribute): Handle the END_OF_FILE token. gcc/testsuite/ChangeLog: * rust/compile/macros/mbe/meta-param.rs: New test. Signed-off-by: Owen Avery <[email protected]>
1 parent d90770b commit 4790db4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

gcc/rust/parse/rust-parse-impl.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,10 @@ Parser<ManagedTokenSource>::parse_attr_input ()
877877
return attr_input_lit;
878878
}
879879
break;
880+
case RIGHT_PAREN:
880881
case RIGHT_SQUARE:
882+
case RIGHT_CURLY:
883+
case END_OF_FILE:
881884
// means AttrInput is missing, which is allowed
882885
return nullptr;
883886
default:
@@ -11911,7 +11914,7 @@ Parser<ManagedTokenSource>::skip_after_end_attribute ()
1191111914
{
1191211915
const_TokenPtr t = lexer.peek_token ();
1191311916

11914-
while (t->get_id () != RIGHT_SQUARE)
11917+
while (t->get_id () != RIGHT_SQUARE && t->get_id () != END_OF_FILE)
1191511918
{
1191611919
lexer.skip_token ();
1191711920
t = lexer.peek_token ();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
macro_rules! foo {
2+
($x:meta) => {0}
3+
}
4+
5+
pub fn main() -> i32 {
6+
foo!(Clone)
7+
}

0 commit comments

Comments
 (0)