diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-08-18 01:10:56 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-09-30 22:58:22 +0300 |
| commit | 957986d05620238799ae7053d505f742a0c7d640 (patch) | |
| tree | d9d83823f2fd71276724c8fec53f4307f8d926f6 /src/libsyntax/attr | |
| parent | 535d4743a4bc4807446cefbc2413e02d53aa0a85 (diff) | |
| download | rust-957986d05620238799ae7053d505f742a0c7d640.tar.gz rust-957986d05620238799ae7053d505f742a0c7d640.zip | |
syntax: Support modern attribute syntax in the `meta` matcher
Diffstat (limited to 'src/libsyntax/attr')
| -rw-r--r-- | src/libsyntax/attr/mod.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index 009259352ba..7bef693a5be 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -255,9 +255,8 @@ impl MetaItem { } } -impl Attribute { - /// Extracts the `MetaItem` from inside this `Attribute`. - pub fn meta(&self) -> Option<MetaItem> { +impl AttrItem { + crate fn meta(&self, span: Span) -> Option<MetaItem> { let mut tokens = self.tokens.trees().peekable(); Some(MetaItem { path: self.path.clone(), @@ -269,9 +268,16 @@ impl Attribute { } else { return None; }, - span: self.span, + span, }) } +} + +impl Attribute { + /// Extracts the MetaItem from inside this Attribute. + pub fn meta(&self) -> Option<MetaItem> { + self.item.meta(self.span) + } pub fn parse<'a, T, F>(&self, sess: &'a ParseSess, mut f: F) -> PResult<'a, T> where F: FnMut(&mut Parser<'a>) -> PResult<'a, T>, @@ -524,7 +530,7 @@ impl MetaItem { } Some(TokenTree::Token(Token { kind: token::Interpolated(nt), .. })) => match *nt { token::Nonterminal::NtIdent(ident, _) => Path::from_ident(ident), - token::Nonterminal::NtMeta(ref meta) => return Some(meta.clone()), + token::Nonterminal::NtMeta(ref item) => return item.meta(item.path.span), token::Nonterminal::NtPath(ref path) => path.clone(), _ => return None, }, |
