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 /src/librustdoc | |
| 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 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/doctest.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/html/markdown.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/passes/collect_intra_doc_links.rs | 37 | ||||
| -rw-r--r-- | src/librustdoc/passes/lint/unescaped_backticks.rs | 4 |
4 files changed, 24 insertions, 25 deletions
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index caad56146a7..e2b4ec5908b 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -643,8 +643,8 @@ pub(crate) fn make_test( // Reset errors so that they won't be reported as compiler bugs when dropping the // dcx. Any errors in the tests will be reported when the test file is compiled, - // Note that we still need to cancel the errors above otherwise `DiagnosticBuilder` - // will panic on drop. + // Note that we still need to cancel the errors above otherwise `Diag` will panic on + // drop. sess.dcx.reset_err_count(); (found_main, found_extern_crate, found_macro) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 21f682d15b9..e8b250648bc 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -27,7 +27,7 @@ //! ``` use rustc_data_structures::fx::FxHashMap; -use rustc_errors::{DiagnosticBuilder, DiagnosticMessage}; +use rustc_errors::{Diag, DiagnosticMessage}; use rustc_hir::def_id::DefId; use rustc_middle::ty::TyCtxt; pub(crate) use rustc_resolve::rustdoc::main_body_opts; @@ -843,7 +843,7 @@ impl<'tcx> ExtraInfo<'tcx> { fn error_invalid_codeblock_attr_with_help( &self, msg: impl Into<DiagnosticMessage>, - f: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), + f: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), ) { if let Some(def_id) = self.def_id.as_local() { self.tcx.node_span_lint( diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index a172580ac3f..33bdbbe1b94 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -8,7 +8,7 @@ use rustc_data_structures::{ fx::{FxHashMap, FxHashSet}, intern::Interned, }; -use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticMessage}; +use rustc_errors::{Applicability, Diag, DiagnosticMessage}; use rustc_hir::def::Namespace::*; use rustc_hir::def::{DefKind, Namespace, PerNS}; use rustc_hir::def_id::{DefId, CRATE_DEF_ID}; @@ -1173,22 +1173,21 @@ impl LinkCollector<'_, '_> { ) { // The resolved item did not match the disambiguator; give a better error than 'not found' let msg = format!("incompatible link kind for `{path_str}`"); - let callback = - |diag: &mut DiagnosticBuilder<'_, ()>, sp: Option<rustc_span::Span>, link_range| { - let note = format!( - "this link resolved to {} {}, which is not {} {}", - resolved.article(), - resolved.descr(), - specified.article(), - specified.descr(), - ); - if let Some(sp) = sp { - diag.span_label(sp, note); - } else { - diag.note(note); - } - suggest_disambiguator(resolved, diag, path_str, link_range, sp, diag_info); - }; + let callback = |diag: &mut Diag<'_, ()>, sp: Option<rustc_span::Span>, link_range| { + let note = format!( + "this link resolved to {} {}, which is not {} {}", + resolved.article(), + resolved.descr(), + specified.article(), + specified.descr(), + ); + if let Some(sp) = sp { + diag.span_label(sp, note); + } else { + diag.note(note); + } + suggest_disambiguator(resolved, diag, path_str, link_range, sp, diag_info); + }; report_diagnostic(self.cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, diag_info, callback); } @@ -1677,7 +1676,7 @@ fn report_diagnostic( lint: &'static Lint, msg: impl Into<DiagnosticMessage> + Display, DiagnosticInfo { item, ori_link: _, dox, link_range }: &DiagnosticInfo<'_>, - decorate: impl FnOnce(&mut DiagnosticBuilder<'_, ()>, Option<rustc_span::Span>, MarkdownLinkRange), + decorate: impl FnOnce(&mut Diag<'_, ()>, Option<rustc_span::Span>, MarkdownLinkRange), ) { let Some(hir_id) = DocContext::as_local_hir_id(tcx, item.item_id) else { // If non-local, no need to check anything. @@ -2125,7 +2124,7 @@ fn ambiguity_error( /// disambiguator. fn suggest_disambiguator( res: Res, - diag: &mut DiagnosticBuilder<'_, ()>, + diag: &mut Diag<'_, ()>, path_str: &str, link_range: MarkdownLinkRange, sp: Option<rustc_span::Span>, diff --git a/src/librustdoc/passes/lint/unescaped_backticks.rs b/src/librustdoc/passes/lint/unescaped_backticks.rs index dbbf39362e3..4ea926cb79a 100644 --- a/src/librustdoc/passes/lint/unescaped_backticks.rs +++ b/src/librustdoc/passes/lint/unescaped_backticks.rs @@ -4,7 +4,7 @@ use crate::clean::Item; use crate::core::DocContext; use crate::html::markdown::main_body_opts; use pulldown_cmark::{BrokenLink, Event, Parser}; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_lint_defs::Applicability; use rustc_resolve::rustdoc::source_span_for_markdown_range; use std::ops::Range; @@ -368,7 +368,7 @@ fn suggest_insertion( cx: &DocContext<'_>, item: &Item, dox: &str, - lint: &mut DiagnosticBuilder<'_, ()>, + lint: &mut Diag<'_, ()>, insert_index: usize, suggestion: char, message: &'static str, |
