about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-03-19 15:16:55 +0100
committerGitHub <noreply@github.com>2019-03-19 15:16:55 +0100
commit8ebe2acb7bd2919cfd7cd583d258e9bd95a81391 (patch)
tree4767aca80de9d6bdf69ecdceb77d624279a75711 /src/libsyntax
parent61ff887919ba03d869e2b91aba1a9e64f6bf9a73 (diff)
parent27abd52170b2d2769f5fbed665795bdb9a3facef (diff)
downloadrust-8ebe2acb7bd2919cfd7cd583d258e9bd95a81391.tar.gz
rust-8ebe2acb7bd2919cfd7cd583d258e9bd95a81391.zip
Rollup merge of #59116 - estebank:comma-sugg, r=petrochenkov
Be more discerning on when to attempt suggesting a comma in a macro invocation

Fix #58796.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/tokenstream.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs
index 4ce308d015c..80a7bde606a 100644
--- a/src/libsyntax/tokenstream.rs
+++ b/src/libsyntax/tokenstream.rs
@@ -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,
                     };