aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-04-30 18:11:18 +0100
committerGitHub <[email protected]>2020-04-30 18:11:18 +0100
commit861652ffa6b6440a022a353d2e6b9f5ca780d2ec (patch)
tree7fabe31609082ce2f4c4ccdc9cae43caf5e3b654 /crates
parent972afffded3957c3891116a9a81ac9b049e28ad4 (diff)
parent45c4f620b1c5b8e462875b6e372db0e849bd6170 (diff)
Merge #4225
4225: Special-case try macro_rules r=matklad a=edwin0cheng Similar to #4221, but for `macro_rules! try {}` Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_parser/src/grammar/items.rs11
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rast27
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rs1
3 files changed, 39 insertions, 0 deletions
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs
index 433ed6812..1503a8730 100644
--- a/crates/ra_parser/src/grammar/items.rs
+++ b/crates/ra_parser/src/grammar/items.rs
@@ -415,6 +415,17 @@ pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike {
415 if p.at(IDENT) { 415 if p.at(IDENT) {
416 name(p); 416 name(p);
417 } 417 }
418 // Special-case `macro_rules! try`.
419 // This is a hack until we do proper edition support
420
421 // test try_macro_rules
422 // macro_rules! try { () => {} }
423 if p.at(T![try]) {
424 let m = p.start();
425 p.bump_remap(IDENT);
426 m.complete(p, NAME);
427 }
428
418 match p.current() { 429 match p.current() {
419 T!['{'] => { 430 T!['{'] => {
420 token_tree(p); 431 token_tree(p);
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rast b/crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rast
new file mode 100644
index 000000000..05b89d1c3
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rast
@@ -0,0 +1,27 @@
1[email protected]
2 [email protected]
3 [email protected]
4 [email protected]
5 [email protected]
6 [email protected] "macro_rules"
7 [email protected] "!"
8 [email protected] " "
9 [email protected]
10 [email protected] "try"
11 [email protected] " "
12 [email protected]
13 [email protected] "{"
14 [email protected] " "
15 [email protected]
16 [email protected] "("
17 [email protected] ")"
18 [email protected] " "
19 [email protected] "="
20 [email protected] ">"
21 [email protected] " "
22 [email protected]
23 [email protected] "{"
24 [email protected] "}"
25 [email protected] " "
26 [email protected] "}"
27 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rs b/crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rs
new file mode 100644
index 000000000..2e2ab6e60
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rs
@@ -0,0 +1 @@
macro_rules! try { () => {} }