From 71efdaa6364142b359c59659ec10f35a1e53b5d2 Mon Sep 17 00:00:00 2001 From: uHOOCCOOHu Date: Mon, 30 Sep 2019 04:44:33 +0800 Subject: Parse correct AttrInput --- crates/ra_parser/src/grammar/attributes.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'crates/ra_parser/src/grammar') diff --git a/crates/ra_parser/src/grammar/attributes.rs b/crates/ra_parser/src/grammar/attributes.rs index 1cfd301b5..72e7717b7 100644 --- a/crates/ra_parser/src/grammar/attributes.rs +++ b/crates/ra_parser/src/grammar/attributes.rs @@ -22,8 +22,25 @@ fn attribute(p: &mut Parser, inner: bool) { p.bump(T![!]); } - if p.at(T!['[']) { - items::token_tree(p); + if p.eat(T!['[']) { + paths::use_path(p); + + let is_delimiter = |p: &mut Parser| match p.current() { + T!['('] | T!['['] | T!['{'] => true, + _ => false, + }; + + if p.eat(T![=]) { + if expressions::literal(p).is_none() { + p.error("expected literal"); + } + } else if is_delimiter(p) { + items::token_tree(p); + } + + if !p.eat(T![']']) { + p.error("expected `]`"); + } } else { p.error("expected `[`"); } -- cgit v1.2.3