1
Fork 0

Rename DiagnosticBuilder as Diag.

Much better!

Note that this involves renaming (and updating the value of)
`DIAGNOSTIC_BUILDER` in clippy.
This commit is contained in:
Nicholas Nethercote 2024-02-23 10:20:45 +11:00
parent 4e1f9bd528
commit 899cb40809
153 changed files with 1136 additions and 1367 deletions

View file

@ -13,7 +13,7 @@ use rustc_ast::{self as ast, AttrVec, Attribute, HasAttrs, Item, NodeId, PatKind
use rustc_attr::{self as attr, Deprecation, Stability};
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::sync::{self, Lrc};
use rustc_errors::{Applicability, DiagCtxt, DiagnosticBuilder, ErrorGuaranteed, PResult};
use rustc_errors::{Applicability, Diag, DiagCtxt, ErrorGuaranteed, PResult};
use rustc_feature::Features;
use rustc_lint_defs::builtin::PROC_MACRO_BACK_COMPAT;
use rustc_lint_defs::{BufferedEarlyLint, BuiltinLintDiagnostics, RegisteredTools};
@ -1260,7 +1260,7 @@ pub fn expr_to_spanned_string<'a>(
err_msg: &'static str,
) -> Result<
(Symbol, ast::StrStyle, Span),
Result<(DiagnosticBuilder<'a>, bool /* has_suggestions */), ErrorGuaranteed>,
Result<(Diag<'a>, bool /* has_suggestions */), ErrorGuaranteed>,
> {
// Perform eager expansion on the expression.
// We want to be able to handle e.g., `concat!("foo", "bar")`.

View file

@ -7,7 +7,7 @@ use crate::mbe::{
use rustc_ast::token::{self, Token, TokenKind};
use rustc_ast::tokenstream::TokenStream;
use rustc_ast_pretty::pprust;
use rustc_errors::{Applicability, DiagCtxt, DiagnosticBuilder, DiagnosticMessage};
use rustc_errors::{Applicability, Diag, DiagCtxt, DiagnosticMessage};
use rustc_parse::parser::{Parser, Recovery};
use rustc_span::source_map::SourceMap;
use rustc_span::symbol::Ident;
@ -218,7 +218,7 @@ impl<'matcher> Tracker<'matcher> for FailureForwarder {
}
pub(super) fn emit_frag_parse_err(
mut e: DiagnosticBuilder<'_>,
mut e: Diag<'_>,
parser: &Parser<'_>,
orig_parser: &mut Parser<'_>,
site_span: Span,
@ -285,11 +285,7 @@ pub(super) fn emit_frag_parse_err(
e.emit()
}
pub(crate) fn annotate_err_with_kind(
err: &mut DiagnosticBuilder<'_>,
kind: AstFragmentKind,
span: Span,
) {
pub(crate) fn annotate_err_with_kind(err: &mut Diag<'_>, kind: AstFragmentKind, span: Span) {
match kind {
AstFragmentKind::Ty => {
err.span_label(span, "this macro call doesn't expand to a type");
@ -315,12 +311,7 @@ enum ExplainDocComment {
},
}
pub(super) fn annotate_doc_comment(
dcx: &DiagCtxt,
err: &mut DiagnosticBuilder<'_>,
sm: &SourceMap,
span: Span,
) {
pub(super) fn annotate_doc_comment(dcx: &DiagCtxt, err: &mut Diag<'_>, sm: &SourceMap, span: Span) {
if let Ok(src) = sm.span_to_snippet(span) {
if src.starts_with("///") || src.starts_with("/**") {
err.subdiagnostic(dcx, ExplainDocComment::Outer { span });

View file

@ -9,7 +9,7 @@ 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::Diag;
use rustc_errors::{pluralize, PResult};
use rustc_span::hygiene::{LocalExpnId, Transparency};
use rustc_span::symbol::{sym, Ident, MacroRulesNormalizedIdent};
@ -622,12 +622,7 @@ where
/// Used by meta-variable expressions when an user input is out of the actual declared bounds. For
/// example, index(999999) in an repetition of only three elements.
fn out_of_bounds_err<'a>(
cx: &ExtCtxt<'a>,
max: usize,
span: Span,
ty: &str,
) -> DiagnosticBuilder<'a> {
fn out_of_bounds_err<'a>(cx: &ExtCtxt<'a>, max: usize, span: Span, ty: &str) -> Diag<'a> {
let msg = if max == 0 {
format!(
"meta-variable expression `{ty}` with depth parameter \

View file

@ -4,7 +4,7 @@ use crate::errors::{
};
use rustc_ast::ptr::P;
use rustc_ast::{token, AttrVec, Attribute, Inline, Item, ModSpans};
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
use rustc_errors::{Diag, ErrorGuaranteed};
use rustc_parse::new_parser_from_file;
use rustc_parse::validate_attr;
use rustc_session::parse::ParseSess;
@ -43,7 +43,7 @@ pub enum ModError<'a> {
ModInBlock(Option<Ident>),
FileNotFound(Ident, PathBuf, PathBuf),
MultipleCandidates(Ident, PathBuf, PathBuf),
ParserError(DiagnosticBuilder<'a>),
ParserError(Diag<'a>),
}
pub(crate) fn parse_external_mod(

View file

@ -11,7 +11,7 @@ use rustc_ast::util::literal::escape_byte_str_symbol;
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::Lrc;
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed, MultiSpan, PResult};
use rustc_errors::{Diag, ErrorGuaranteed, MultiSpan, PResult};
use rustc_parse::lexer::nfc_normalize;
use rustc_parse::parse_stream_from_source_str;
use rustc_session::parse::ParseSess;
@ -513,8 +513,8 @@ impl server::FreeFunctions for Rustc<'_, '_> {
fn emit_diagnostic(&mut self, diagnostic: Diagnostic<Self::Span>) {
let message = rustc_errors::DiagnosticMessage::from(diagnostic.message);
let mut diag: DiagnosticBuilder<'_, ()> =
DiagnosticBuilder::new(&self.sess().dcx, diagnostic.level.to_internal(), message);
let mut diag: Diag<'_, ()> =
Diag::new(&self.sess().dcx, diagnostic.level.to_internal(), message);
diag.span(MultiSpan::from_spans(diagnostic.spans));
for child in diagnostic.children {
diag.sub(child.level.to_internal(), child.message, MultiSpan::from_spans(child.spans));