]> git.lizzy.rs Git - rust.git/commitdiff
Merge #7050
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>
Sun, 27 Dec 2020 16:42:01 +0000 (16:42 +0000)
committerGitHub <noreply@github.com>
Sun, 27 Dec 2020 16:42:01 +0000 (16:42 +0000)
7050: Ignore third punct when matching for 2-composite punct in mbe r=jonas-schievink a=edwin0cheng

Fixes #6692

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
crates/mbe/src/mbe_expander/matcher.rs
crates/mbe/src/tests.rs

index 7aeef7be5c2e964cb6426e116fba8cfe9b01fe13..44722c0f1a286719eea0398485fc4e383b94a87e 100644 (file)
@@ -240,26 +240,26 @@ pub(crate) fn expect_tt(&mut self) -> Result<tt::TokenTree, ()> {
                 let tt3 = self.next().unwrap().clone();
                 Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2, tt3] }.into())
             }
-            ('-', '=', None)
-            | ('-', '>', None)
-            | (':', ':', None)
-            | ('!', '=', None)
-            | ('.', '.', None)
-            | ('*', '=', None)
-            | ('/', '=', None)
-            | ('&', '&', None)
-            | ('&', '=', None)
-            | ('%', '=', None)
-            | ('^', '=', None)
-            | ('+', '=', None)
-            | ('<', '<', None)
-            | ('<', '=', None)
-            | ('=', '=', None)
-            | ('=', '>', None)
-            | ('>', '=', None)
-            | ('>', '>', None)
-            | ('|', '=', None)
-            | ('|', '|', None) => {
+            ('-', '=', _)
+            | ('-', '>', _)
+            | (':', ':', _)
+            | ('!', '=', _)
+            | ('.', '.', _)
+            | ('*', '=', _)
+            | ('/', '=', _)
+            | ('&', '&', _)
+            | ('&', '=', _)
+            | ('%', '=', _)
+            | ('^', '=', _)
+            | ('+', '=', _)
+            | ('<', '<', _)
+            | ('<', '=', _)
+            | ('=', '=', _)
+            | ('=', '>', _)
+            | ('>', '=', _)
+            | ('>', '>', _)
+            | ('|', '=', _)
+            | ('|', '|', _) => {
                 let tt2 = self.next().unwrap().clone();
                 Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2] }.into())
             }
index 451fa1456a40528a6664053b42ad453a790fbdc8..6cd0ed205395249eba780d633231a65f23fe61f4 100644 (file)
@@ -991,6 +991,22 @@ macro_rules! foo {
     );
 }
 
+#[test]
+fn test_tt_with_composite_without_space() {
+    parse_macro(
+        r#"
+        macro_rules! foo {
+            ($ op:tt, $j:path) => (
+                0
+            )
+        }
+"#,
+    )
+    // Test macro input without any spaces
+    // See https://github.com/rust-analyzer/rust-analyzer/issues/6692
+    .assert_expand_items("foo!(==,Foo::Bool)", "0");
+}
+
 #[test]
 fn test_underscore() {
     parse_macro(