]> git.lizzy.rs Git - rust.git/blobdiff - crates/ra_ide/src/goto_definition.rs
Fix parser for macro call in pattern position
[rust.git] / crates / ra_ide / src / goto_definition.rs
index 9b57447897ed445727562c49a87707121cc9a3fc..79d332e8cea6f4aa180596968fb321fcc854c349 100644 (file)
@@ -424,6 +424,42 @@ fn bar() {
         );
     }
 
+    #[test]
+    fn goto_definition_works_for_macro_inside_pattern() {
+        check_goto(
+            "
+            //- /lib.rs
+            macro_rules! foo {() => {0}}
+
+            fn bar() {
+                match (0,1) {
+                    (<|>foo!(), _) => {}
+                }
+            }
+            ",
+            "foo MACRO_CALL FileId(1) [0; 28) [13; 16)",
+            "macro_rules! foo {() => {0}}|foo",
+        );
+    }
+
+    #[test]
+    fn goto_definition_works_for_macro_inside_match_arm_lhs() {
+        check_goto(
+            "
+            //- /lib.rs
+            macro_rules! foo {() => {0}}
+
+            fn bar() {
+                match 0 {
+                    <|>foo!() => {}
+                }
+            }
+            ",
+            "foo MACRO_CALL FileId(1) [0; 28) [13; 16)",
+            "macro_rules! foo {() => {0}}|foo",
+        );
+    }
+
     #[test]
     fn goto_def_for_methods() {
         covers!(goto_def_for_methods);