diff options
Diffstat (limited to 'compiler/rustc_parse/src/parser/stmt.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/stmt.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 259bc06fabf..831edcd88c1 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -66,7 +66,7 @@ impl<'a> Parser<'a> { if self.token.is_keyword(kw::Mut) && self.is_keyword_ahead(1, &[kw::Let]) { self.bump(); let mut_let_span = lo.to(self.token.span); - self.sess.emit_err(errors::InvalidVariableDeclaration { + self.dcx().emit_err(errors::InvalidVariableDeclaration { span: mut_let_span, sub: errors::InvalidVariableDeclarationSub::SwitchMutLetOrder(mut_let_span), }); @@ -140,7 +140,7 @@ impl<'a> Parser<'a> { let bl = self.parse_block()?; // Destructuring assignment ... else. // This is not allowed, but point it out in a nice way. - self.sess.emit_err(errors::AssignmentElseNotAllowed { span: e.span.to(bl.span) }); + self.dcx().emit_err(errors::AssignmentElseNotAllowed { span: e.span.to(bl.span) }); } self.mk_stmt(lo.to(e.span), StmtKind::Expr(e)) } else { @@ -233,12 +233,12 @@ impl<'a> Parser<'a> { && let attrs @ [.., last] = &*attrs { if last.is_doc_comment() { - self.sess.emit_err(errors::DocCommentDoesNotDocumentAnything { + self.dcx().emit_err(errors::DocCommentDoesNotDocumentAnything { span: last.span, missing_comma: None, }); } else if attrs.iter().any(|a| a.style == AttrStyle::Outer) { - self.sess.emit_err(errors::ExpectedStatementAfterOuterAttr { span: last.span }); + self.dcx().emit_err(errors::ExpectedStatementAfterOuterAttr { span: last.span }); } } } @@ -258,7 +258,8 @@ impl<'a> Parser<'a> { TrailingToken::None, )) })?; - self.sess.emit_err(errors::InvalidVariableDeclaration { span: lo, sub: subdiagnostic(lo) }); + self.dcx() + .emit_err(errors::InvalidVariableDeclaration { span: lo, sub: subdiagnostic(lo) }); Ok(stmt) } @@ -286,7 +287,7 @@ impl<'a> Parser<'a> { let lo = self.prev_token.span; if self.token.is_keyword(kw::Const) && self.look_ahead(1, |t| t.is_ident()) { - self.sess.emit_err(errors::ConstLetMutuallyExclusive { span: lo.to(self.token.span) }); + self.dcx().emit_err(errors::ConstLetMutuallyExclusive { span: lo.to(self.token.span) }); self.bump(); } @@ -385,7 +386,7 @@ impl<'a> Parser<'a> { fn check_let_else_init_bool_expr(&self, init: &ast::Expr) { if let ast::ExprKind::Binary(op, ..) = init.kind { if op.node.is_lazy() { - self.sess.emit_err(errors::InvalidExpressionInLetElse { + self.dcx().emit_err(errors::InvalidExpressionInLetElse { span: init.span, operator: op.node.as_str(), sugg: errors::WrapExpressionInParentheses { @@ -399,7 +400,7 @@ impl<'a> Parser<'a> { fn check_let_else_init_trailing_brace(&self, init: &ast::Expr) { if let Some(trailing) = classify::expr_trailing_brace(init) { - self.sess.emit_err(errors::InvalidCurlyInLetElse { + self.dcx().emit_err(errors::InvalidCurlyInLetElse { span: trailing.span.with_lo(trailing.span.hi() - BytePos(1)), sugg: errors::WrapExpressionInParentheses { left: trailing.span.shrink_to_lo(), @@ -414,7 +415,7 @@ impl<'a> Parser<'a> { let eq_consumed = match self.token.kind { token::BinOpEq(..) => { // Recover `let x <op>= 1` as `let x = 1` - self.sess + self.dcx() .emit_err(errors::CompoundAssignmentExpressionInLet { span: self.token.span }); self.bump(); true @@ -698,7 +699,7 @@ impl<'a> Parser<'a> { match self.parse_expr_labeled(label, false) { Ok(labeled_expr) => { e.delay_as_bug(); - self.sess.emit_err(MalformedLoopLabel { + self.dcx().emit_err(MalformedLoopLabel { span: label.ident.span, correct_label: label.ident, }); |
