From 6ea4a52f47f3f66f9db9004d8ed55a819dd81523 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Tue, 1 Oct 2019 00:58:30 +0300 Subject: [PATCH] Address review comments --- src/libsyntax/ast.rs | 1 + src/libsyntax/parse/attr.rs | 4 ++-- src/test/ui/macros/macro-meta-items-modern.rs | 11 +++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/macros/macro-meta-items-modern.rs diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index e2c8e37e11c30..023952042e6d4 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -2156,6 +2156,7 @@ pub struct Attribute { pub span: Span, } +// Compatibility impl to avoid churn, consider removing. impl std::ops::Deref for Attribute { type Target = AttrItem; fn deref(&self) -> &Self::Target { &self.item } diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index f3298b6a65dcf..e74f3045db804 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -166,7 +166,7 @@ impl<'a> Parser<'a> { /// PATH `[` TOKEN_STREAM `]` /// PATH `{` TOKEN_STREAM `}` /// PATH - /// PATH `=` TOKEN_TREE + /// PATH `=` UNSUFFIXED_LIT /// The delimiters or `=` are still put into the resulting token stream. pub fn parse_attr_item(&mut self) -> PResult<'a, ast::AttrItem> { let item = match self.token.kind { @@ -262,7 +262,7 @@ impl<'a> Parser<'a> { /// Matches the following grammar (per RFC 1559). /// - /// meta_item : IDENT ( '=' UNSUFFIXED_LIT | '(' meta_item_inner? ')' )? ; + /// meta_item : PATH ( '=' UNSUFFIXED_LIT | '(' meta_item_inner? ')' )? ; /// meta_item_inner : (meta_item | UNSUFFIXED_LIT) (',' meta_item_inner)? ; pub fn parse_meta_item(&mut self) -> PResult<'a, ast::MetaItem> { let nt_meta = match self.token.kind { diff --git a/src/test/ui/macros/macro-meta-items-modern.rs b/src/test/ui/macros/macro-meta-items-modern.rs new file mode 100644 index 0000000000000..bc6938d4a6c9a --- /dev/null +++ b/src/test/ui/macros/macro-meta-items-modern.rs @@ -0,0 +1,11 @@ +// check-pass + +macro_rules! check { ($meta:meta) => () } + +check!(meta(a b c d)); +check!(meta[a b c d]); +check!(meta { a b c d }); +check!(meta); +check!(meta = 0); + +fn main() {}