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:
parent
4e1f9bd528
commit
899cb40809
153 changed files with 1136 additions and 1367 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue