1
Fork 0

Be more discerning on when to attempt suggesting a comma in a macro invocation

This commit is contained in:
Esteban Küber 2019-03-11 15:07:07 -07:00
parent 913ad6d1f0
commit b9d12edd6c
3 changed files with 27 additions and 9 deletions

View file

@ -178,9 +178,11 @@ impl TokenStream {
while let Some((pos, ts)) = iter.next() {
if let Some((_, next)) = iter.peek() {
let sp = match (&ts, &next) {
((TokenTree::Token(_, token::Token::Comma), NonJoint), _) |
(_, (TokenTree::Token(_, token::Token::Comma), NonJoint)) => continue,
((TokenTree::Token(sp, _), NonJoint), _) => *sp,
(_, (TokenTree::Token(_, token::Token::Comma), _)) => continue,
((TokenTree::Token(sp, token_left), NonJoint),
(TokenTree::Token(_, token_right), _))
if token_left.is_ident() || token_left.is_lit() &&
token_right.is_ident() || token_right.is_lit() => *sp,
((TokenTree::Delimited(sp, ..), NonJoint), _) => sp.entire(),
_ => continue,
};