diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-02-23 10:20:45 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-02-28 08:55:35 +1100 |
| commit | 899cb40809a85eb9d89f6da3268713b83175360a (patch) | |
| tree | e4c9a526f3eeb5d8563bfe254f1507648fddede2 /compiler/rustc_expand/src | |
| parent | 4e1f9bd528aef7215bb3b446fcdf43368371da37 (diff) | |
| download | rust-899cb40809a85eb9d89f6da3268713b83175360a.tar.gz rust-899cb40809a85eb9d89f6da3268713b83175360a.zip | |
Rename `DiagnosticBuilder` as `Diag`.
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
Diffstat (limited to 'compiler/rustc_expand/src')
| -rw-r--r-- | compiler/rustc_expand/src/base.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_expand/src/mbe/diagnostics.rs | 17 | ||||
| -rw-r--r-- | compiler/rustc_expand/src/mbe/transcribe.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_expand/src/module.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_expand/src/proc_macro_server.rs | 6 |
5 files changed, 13 insertions, 27 deletions
diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 7ece46523db..485f0e7e46d 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -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")`. diff --git a/compiler/rustc_expand/src/mbe/diagnostics.rs b/compiler/rustc_expand/src/mbe/diagnostics.rs index 5629c5ef5fa..053063b690e 100644 --- a/compiler/rustc_expand/src/mbe/diagnostics.rs +++ b/compiler/rustc_expand/src/mbe/diagnostics.rs @@ -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 }); diff --git a/compiler/rustc_expand/src/mbe/transcribe.rs b/compiler/rustc_expand/src/mbe/transcribe.rs index 4a18055d4ca..8fcd468e34b 100644 --- a/compiler/rustc_expand/src/mbe/transcribe.rs +++ b/compiler/rustc_expand/src/mbe/transcribe.rs @@ -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 \ diff --git a/compiler/rustc_expand/src/module.rs b/compiler/rustc_expand/src/module.rs index e979f9a75d4..1282cf2c03a 100644 --- a/compiler/rustc_expand/src/module.rs +++ b/compiler/rustc_expand/src/module.rs @@ -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( diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index 87ea8690ffe..6fe0d611363 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -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)); |
