Give DiagnosticBuilder
a default type.
`IntoDiagnostic` defaults to `ErrorGuaranteed`, because errors are the most common diagnostic level. It makes sense to do likewise for the closely-related (and much more widely used) `DiagnosticBuilder` type, letting us write `DiagnosticBuilder<'a, ErrorGuaranteed>` as just `DiagnosticBuilder<'a>`. This cuts over 200 lines of code due to many multi-line things becoming single line things.
This commit is contained in:
parent
6257f3bf1f
commit
757d6f6ef8
59 changed files with 250 additions and 454 deletions
|
@ -1118,15 +1118,12 @@ impl<'a> ExtCtxt<'a> {
|
|||
&self,
|
||||
sp: S,
|
||||
msg: impl Into<DiagnosticMessage>,
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
) -> DiagnosticBuilder<'a> {
|
||||
self.sess.dcx().struct_span_err(sp, msg)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn create_err(
|
||||
&self,
|
||||
err: impl IntoDiagnostic<'a>,
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
pub fn create_err(&self, err: impl IntoDiagnostic<'a>) -> DiagnosticBuilder<'a> {
|
||||
self.sess.create_err(err)
|
||||
}
|
||||
|
||||
|
@ -1230,7 +1227,7 @@ pub fn expr_to_spanned_string<'a>(
|
|||
cx: &'a mut ExtCtxt<'_>,
|
||||
expr: P<ast::Expr>,
|
||||
err_msg: &'static str,
|
||||
) -> Result<(Symbol, ast::StrStyle, Span), Option<(DiagnosticBuilder<'a, ErrorGuaranteed>, bool)>> {
|
||||
) -> Result<(Symbol, ast::StrStyle, Span), Option<(DiagnosticBuilder<'a>, bool)>> {
|
||||
// Perform eager expansion on the expression.
|
||||
// We want to be able to handle e.g., `concat!("foo", "bar")`.
|
||||
let expr = cx.expander().fully_expand_fragment(AstFragment::Expr(expr)).make_expr();
|
||||
|
|
|
@ -215,7 +215,7 @@ impl<'matcher> Tracker<'matcher> for FailureForwarder {
|
|||
}
|
||||
|
||||
pub(super) fn emit_frag_parse_err(
|
||||
mut e: DiagnosticBuilder<'_, rustc_errors::ErrorGuaranteed>,
|
||||
mut e: DiagnosticBuilder<'_>,
|
||||
parser: &Parser<'_>,
|
||||
orig_parser: &mut Parser<'_>,
|
||||
site_span: Span,
|
||||
|
|
|
@ -9,8 +9,8 @@ use rustc_ast::mut_visit::{self, MutVisitor};
|
|||
use rustc_ast::token::{self, Delimiter, Token, TokenKind};
|
||||
use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_errors::{pluralize, PResult};
|
||||
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
|
||||
use rustc_span::hygiene::{LocalExpnId, Transparency};
|
||||
use rustc_span::symbol::{sym, Ident, MacroRulesNormalizedIdent};
|
||||
use rustc_span::Span;
|
||||
|
@ -528,7 +528,7 @@ fn out_of_bounds_err<'a>(
|
|||
max: usize,
|
||||
span: Span,
|
||||
ty: &str,
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
) -> DiagnosticBuilder<'a> {
|
||||
let msg = if max == 0 {
|
||||
format!(
|
||||
"meta-variable expression `{ty}` with depth parameter \
|
||||
|
|
|
@ -43,7 +43,7 @@ pub enum ModError<'a> {
|
|||
ModInBlock(Option<Ident>),
|
||||
FileNotFound(Ident, PathBuf, PathBuf),
|
||||
MultipleCandidates(Ident, PathBuf, PathBuf),
|
||||
ParserError(DiagnosticBuilder<'a, ErrorGuaranteed>),
|
||||
ParserError(DiagnosticBuilder<'a>),
|
||||
}
|
||||
|
||||
pub(crate) fn parse_external_mod(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue