aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-12-20 15:30:36 +0000
committerGitHub <[email protected]>2019-12-20 15:30:36 +0000
commitcfc50ff160d0af2ce5cd931c6d41161abfdb2fbd (patch)
tree35a9048f1f6f7a7e948faf2f337dd7973ab3427b /crates/ra_ide/src
parentaf5e2abe15c2bf182b871e26a680507a51526176 (diff)
parent4a7e19946a60b4cba6ef9d9916ae0fbec65c74da (diff)
Merge #2615
2615: Fix wrong path parsing for macro call in pattern position r=edwin0cheng a=edwin0cheng The parser incorrectly insert a `PathPat` inside `MacroCall` syntax node when parsing inside a pattern position, for example : ```rust let foo!() = 0; ``` become: ``` MACRO_CALL@[60; 66) PATH_PAT@[60; 63) <------------- It should not exist PATH@[60; 63) PATH_SEGMENT@[60; 63) NAME_REF@[60; 63) IDENT@[60; 63) "foo" EXCL@[63; 64) "!" TOKEN_TREE@[64; 66) L_PAREN@[64; 65) "(" R_PAREN@[65; 66) ")" ``` This PR fix this bug and add some test to make sure goto-defintion works for macro inside pattern. Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/goto_definition.rs36
1 files changed, 36 insertions, 0 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(