aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_parser/src/grammar/expressions/atom.rs16
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rast35
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rs1
3 files changed, 52 insertions, 0 deletions
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs
index 0d277a586..166dfc472 100644
--- a/crates/ra_parser/src/grammar/expressions/atom.rs
+++ b/crates/ra_parser/src/grammar/expressions/atom.rs
@@ -535,6 +535,22 @@ fn break_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker {
535fn try_block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { 535fn try_block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
536 assert!(p.at(T![try])); 536 assert!(p.at(T![try]));
537 let m = m.unwrap_or_else(|| p.start()); 537 let m = m.unwrap_or_else(|| p.start());
538 // Special-case `try!` as macro.
539 // This is a hack until we do proper edition support
540 if p.nth_at(1, T![!]) {
541 // test try_macro_fallback
542 // fn foo() { try!(Ok(())); }
543 let path = p.start();
544 let path_segment = p.start();
545 let name_ref = p.start();
546 p.bump_remap(IDENT);
547 name_ref.complete(p, NAME_REF);
548 path_segment.complete(p, PATH_SEGMENT);
549 path.complete(p, PATH);
550 let _block_like = items::macro_call_after_excl(p);
551 return m.complete(p, MACRO_CALL);
552 }
553
538 p.bump(T![try]); 554 p.bump(T![try]);
539 block(p); 555 block(p);
540 m.complete(p, TRY_EXPR) 556 m.complete(p, TRY_EXPR)
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rast b/crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rast
new file mode 100644
index 000000000..beb6d8010
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rast
@@ -0,0 +1,35 @@
1[email protected]
2 [email protected]
3 [email protected] "fn"
4 [email protected] " "
5 [email protected]
6 [email protected] "foo"
7 [email protected]
8 [email protected] "("
9 [email protected] ")"
10 [email protected] " "
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] "try"
21 [email protected] "!"
22 [email protected]
23 [email protected] "("
24 [email protected] "Ok"
25 [email protected]
26 [email protected] "("
27 [email protected]
28 [email protected] "("
29 [email protected] ")"
30 [email protected] ")"
31 [email protected] ")"
32 [email protected] ";"
33 [email protected] " "
34 [email protected] "}"
35 [email protected] "\n"
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rs b/crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rs
new file mode 100644
index 000000000..61a6b46a0
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rs
@@ -0,0 +1 @@
fn foo() { try!(Ok(())); }