Use maybe_whole!
to streamline parse_stmt_without_recovery
.
This commit is contained in:
parent
d4ad322b5d
commit
0de050bd6d
1 changed files with 5 additions and 11 deletions
|
@ -40,8 +40,8 @@ impl<'a> Parser<'a> {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If `force_collect` is [`ForceCollect::Yes`], forces collection of tokens regardless of whether
|
/// If `force_collect` is [`ForceCollect::Yes`], forces collection of tokens regardless of
|
||||||
/// or not we have attributes
|
/// whether or not we have attributes.
|
||||||
// Public for `cfg_eval` macro expansion.
|
// Public for `cfg_eval` macro expansion.
|
||||||
pub fn parse_stmt_without_recovery(
|
pub fn parse_stmt_without_recovery(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -51,18 +51,12 @@ impl<'a> Parser<'a> {
|
||||||
let attrs = self.parse_outer_attributes()?;
|
let attrs = self.parse_outer_attributes()?;
|
||||||
let lo = self.token.span;
|
let lo = self.token.span;
|
||||||
|
|
||||||
// Don't use `maybe_whole` so that we have precise control
|
maybe_whole!(self, NtStmt, |stmt| {
|
||||||
// over when we bump the parser
|
|
||||||
if let token::Interpolated(nt) = &self.token.kind
|
|
||||||
&& let token::NtStmt(stmt) = &nt.0
|
|
||||||
{
|
|
||||||
let mut stmt = stmt.clone();
|
|
||||||
self.bump();
|
|
||||||
stmt.visit_attrs(|stmt_attrs| {
|
stmt.visit_attrs(|stmt_attrs| {
|
||||||
attrs.prepend_to_nt_inner(stmt_attrs);
|
attrs.prepend_to_nt_inner(stmt_attrs);
|
||||||
});
|
});
|
||||||
return Ok(Some(stmt.into_inner()));
|
Some(stmt.into_inner())
|
||||||
}
|
});
|
||||||
|
|
||||||
if self.token.is_keyword(kw::Mut) && self.is_keyword_ahead(1, &[kw::Let]) {
|
if self.token.is_keyword(kw::Mut) && self.is_keyword_ahead(1, &[kw::Let]) {
|
||||||
self.bump();
|
self.bump();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue