aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/goto_definition.rs36
-rw-r--r--crates/ra_parser/src/grammar/patterns.rs2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.txt9
3 files changed, 41 insertions, 6 deletions
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs
index 9b5744789..79d332e8c 100644
--- a/crates/ra_ide/src/goto_definition.rs
+++ b/crates/ra_ide/src/goto_definition.rs
@@ -425,6 +425,42 @@ mod tests {
425 } 425 }
426 426
427 #[test] 427 #[test]
428 fn goto_definition_works_for_macro_inside_pattern() {
429 check_goto(
430 "
431 //- /lib.rs
432 macro_rules! foo {() => {0}}
433
434 fn bar() {
435 match (0,1) {
436 (<|>foo!(), _) => {}
437 }
438 }
439 ",
440 "foo MACRO_CALL FileId(1) [0; 28) [13; 16)",
441 "macro_rules! foo {() => {0}}|foo",
442 );
443 }
444
445 #[test]
446 fn goto_definition_works_for_macro_inside_match_arm_lhs() {
447 check_goto(
448 "
449 //- /lib.rs
450 macro_rules! foo {() => {0}}
451
452 fn bar() {
453 match 0 {
454 <|>foo!() => {}
455 }
456 }
457 ",
458 "foo MACRO_CALL FileId(1) [0; 28) [13; 16)",
459 "macro_rules! foo {() => {0}}|foo",
460 );
461 }
462
463 #[test]
428 fn goto_def_for_methods() { 464 fn goto_def_for_methods() {
429 covers!(goto_def_for_methods); 465 covers!(goto_def_for_methods);
430 check_goto( 466 check_goto(
diff --git a/crates/ra_parser/src/grammar/patterns.rs b/crates/ra_parser/src/grammar/patterns.rs
index f5d12278c..422a4e3dc 100644
--- a/crates/ra_parser/src/grammar/patterns.rs
+++ b/crates/ra_parser/src/grammar/patterns.rs
@@ -50,7 +50,7 @@ pub(super) fn pattern_r(p: &mut Parser, recovery_set: TokenSet) {
50 // let m!(x) = 0; 50 // let m!(x) = 0;
51 // } 51 // }
52 if lhs.kind() == PATH_PAT && p.at(T![!]) { 52 if lhs.kind() == PATH_PAT && p.at(T![!]) {
53 let m = lhs.precede(p); 53 let m = lhs.undo_completion(p);
54 items::macro_call_after_excl(p); 54 items::macro_call_after_excl(p);
55 m.complete(p, MACRO_CALL); 55 m.complete(p, MACRO_CALL);
56 } 56 }
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.txt
index 4a714ad6b..b05ccc0ed 100644
--- a/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.txt
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.txt
@@ -16,11 +16,10 @@ SOURCE_FILE@[0; 33)
16 LET_KW@[16; 19) "let" 16 LET_KW@[16; 19) "let"
17 WHITESPACE@[19; 20) " " 17 WHITESPACE@[19; 20) " "
18 MACRO_CALL@[20; 25) 18 MACRO_CALL@[20; 25)
19 PATH_PAT@[20; 21) 19 PATH@[20; 21)
20 PATH@[20; 21) 20 PATH_SEGMENT@[20; 21)
21 PATH_SEGMENT@[20; 21) 21 NAME_REF@[20; 21)
22 NAME_REF@[20; 21) 22 IDENT@[20; 21) "m"
23 IDENT@[20; 21) "m"
24 EXCL@[21; 22) "!" 23 EXCL@[21; 22) "!"
25 TOKEN_TREE@[22; 25) 24 TOKEN_TREE@[22; 25)
26 L_PAREN@[22; 23) "(" 25 L_PAREN@[22; 23) "("