Moved is_try check into try_macro_suggestion
This commit is contained in:
parent
ba61fe432a
commit
d3f5c274c6
@ -1055,10 +1055,11 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
|
||||
pub(super) fn try_macro_suggestion(&mut self) -> DiagnosticBuilder<'a> {
|
||||
let is_try = self.token.is_keyword(kw::Try);
|
||||
let is_questionmark = self.look_ahead(1, |t| t == &token::Not); //check for !
|
||||
let is_open = self.look_ahead(2, |t| t == &token::OpenDelim(token::Paren)); //check for (
|
||||
|
||||
if is_questionmark && is_open {
|
||||
if is_try && is_questionmark && is_open {
|
||||
let lo = self.token.span;
|
||||
self.bump(); //remove try
|
||||
self.bump(); //remove !
|
||||
|
@ -1001,14 +1001,12 @@ impl<'a> Parser<'a> {
|
||||
|
||||
fn parse_lit_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
|
||||
let lo = self.token.span;
|
||||
let is_try = self.token.is_keyword(kw::Try);
|
||||
match self.parse_opt_lit() {
|
||||
Some(literal) => {
|
||||
let expr = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Lit(literal), attrs);
|
||||
self.maybe_recover_from_bad_qpath(expr, true)
|
||||
}
|
||||
None if is_try => Err(self.try_macro_suggestion()),
|
||||
None => Err(self.expected_expression_found()),
|
||||
None => Err(self.try_macro_suggestion()),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user