From 4a7e19946a60b4cba6ef9d9916ae0fbec65c74da Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 20 Dec 2019 23:11:07 +0800 Subject: Fix parser for macro call in pattern position --- crates/ra_ide/src/goto_definition.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'crates/ra_ide') 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 @@ -424,6 +424,42 @@ mod tests { ); } + #[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); -- cgit v1.2.3