Skip to content

Commit ceb2c24

Browse files
committed
Include the closing paren to the span of ast::NestedMetaItem
1 parent ea22216 commit ceb2c24

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/libsyntax/attr.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -1064,26 +1064,21 @@ impl MetaItem {
10641064
},
10651065
_ => return None,
10661066
};
1067+
let list_closing_paren_pos = tokens.peek().map(|tt| tt.span().hi);
10671068
let node = match MetaItemKind::from_tokens(tokens) {
10681069
Some(node) => node,
10691070
_ => return None,
10701071
};
1071-
if let Some(last_span) = node.last_span() {
1072-
span.hi = last_span.hi;
1073-
}
1072+
span.hi = match node {
1073+
MetaItemKind::NameValue(ref lit) => lit.span.hi,
1074+
MetaItemKind::List(..) => list_closing_paren_pos.unwrap_or(span.hi),
1075+
_ => span.hi,
1076+
};
10741077
Some(MetaItem { name: name, span: span, node: node })
10751078
}
10761079
}
10771080

10781081
impl MetaItemKind {
1079-
fn last_span(&self) -> Option<Span> {
1080-
match *self {
1081-
MetaItemKind::Word => None,
1082-
MetaItemKind::List(ref list) => list.last().map(NestedMetaItem::span),
1083-
MetaItemKind::NameValue(ref lit) => Some(lit.span),
1084-
}
1085-
}
1086-
10871082
pub fn tokens(&self, span: Span) -> TokenStream {
10881083
match *self {
10891084
MetaItemKind::Word => TokenStream::empty(),

0 commit comments

Comments
 (0)