Skip to content

Commit e3b8b52

Browse files
committed
Auto merge of rust-lang#121489 - nnethercote:diag-renaming, r=davidtwco
Diagnostic renaming Renaming various diagnostic types from `Diagnostic*` to `Diag*`. Part of rust-lang/compiler-team#722. There are more to do but this is enough for one PR. r? `@davidtwco`
2 parents 7a7224e + 2a2b0b7 commit e3b8b52

15 files changed

+34
-34
lines changed

clippy_lints/src/casts/cast_possible_truncation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::expr_or_init;
44
use clippy_utils::source::snippet;
55
use clippy_utils::sugg::Sugg;
66
use clippy_utils::ty::{get_discriminant_value, is_isize_or_usize};
7-
use rustc_errors::{Applicability, DiagnosticBuilder, SuggestionStyle};
7+
use rustc_errors::{Applicability, Diag, SuggestionStyle};
88
use rustc_hir::def::{DefKind, Res};
99
use rustc_hir::{BinOpKind, Expr, ExprKind};
1010
use rustc_lint::LateContext;
@@ -176,7 +176,7 @@ fn offer_suggestion(
176176
expr: &Expr<'_>,
177177
cast_expr: &Expr<'_>,
178178
cast_to_span: Span,
179-
diag: &mut DiagnosticBuilder<'_, ()>,
179+
diag: &mut Diag<'_, ()>,
180180
) {
181181
let cast_to_snip = snippet(cx, cast_to_span, "..");
182182
let suggestion = if cast_to_snip == "_" {

clippy_lints/src/disallowed_macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clippy_utils::diagnostics::{span_lint_and_then, span_lint_hir_and_then};
33
use clippy_utils::macros::macro_backtrace;
44
use rustc_ast::Attribute;
55
use rustc_data_structures::fx::FxHashSet;
6-
use rustc_errors::DiagnosticBuilder;
6+
use rustc_errors::Diag;
77
use rustc_hir::def_id::DefIdMap;
88
use rustc_hir::{
99
Expr, ExprKind, ForeignItem, HirId, ImplItem, Item, ItemKind, OwnerId, Pat, Path, Stmt, TraitItem, Ty,
@@ -89,7 +89,7 @@ impl DisallowedMacros {
8989
if let Some(&index) = self.disallowed.get(&mac.def_id) {
9090
let conf = &self.conf_disallowed[index];
9191
let msg = format!("use of a disallowed macro `{}`", conf.path());
92-
let add_note = |diag: &mut DiagnosticBuilder<'_, _>| {
92+
let add_note = |diag: &mut Diag<'_, _>| {
9393
if let Some(reason) = conf.reason() {
9494
diag.note(reason);
9595
}

clippy_lints/src/doc/needless_doctest_main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use clippy_utils::diagnostics::span_lint;
66
use rustc_ast::{CoroutineKind, Fn, FnRetTy, Item, ItemKind};
77
use rustc_data_structures::sync::Lrc;
88
use rustc_errors::emitter::HumanEmitter;
9-
use rustc_errors::{DiagCtxt, DiagnosticBuilder};
9+
use rustc_errors::{Diag, DiagCtxt};
1010
use rustc_lint::LateContext;
1111
use rustc_parse::maybe_new_parser_from_source_str;
1212
use rustc_parse::parser::ForceCollect;
@@ -53,7 +53,7 @@ pub fn check(
5353
let mut parser = match maybe_new_parser_from_source_str(&sess, filename, code) {
5454
Ok(p) => p,
5555
Err(errs) => {
56-
errs.into_iter().for_each(DiagnosticBuilder::cancel);
56+
errs.into_iter().for_each(Diag::cancel);
5757
return (false, test_attr_spans);
5858
},
5959
};

clippy_lints/src/functions/result.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_errors::DiagnosticBuilder;
1+
use rustc_errors::Diag;
22
use rustc_hir as hir;
33
use rustc_lint::{LateContext, LintContext};
44
use rustc_middle::lint::in_external_macro;
@@ -135,7 +135,7 @@ fn check_result_large_err<'tcx>(cx: &LateContext<'tcx>, err_ty: Ty<'tcx>, hir_ty
135135
RESULT_LARGE_ERR,
136136
hir_ty_span,
137137
"the `Err`-variant returned from this function is very large",
138-
|diag: &mut DiagnosticBuilder<'_, ()>| {
138+
|diag: &mut Diag<'_, ()>| {
139139
diag.span_label(hir_ty_span, format!("the `Err`-variant is at least {ty_size} bytes"));
140140
diag.help(format!("try reducing the size of `{err_ty}`, for example by boxing large elements or replacing it with `Box<{err_ty}>`"));
141141
},

clippy_lints/src/if_let_mutex.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint_and_then;
22
use clippy_utils::ty::is_type_diagnostic_item;
33
use clippy_utils::{higher, SpanlessEq};
4-
use rustc_errors::DiagnosticBuilder;
4+
use rustc_errors::Diag;
55
use rustc_hir::intravisit::{self as visit, Visitor};
66
use rustc_hir::{Expr, ExprKind};
77
use rustc_lint::{LateContext, LateLintPass};
@@ -59,7 +59,7 @@ impl<'tcx> LateLintPass<'tcx> for IfLetMutex {
5959
arm_visit.visit_expr(if_else);
6060

6161
if let Some(arm_mutex) = arm_visit.found_mutex_if_same_as(op_mutex) {
62-
let diag = |diag: &mut DiagnosticBuilder<'_, ()>| {
62+
let diag = |diag: &mut Diag<'_, ()>| {
6363
diag.span_label(
6464
op_mutex.span,
6565
"this Mutex will remain locked for the entire `if let`-block...",

clippy_lints/src/implicit_hasher.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::borrow::Cow;
22
use std::collections::BTreeMap;
33

4-
use rustc_errors::DiagnosticBuilder;
4+
use rustc_errors::Diag;
55
use rustc_hir as hir;
66
use rustc_hir::intravisit::{walk_body, walk_expr, walk_inf, walk_ty, Visitor};
77
use rustc_hir::{Body, Expr, ExprKind, GenericArg, Item, ItemKind, QPath, TyKind};
@@ -65,7 +65,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
6565

6666
fn suggestion(
6767
cx: &LateContext<'_>,
68-
diag: &mut DiagnosticBuilder<'_, ()>,
68+
diag: &mut Diag<'_, ()>,
6969
generics_span: Span,
7070
generics_suggestion_span: Span,
7171
target: &ImplicitHasherType<'_>,

clippy_lints/src/manual_clamp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use clippy_utils::{
99
peel_blocks_with_stmt, MaybePath,
1010
};
1111
use itertools::Itertools;
12-
use rustc_errors::{Applicability, DiagnosticBuilder};
12+
use rustc_errors::{Applicability, Diag};
1313
use rustc_hir::def::Res;
1414
use rustc_hir::{Arm, BinOpKind, Block, Expr, ExprKind, HirId, PatKind, PathSegment, PrimTy, QPath, StmtKind};
1515
use rustc_lint::{LateContext, LateLintPass};
@@ -163,7 +163,7 @@ fn emit_suggestion<'tcx>(cx: &LateContext<'tcx>, suggestion: &ClampSuggestion<'t
163163
};
164164
let suggestion = format!("{assignment}{input}.clamp({min}, {max}){semicolon}");
165165
let msg = "clamp-like pattern without using clamp function";
166-
let lint_builder = |d: &mut DiagnosticBuilder<'_, ()>| {
166+
let lint_builder = |d: &mut Diag<'_, ()>| {
167167
d.span_suggestion(*span, "replace with clamp", suggestion, Applicability::MaybeIncorrect);
168168
if *is_float {
169169
d.note("clamp will panic if max < min, min.is_nan(), or max.is_nan()")

clippy_lints/src/matches/significant_drop_in_scrutinee.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::FxHashSet;
22
use clippy_utils::diagnostics::span_lint_and_then;
33
use clippy_utils::source::{indent_of, snippet};
44
use clippy_utils::{get_attr, is_lint_allowed};
5-
use rustc_errors::{Applicability, DiagnosticBuilder};
5+
use rustc_errors::{Applicability, Diag};
66
use rustc_hir::intravisit::{walk_expr, Visitor};
77
use rustc_hir::{Arm, Expr, ExprKind, MatchSource};
88
use rustc_lint::{LateContext, LintContext};
@@ -38,7 +38,7 @@ pub(super) fn check<'tcx>(
3838
}
3939

4040
fn set_diagnostic<'tcx>(
41-
diag: &mut DiagnosticBuilder<'_, ()>,
41+
diag: &mut Diag<'_, ()>,
4242
cx: &LateContext<'tcx>,
4343
expr: &'tcx Expr<'tcx>,
4444
found: FoundSigDrop,

clippy_lints/src/methods/suspicious_command_arg_space.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::diagnostics::span_lint_and_then;
22
use clippy_utils::ty::is_type_diagnostic_item;
3-
use rustc_errors::{Applicability, DiagnosticBuilder};
3+
use rustc_errors::{Applicability, Diag};
44
use rustc_lint::LateContext;
55
use rustc_span::{sym, Span};
66
use {rustc_ast as ast, rustc_hir as hir};
@@ -22,7 +22,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, recv: &'tcx hir::Expr<'_>, arg
2222
SUSPICIOUS_COMMAND_ARG_SPACE,
2323
arg.span,
2424
"single argument that looks like it should be multiple arguments",
25-
|diag: &mut DiagnosticBuilder<'_, ()>| {
25+
|diag: &mut Diag<'_, ()>| {
2626
diag.multipart_suggestion_verbose(
2727
"consider splitting the argument",
2828
vec![(span, "args".to_string()), (arg.span, format!("[{arg1:?}, {arg2:?}]"))],

clippy_lints/src/missing_asserts_for_indexing.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use clippy_utils::{eq_expr_value, hash_expr, higher};
99
use rustc_ast::{LitKind, RangeLimits};
1010
use rustc_data_structures::packed::Pu128;
1111
use rustc_data_structures::unhash::UnhashMap;
12-
use rustc_errors::{Applicability, DiagnosticBuilder};
12+
use rustc_errors::{Applicability, Diag};
1313
use rustc_hir::{BinOp, Block, Body, Expr, ExprKind, UnOp};
1414
use rustc_lint::{LateContext, LateLintPass};
1515
use rustc_session::declare_lint_pass;
@@ -67,7 +67,7 @@ declare_lint_pass!(MissingAssertsForIndexing => [MISSING_ASSERTS_FOR_INDEXING]);
6767

6868
fn report_lint<F>(cx: &LateContext<'_>, full_span: Span, msg: &str, indexes: &[Span], f: F)
6969
where
70-
F: FnOnce(&mut DiagnosticBuilder<'_, ()>),
70+
F: FnOnce(&mut Diag<'_, ()>),
7171
{
7272
span_lint_and_then(cx, MISSING_ASSERTS_FOR_INDEXING, full_span, msg, |diag| {
7373
f(diag);

clippy_lints/src/needless_pass_by_value.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use clippy_utils::ty::{
66
implements_trait, implements_trait_with_env_from_iter, is_copy, is_type_diagnostic_item, is_type_lang_item,
77
};
88
use rustc_ast::ast::Attribute;
9-
use rustc_errors::{Applicability, DiagnosticBuilder};
9+
use rustc_errors::{Applicability, Diag};
1010
use rustc_hir::intravisit::FnKind;
1111
use rustc_hir::{
1212
BindingAnnotation, Body, FnDecl, GenericArg, HirId, HirIdSet, Impl, ItemKind, LangItem, Mutability, Node, PatKind,
@@ -196,7 +196,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
196196
&& !moved_vars.contains(&canonical_id)
197197
{
198198
// Dereference suggestion
199-
let sugg = |diag: &mut DiagnosticBuilder<'_, ()>| {
199+
let sugg = |diag: &mut Diag<'_, ()>| {
200200
if let ty::Adt(def, ..) = ty.kind() {
201201
if let Some(span) = cx.tcx.hir().span_if_local(def.did()) {
202202
if type_allowed_to_implement_copy(

clippy_lints/src/utils/internal_lints/metadata_collector.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const LINT_EMISSION_FUNCTIONS: [&[&str]; 7] = [
7474
&["clippy_utils", "diagnostics", "span_lint_and_then"],
7575
&["clippy_utils", "diagnostics", "span_lint_hir_and_then"],
7676
];
77-
const SUGGESTION_DIAGNOSTIC_BUILDER_METHODS: [(&str, bool); 9] = [
77+
const SUGGESTION_DIAG_METHODS: [(&str, bool); 9] = [
7878
("span_suggestion", false),
7979
("span_suggestion_short", false),
8080
("span_suggestion_verbose", false),
@@ -1067,9 +1067,9 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for IsMultiSpanScanner<'a, 'hir> {
10671067
},
10681068
ExprKind::MethodCall(path, recv, _, _arg_span) => {
10691069
let (self_ty, _) = walk_ptrs_ty_depth(self.cx.typeck_results().expr_ty(recv));
1070-
if match_type(self.cx, self_ty, &paths::DIAGNOSTIC_BUILDER) {
1070+
if match_type(self.cx, self_ty, &paths::DIAG) {
10711071
let called_method = path.ident.name.as_str().to_string();
1072-
for (method_name, is_multi_part) in &SUGGESTION_DIAGNOSTIC_BUILDER_METHODS {
1072+
for (method_name, is_multi_part) in &SUGGESTION_DIAG_METHODS {
10731073
if *method_name == called_method {
10741074
if *is_multi_part {
10751075
self.add_multi_part_suggestion();

clippy_utils/src/diagnostics.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
//! Thank you!
99
//! ~The `INTERNAL_METADATA_COLLECTOR` lint
1010
11-
use rustc_errors::{Applicability, DiagnosticBuilder, MultiSpan};
11+
use rustc_errors::{Applicability, Diag, MultiSpan};
1212
use rustc_hir::HirId;
1313
use rustc_lint::{LateContext, Lint, LintContext};
1414
use rustc_span::Span;
1515
use std::env;
1616

17-
fn docs_link(diag: &mut DiagnosticBuilder<'_, ()>, lint: &'static Lint) {
17+
fn docs_link(diag: &mut Diag<'_, ()>, lint: &'static Lint) {
1818
if env::var("CLIPPY_DISABLE_DOCS_LINKS").is_err() {
1919
if let Some(lint) = lint.name_lower().strip_prefix("clippy::") {
2020
diag.help(format!(
@@ -143,7 +143,7 @@ pub fn span_lint_and_then<C, S, F>(cx: &C, lint: &'static Lint, sp: S, msg: &str
143143
where
144144
C: LintContext,
145145
S: Into<MultiSpan>,
146-
F: FnOnce(&mut DiagnosticBuilder<'_, ()>),
146+
F: FnOnce(&mut Diag<'_, ()>),
147147
{
148148
#[expect(clippy::disallowed_methods)]
149149
cx.span_lint(lint, sp, msg.to_string(), |diag| {
@@ -165,7 +165,7 @@ pub fn span_lint_hir_and_then(
165165
hir_id: HirId,
166166
sp: impl Into<MultiSpan>,
167167
msg: &str,
168-
f: impl FnOnce(&mut DiagnosticBuilder<'_, ()>),
168+
f: impl FnOnce(&mut Diag<'_, ()>),
169169
) {
170170
#[expect(clippy::disallowed_methods)]
171171
cx.tcx.node_span_lint(lint, hir_id, sp, msg.to_string(), |diag| {
@@ -214,7 +214,7 @@ pub fn span_lint_and_sugg<T: LintContext>(
214214
/// appear once per
215215
/// replacement. In human-readable format though, it only appears once before
216216
/// the whole suggestion.
217-
pub fn multispan_sugg<I>(diag: &mut DiagnosticBuilder<'_, ()>, help_msg: &str, sugg: I)
217+
pub fn multispan_sugg<I>(diag: &mut Diag<'_, ()>, help_msg: &str, sugg: I)
218218
where
219219
I: IntoIterator<Item = (Span, String)>,
220220
{
@@ -227,7 +227,7 @@ where
227227
/// multiple spans. This is tracked in issue [rustfix#141](https://github.com/rust-lang/rustfix/issues/141).
228228
/// Suggestions with multiple spans will be silently ignored.
229229
pub fn multispan_sugg_with_applicability<I>(
230-
diag: &mut DiagnosticBuilder<'_, ()>,
230+
diag: &mut Diag<'_, ()>,
231231
help_msg: &str,
232232
applicability: Applicability,
233233
sugg: I,

clippy_utils/src/paths.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub const APPLICABILITY_VALUES: [[&str; 3]; 4] = [
1111
["rustc_lint_defs", "Applicability", "MaybeIncorrect"],
1212
["rustc_lint_defs", "Applicability", "MachineApplicable"],
1313
];
14-
pub const DIAGNOSTIC_BUILDER: [&str; 2] = ["rustc_errors", "DiagnosticBuilder"];
14+
pub const DIAG: [&str; 2] = ["rustc_errors", "Diag"];
1515
pub const BINARYHEAP_ITER: [&str; 5] = ["alloc", "collections", "binary_heap", "BinaryHeap", "iter"];
1616
pub const BTREEMAP_CONTAINS_KEY: [&str; 6] = ["alloc", "collections", "btree", "map", "BTreeMap", "contains_key"];
1717
pub const BTREEMAP_INSERT: [&str; 6] = ["alloc", "collections", "btree", "map", "BTreeMap", "insert"];

clippy_utils/src/sugg.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ fn indentation<T: LintContext>(cx: &T, span: Span) -> Option<String> {
684684
})
685685
}
686686

687-
/// Convenience extension trait for `DiagnosticBuilder`.
687+
/// Convenience extension trait for `Diag`.
688688
pub trait DiagnosticExt<T: LintContext> {
689689
/// Suggests to add an attribute to an item.
690690
///
@@ -732,7 +732,7 @@ pub trait DiagnosticExt<T: LintContext> {
732732
fn suggest_remove_item(&mut self, cx: &T, item: Span, msg: &str, applicability: Applicability);
733733
}
734734

735-
impl<T: LintContext> DiagnosticExt<T> for rustc_errors::DiagnosticBuilder<'_, ()> {
735+
impl<T: LintContext> DiagnosticExt<T> for rustc_errors::Diag<'_, ()> {
736736
fn suggest_item_with_attr<D: Display + ?Sized>(
737737
&mut self,
738738
cx: &T,

0 commit comments

Comments
 (0)