parser::path: remove .fatal calls
This commit is contained in:
parent
51fb599849
commit
6fba125912
3 changed files with 15 additions and 10 deletions
|
@ -1450,9 +1450,7 @@ impl<'a> Parser<'a> {
|
|||
self.struct_span_err(sp, "missing condition for `if` expression")
|
||||
.span_label(sp, "expected if condition here")
|
||||
.emit();
|
||||
let expr = self.mk_expr_err(span);
|
||||
let stmt = self.mk_stmt(span, ast::StmtKind::Expr(expr));
|
||||
self.mk_block(vec![stmt], BlockCheckMode::Default, span)
|
||||
self.mk_block_err(span)
|
||||
}
|
||||
|
||||
/// Parses the condition of a `if` or `while` expression.
|
||||
|
|
|
@ -406,9 +406,11 @@ impl<'a> Parser<'a> {
|
|||
if self.token.is_bool_lit() {
|
||||
self.parse_literal_maybe_minus()?
|
||||
} else {
|
||||
return Err(
|
||||
self.fatal("identifiers may currently not be used for const generics")
|
||||
);
|
||||
let span = self.token.span;
|
||||
let msg = "identifiers may currently not be used for const generics";
|
||||
self.struct_span_err(span, msg).emit();
|
||||
let block = self.mk_block_err(span);
|
||||
self.mk_expr(span, ast::ExprKind::Block(block, None), ast::AttrVec::new())
|
||||
}
|
||||
} else {
|
||||
self.parse_literal_maybe_minus()?
|
||||
|
|
|
@ -398,10 +398,7 @@ impl<'a> Parser<'a> {
|
|||
self.maybe_annotate_with_ascription(&mut err, false);
|
||||
err.emit();
|
||||
self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore);
|
||||
Some(self.mk_stmt(
|
||||
self.token.span,
|
||||
StmtKind::Expr(self.mk_expr_err(self.token.span)),
|
||||
))
|
||||
Some(self.mk_stmt_err(self.token.span))
|
||||
}
|
||||
Ok(stmt) => stmt,
|
||||
};
|
||||
|
@ -479,4 +476,12 @@ impl<'a> Parser<'a> {
|
|||
pub(super) fn mk_stmt(&self, span: Span, kind: StmtKind) -> Stmt {
|
||||
Stmt { id: DUMMY_NODE_ID, kind, span }
|
||||
}
|
||||
|
||||
fn mk_stmt_err(&self, span: Span) -> Stmt {
|
||||
self.mk_stmt(span, StmtKind::Expr(self.mk_expr_err(span)))
|
||||
}
|
||||
|
||||
pub(super) fn mk_block_err(&self, span: Span) -> P<Block> {
|
||||
self.mk_block(vec![self.mk_stmt_err(span)], BlockCheckMode::Default, span)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue