diff options
Diffstat (limited to 'crates/ra_parser/src')
-rw-r--r-- | crates/ra_parser/src/grammar/expressions/atom.rs | 22 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/items.rs | 11 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/items/use_item.rs | 2 | ||||
-rw-r--r-- | crates/ra_parser/src/syntax_kind/generated.rs | 1 |
4 files changed, 31 insertions, 5 deletions
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index 0d277a586..76aa601cb 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs | |||
@@ -84,7 +84,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar | |||
84 | T![box] => box_expr(p, None), | 84 | T![box] => box_expr(p, None), |
85 | T![for] => for_expr(p, None), | 85 | T![for] => for_expr(p, None), |
86 | T![while] => while_expr(p, None), | 86 | T![while] => while_expr(p, None), |
87 | T![try] => try_block_expr(p, None), | 87 | T![try] => try_expr(p, None), |
88 | LIFETIME if la == T![:] => { | 88 | LIFETIME if la == T![:] => { |
89 | let m = p.start(); | 89 | let m = p.start(); |
90 | label(p); | 90 | label(p); |
@@ -134,7 +134,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar | |||
134 | } | 134 | } |
135 | }; | 135 | }; |
136 | let blocklike = match done.kind() { | 136 | let blocklike = match done.kind() { |
137 | IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR | BLOCK_EXPR | TRY_BLOCK_EXPR => { | 137 | IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR | BLOCK_EXPR | TRY_EXPR => { |
138 | BlockLike::Block | 138 | BlockLike::Block |
139 | } | 139 | } |
140 | _ => BlockLike::NotBlock, | 140 | _ => BlockLike::NotBlock, |
@@ -532,9 +532,25 @@ fn break_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker { | |||
532 | // fn foo() { | 532 | // fn foo() { |
533 | // let _ = try {}; | 533 | // let _ = try {}; |
534 | // } | 534 | // } |
535 | fn try_block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { | 535 | fn try_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_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_parser/src/grammar/items/use_item.rs b/crates/ra_parser/src/grammar/items/use_item.rs index e3b991c8c..3a0c7a31a 100644 --- a/crates/ra_parser/src/grammar/items/use_item.rs +++ b/crates/ra_parser/src/grammar/items/use_item.rs | |||
@@ -47,7 +47,7 @@ fn use_tree(p: &mut Parser, top_level: bool) { | |||
47 | // use {crate::path::from::root, or::path::from::crate_name}; // Rust 2018 (with a crate named `or`) | 47 | // use {crate::path::from::root, or::path::from::crate_name}; // Rust 2018 (with a crate named `or`) |
48 | // use {path::from::root}; // Rust 2015 | 48 | // use {path::from::root}; // Rust 2015 |
49 | // use ::{some::arbritrary::path}; // Rust 2015 | 49 | // use ::{some::arbritrary::path}; // Rust 2015 |
50 | // use ::{{{crate::export}}}; // Nonsensical but perfectly legal nestnig | 50 | // use ::{{{root::export}}}; // Nonsensical but perfectly legal nesting |
51 | T!['{'] => { | 51 | T!['{'] => { |
52 | use_tree_list(p); | 52 | use_tree_list(p); |
53 | } | 53 | } |
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs index 524e7d784..ab727ed7e 100644 --- a/crates/ra_parser/src/syntax_kind/generated.rs +++ b/crates/ra_parser/src/syntax_kind/generated.rs | |||
@@ -191,7 +191,6 @@ pub enum SyntaxKind { | |||
191 | RECORD_LIT, | 191 | RECORD_LIT, |
192 | RECORD_FIELD_LIST, | 192 | RECORD_FIELD_LIST, |
193 | RECORD_FIELD, | 193 | RECORD_FIELD, |
194 | TRY_BLOCK_EXPR, | ||
195 | BOX_EXPR, | 194 | BOX_EXPR, |
196 | CALL_EXPR, | 195 | CALL_EXPR, |
197 | INDEX_EXPR, | 196 | INDEX_EXPR, |