Use .into_diagnostic()
less.
This commit replaces this pattern: ``` err.into_diagnostic(dcx) ``` with this pattern: ``` dcx.create_err(err) ``` in a lot of places. It's a little shorter, makes the error level explicit, avoids some `IntoDiagnostic` imports, and is a necessary prerequisite for the next commit which will add a `level` arg to `into_diagnostic`. This requires adding `track_caller` on `create_err` to avoid mucking up the output of `tests/ui/track-diagnostics/track4.rs`. It probably should have been there already.
This commit is contained in:
parent
cda4736f1e
commit
cea683c08f
13 changed files with 109 additions and 130 deletions
|
@ -18,7 +18,7 @@ use rustc_ast::{
|
|||
PatField, PatKind, Path, QSelf, RangeEnd, RangeSyntax,
|
||||
};
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic, PResult};
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder, ErrorGuaranteed, PResult};
|
||||
use rustc_session::errors::ExprParenthesesNeeded;
|
||||
use rustc_span::source_map::{respan, Spanned};
|
||||
use rustc_span::symbol::{kw, sym, Ident};
|
||||
|
@ -872,8 +872,9 @@ impl<'a> Parser<'a> {
|
|||
// binding mode then we do not end up here, because the lookahead
|
||||
// will direct us over to `parse_enum_variant()`.
|
||||
if self.token == token::OpenDelim(Delimiter::Parenthesis) {
|
||||
return Err(EnumPatternInsteadOfIdentifier { span: self.prev_token.span }
|
||||
.into_diagnostic(self.dcx()));
|
||||
return Err(self
|
||||
.dcx()
|
||||
.create_err(EnumPatternInsteadOfIdentifier { span: self.prev_token.span }));
|
||||
}
|
||||
|
||||
Ok(PatKind::Ident(binding_annotation, ident, sub))
|
||||
|
@ -986,8 +987,8 @@ impl<'a> Parser<'a> {
|
|||
|
||||
// check that a comma comes after every field
|
||||
if !ate_comma {
|
||||
let mut err = ExpectedCommaAfterPatternField { span: self.token.span }
|
||||
.into_diagnostic(self.dcx());
|
||||
let mut err =
|
||||
self.dcx().create_err(ExpectedCommaAfterPatternField { span: self.token.span });
|
||||
if let Some(mut delayed) = delayed_err {
|
||||
delayed.emit();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue