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:
Nicholas Nethercote 2023-12-18 14:00:17 +11:00
parent cda4736f1e
commit cea683c08f
13 changed files with 109 additions and 130 deletions

View file

@ -5,7 +5,7 @@ use super::{AttrWrapper, Capturing, FnParseMode, ForceCollect, Parser, PathStyle
use rustc_ast as ast;
use rustc_ast::attr;
use rustc_ast::token::{self, Delimiter, Nonterminal};
use rustc_errors::{error_code, Diagnostic, IntoDiagnostic, PResult};
use rustc_errors::{error_code, Diagnostic, PResult};
use rustc_span::{sym, BytePos, Span};
use thin_vec::ThinVec;
use tracing::debug;
@ -416,8 +416,9 @@ impl<'a> Parser<'a> {
Err(err) => err.cancel(),
}
Err(InvalidMetaItem { span: self.token.span, token: self.token.clone() }
.into_diagnostic(self.dcx()))
Err(self
.dcx()
.create_err(InvalidMetaItem { span: self.token.span, token: self.token.clone() }))
}
}