diff options
| author | Michael Goulet <michael@errs.io> | 2023-06-23 05:31:14 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-07-22 15:22:12 +0000 |
| commit | 7b962d754350dd7cc8d2729416cb36a7244b3dd0 (patch) | |
| tree | a3f983a7096035f1930251a97dd41b5d92d3f3f7 /compiler/rustc_parse/src/parser/expr.rs | |
| parent | 8164cdb9ee460eddcb8888b9b6f72836a956d110 (diff) | |
| download | rust-7b962d754350dd7cc8d2729416cb36a7244b3dd0.tar.gz rust-7b962d754350dd7cc8d2729416cb36a7244b3dd0.zip | |
Support interpolated block for try and async
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 3ecdbc36248..769415b614b 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -3003,7 +3003,8 @@ impl<'a> Parser<'a> { fn is_do_catch_block(&self) -> bool { self.token.is_keyword(kw::Do) && self.is_keyword_ahead(1, &[kw::Catch]) - && self.look_ahead(2, |t| *t == token::OpenDelim(Delimiter::Brace)) + && self + .look_ahead(2, |t| *t == token::OpenDelim(Delimiter::Brace) || t.is_whole_block()) && !self.restrictions.contains(Restrictions::NO_STRUCT_LITERAL) } @@ -3013,7 +3014,8 @@ impl<'a> Parser<'a> { fn is_try_block(&self) -> bool { self.token.is_keyword(kw::Try) - && self.look_ahead(1, |t| *t == token::OpenDelim(Delimiter::Brace)) + && self + .look_ahead(1, |t| *t == token::OpenDelim(Delimiter::Brace) || t.is_whole_block()) && self.token.uninterpolated_span().at_least_rust_2018() } @@ -3032,10 +3034,14 @@ impl<'a> Parser<'a> { && (( // `async move {` self.is_keyword_ahead(1, &[kw::Move]) - && self.look_ahead(2, |t| *t == token::OpenDelim(Delimiter::Brace)) + && self.look_ahead(2, |t| { + *t == token::OpenDelim(Delimiter::Brace) || t.is_whole_block() + }) ) || ( // `async {` - self.look_ahead(1, |t| *t == token::OpenDelim(Delimiter::Brace)) + self.look_ahead(1, |t| { + *t == token::OpenDelim(Delimiter::Brace) || t.is_whole_block() + }) )) } |
