Skip to content

Commit 0de050b

Browse files
committed
Use maybe_whole! to streamline parse_stmt_without_recovery.
1 parent d4ad322 commit 0de050b

File tree

1 file changed

+5
-11
lines changed
  • compiler/rustc_parse/src/parser

1 file changed

+5
-11
lines changed

compiler/rustc_parse/src/parser/stmt.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ impl<'a> Parser<'a> {
4040
}))
4141
}
4242

43-
/// If `force_collect` is [`ForceCollect::Yes`], forces collection of tokens regardless of whether
44-
/// or not we have attributes
43+
/// If `force_collect` is [`ForceCollect::Yes`], forces collection of tokens regardless of
44+
/// whether or not we have attributes.
4545
// Public for `cfg_eval` macro expansion.
4646
pub fn parse_stmt_without_recovery(
4747
&mut self,
@@ -51,18 +51,12 @@ impl<'a> Parser<'a> {
5151
let attrs = self.parse_outer_attributes()?;
5252
let lo = self.token.span;
5353

54-
// Don't use `maybe_whole` so that we have precise control
55-
// over when we bump the parser
56-
if let token::Interpolated(nt) = &self.token.kind
57-
&& let token::NtStmt(stmt) = &nt.0
58-
{
59-
let mut stmt = stmt.clone();
60-
self.bump();
54+
maybe_whole!(self, NtStmt, |stmt| {
6155
stmt.visit_attrs(|stmt_attrs| {
6256
attrs.prepend_to_nt_inner(stmt_attrs);
6357
});
64-
return Ok(Some(stmt.into_inner()));
65-
}
58+
Some(stmt.into_inner())
59+
});
6660

6761
if self.token.is_keyword(kw::Mut) && self.is_keyword_ahead(1, &[kw::Let]) {
6862
self.bump();

0 commit comments

Comments
 (0)