From ceb2c240a6722f2b2ba3a3612af21d943c18fd30 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Thu, 17 Aug 2017 21:58:01 +0900 Subject: Include the closing paren to the span of ast::NestedMetaItem --- src/libsyntax/attr.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index bca662c3363..ca87c807103 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -1064,26 +1064,21 @@ impl MetaItem { }, _ => return None, }; + let list_closing_paren_pos = tokens.peek().map(|tt| tt.span().hi); let node = match MetaItemKind::from_tokens(tokens) { Some(node) => node, _ => return None, }; - if let Some(last_span) = node.last_span() { - span.hi = last_span.hi; - } + span.hi = match node { + MetaItemKind::NameValue(ref lit) => lit.span.hi, + MetaItemKind::List(..) => list_closing_paren_pos.unwrap_or(span.hi), + _ => span.hi, + }; Some(MetaItem { name: name, span: span, node: node }) } } impl MetaItemKind { - fn last_span(&self) -> Option { - match *self { - MetaItemKind::Word => None, - MetaItemKind::List(ref list) => list.last().map(NestedMetaItem::span), - MetaItemKind::NameValue(ref lit) => Some(lit.span), - } - } - pub fn tokens(&self, span: Span) -> TokenStream { match *self { MetaItemKind::Word => TokenStream::empty(), -- cgit 1.4.1-3-g733a5