Skip to content

Commit c475e23

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 bf9c7a6 + 8f3b007 commit c475e23

File tree

182 files changed

+1527
-1774
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+1527
-1774
lines changed

Diff for: compiler/rustc_ast_lowering/src/errors.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use rustc_errors::{
2-
codes::*, AddToDiagnostic, DiagnosticArgFromDisplay, DiagnosticBuilder, EmissionGuarantee,
3-
SubdiagnosticMessageOp,
2+
codes::*, AddToDiagnostic, Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagnosticMessageOp,
43
};
54
use rustc_macros::{Diagnostic, Subdiagnostic};
65
use rustc_span::{symbol::Ident, Span, Symbol};
@@ -44,7 +43,7 @@ pub struct InvalidAbiReason(pub &'static str);
4443
impl AddToDiagnostic for InvalidAbiReason {
4544
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
4645
self,
47-
diag: &mut DiagnosticBuilder<'_, G>,
46+
diag: &mut Diag<'_, G>,
4847
_: F,
4948
) {
5049
#[allow(rustc::untranslatable_diagnostic)]
@@ -95,7 +94,7 @@ pub enum AssocTyParenthesesSub {
9594
pub struct MisplacedImplTrait<'a> {
9695
#[primary_span]
9796
pub span: Span,
98-
pub position: DiagnosticArgFromDisplay<'a>,
97+
pub position: DiagArgFromDisplay<'a>,
9998
}
10099

101100
#[derive(Diagnostic)]

Diff for: compiler/rustc_ast_lowering/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use rustc_data_structures::fingerprint::Fingerprint;
5151
use rustc_data_structures::sorted_map::SortedMap;
5252
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
5353
use rustc_data_structures::sync::Lrc;
54-
use rustc_errors::{DiagCtxt, DiagnosticArgFromDisplay, StashKey};
54+
use rustc_errors::{DiagArgFromDisplay, DiagCtxt, StashKey};
5555
use rustc_hir as hir;
5656
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
5757
use rustc_hir::def_id::{LocalDefId, LocalDefIdMap, CRATE_DEF_ID, LOCAL_CRATE};
@@ -1473,7 +1473,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14731473
.create_feature_err(
14741474
MisplacedImplTrait {
14751475
span: t.span,
1476-
position: DiagnosticArgFromDisplay(&position),
1476+
position: DiagArgFromDisplay(&position),
14771477
},
14781478
feature,
14791479
)
@@ -1483,7 +1483,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14831483
ImplTraitContext::Disallowed(position) => {
14841484
let guar = self.dcx().emit_err(MisplacedImplTrait {
14851485
span: t.span,
1486-
position: DiagnosticArgFromDisplay(&position),
1486+
position: DiagArgFromDisplay(&position),
14871487
});
14881488
hir::TyKind::Err(guar)
14891489
}

Diff for: compiler/rustc_ast_passes/src/errors.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
33
use rustc_ast::ParamKindOrd;
44
use rustc_errors::{
5-
codes::*, AddToDiagnostic, Applicability, DiagnosticBuilder, EmissionGuarantee,
6-
SubdiagnosticMessageOp,
5+
codes::*, AddToDiagnostic, Applicability, Diag, EmissionGuarantee, SubdiagnosticMessageOp,
76
};
87
use rustc_macros::{Diagnostic, Subdiagnostic};
98
use rustc_span::{symbol::Ident, Span, Symbol};
@@ -377,7 +376,7 @@ pub struct EmptyLabelManySpans(pub Vec<Span>);
377376
impl AddToDiagnostic for EmptyLabelManySpans {
378377
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
379378
self,
380-
diag: &mut DiagnosticBuilder<'_, G>,
379+
diag: &mut Diag<'_, G>,
381380
_: F,
382381
) {
383382
diag.span_labels(self.0, "");
@@ -738,7 +737,7 @@ pub struct StableFeature {
738737
impl AddToDiagnostic for StableFeature {
739738
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
740739
self,
741-
diag: &mut DiagnosticBuilder<'_, G>,
740+
diag: &mut Diag<'_, G>,
742741
_: F,
743742
) {
744743
diag.arg("name", self.name);

Diff for: compiler/rustc_attr/src/session_diagnostics.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::num::IntErrorKind;
22

33
use rustc_ast as ast;
44
use rustc_errors::{
5-
codes::*, Applicability, DiagCtxt, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic, Level,
5+
codes::*, Applicability, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level,
66
};
77
use rustc_macros::Diagnostic;
88
use rustc_span::{Span, Symbol};
@@ -51,9 +51,9 @@ pub(crate) struct UnknownMetaItem<'a> {
5151

5252
// Manual implementation to be able to format `expected` items correctly.
5353
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for UnknownMetaItem<'_> {
54-
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
54+
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
5555
let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>();
56-
DiagnosticBuilder::new(dcx, level, fluent::attr_unknown_meta_item)
56+
Diag::new(dcx, level, fluent::attr_unknown_meta_item)
5757
.with_span(self.span)
5858
.with_code(E0541)
5959
.with_arg("item", self.item)
@@ -198,8 +198,8 @@ pub(crate) struct UnsupportedLiteral {
198198
}
199199

200200
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for UnsupportedLiteral {
201-
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
202-
let mut diag = DiagnosticBuilder::new(
201+
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
202+
let mut diag = Diag::new(
203203
dcx,
204204
level,
205205
match self.reason {

Diff for: compiler/rustc_borrowck/src/borrowck_errors.rs

+25-38
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(rustc::diagnostic_outside_of_impl)]
22
#![allow(rustc::untranslatable_diagnostic)]
33

4-
use rustc_errors::{codes::*, struct_span_code_err, DiagCtxt, DiagnosticBuilder};
4+
use rustc_errors::{codes::*, struct_span_code_err, Diag, DiagCtxt};
55
use rustc_middle::ty::{self, Ty, TyCtxt};
66
use rustc_span::Span;
77

@@ -17,7 +17,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
1717
place: &str,
1818
borrow_place: &str,
1919
value_place: &str,
20-
) -> DiagnosticBuilder<'tcx> {
20+
) -> Diag<'tcx> {
2121
self.dcx().create_err(crate::session_diagnostics::MoveBorrow {
2222
place,
2323
span,
@@ -33,7 +33,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
3333
desc: &str,
3434
borrow_span: Span,
3535
borrow_desc: &str,
36-
) -> DiagnosticBuilder<'tcx> {
36+
) -> Diag<'tcx> {
3737
struct_span_code_err!(
3838
self.dcx(),
3939
span,
@@ -53,7 +53,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
5353
old_loan_span: Span,
5454
old_opt_via: &str,
5555
old_load_end_span: Option<Span>,
56-
) -> DiagnosticBuilder<'tcx> {
56+
) -> Diag<'tcx> {
5757
let via = |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {msg})") };
5858
let mut err = struct_span_code_err!(
5959
self.dcx(),
@@ -100,7 +100,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
100100
desc: &str,
101101
old_loan_span: Span,
102102
old_load_end_span: Option<Span>,
103-
) -> DiagnosticBuilder<'tcx> {
103+
) -> Diag<'tcx> {
104104
let mut err = struct_span_code_err!(
105105
self.dcx(),
106106
new_loan_span,
@@ -133,7 +133,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
133133
noun_old: &str,
134134
old_opt_via: &str,
135135
previous_end_span: Option<Span>,
136-
) -> DiagnosticBuilder<'tcx> {
136+
) -> Diag<'tcx> {
137137
let mut err = struct_span_code_err!(
138138
self.dcx(),
139139
new_loan_span,
@@ -165,7 +165,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
165165
old_opt_via: &str,
166166
previous_end_span: Option<Span>,
167167
second_borrow_desc: &str,
168-
) -> DiagnosticBuilder<'tcx> {
168+
) -> Diag<'tcx> {
169169
let mut err = struct_span_code_err!(
170170
self.dcx(),
171171
new_loan_span,
@@ -197,7 +197,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
197197
kind_old: &str,
198198
msg_old: &str,
199199
old_load_end_span: Option<Span>,
200-
) -> DiagnosticBuilder<'tcx> {
200+
) -> Diag<'tcx> {
201201
let via = |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {msg})") };
202202
let mut err = struct_span_code_err!(
203203
self.dcx(),
@@ -238,7 +238,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
238238
span: Span,
239239
borrow_span: Span,
240240
desc: &str,
241-
) -> DiagnosticBuilder<'tcx> {
241+
) -> Diag<'tcx> {
242242
struct_span_code_err!(
243243
self.dcx(),
244244
span,
@@ -255,20 +255,20 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
255255
span: Span,
256256
desc: &str,
257257
is_arg: bool,
258-
) -> DiagnosticBuilder<'tcx> {
258+
) -> Diag<'tcx> {
259259
let msg = if is_arg { "to immutable argument" } else { "twice to immutable variable" };
260260
struct_span_code_err!(self.dcx(), span, E0384, "cannot assign {} {}", msg, desc)
261261
}
262262

263-
pub(crate) fn cannot_assign(&self, span: Span, desc: &str) -> DiagnosticBuilder<'tcx> {
263+
pub(crate) fn cannot_assign(&self, span: Span, desc: &str) -> Diag<'tcx> {
264264
struct_span_code_err!(self.dcx(), span, E0594, "cannot assign to {}", desc)
265265
}
266266

267267
pub(crate) fn cannot_move_out_of(
268268
&self,
269269
move_from_span: Span,
270270
move_from_desc: &str,
271-
) -> DiagnosticBuilder<'tcx> {
271+
) -> Diag<'tcx> {
272272
struct_span_code_err!(
273273
self.dcx(),
274274
move_from_span,
@@ -286,7 +286,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
286286
move_from_span: Span,
287287
ty: Ty<'_>,
288288
is_index: Option<bool>,
289-
) -> DiagnosticBuilder<'tcx> {
289+
) -> Diag<'tcx> {
290290
let type_name = match (&ty.kind(), is_index) {
291291
(&ty::Array(_, _), Some(true)) | (&ty::Array(_, _), None) => "array",
292292
(&ty::Slice(_), _) => "slice",
@@ -307,7 +307,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
307307
&self,
308308
move_from_span: Span,
309309
container_ty: Ty<'_>,
310-
) -> DiagnosticBuilder<'tcx> {
310+
) -> Diag<'tcx> {
311311
struct_span_code_err!(
312312
self.dcx(),
313313
move_from_span,
@@ -324,7 +324,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
324324
verb: &str,
325325
optional_adverb_for_moved: &str,
326326
moved_path: Option<String>,
327-
) -> DiagnosticBuilder<'tcx> {
327+
) -> Diag<'tcx> {
328328
let moved_path = moved_path.map(|mp| format!(": `{mp}`")).unwrap_or_default();
329329

330330
struct_span_code_err!(
@@ -343,7 +343,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
343343
span: Span,
344344
path: &str,
345345
reason: &str,
346-
) -> DiagnosticBuilder<'tcx> {
346+
) -> Diag<'tcx> {
347347
struct_span_code_err!(
348348
self.dcx(),
349349
span,
@@ -361,7 +361,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
361361
immutable_place: &str,
362362
immutable_section: &str,
363363
action: &str,
364-
) -> DiagnosticBuilder<'tcx> {
364+
) -> Diag<'tcx> {
365365
struct_span_code_err!(
366366
self.dcx(),
367367
mutate_span,
@@ -379,7 +379,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
379379
&self,
380380
span: Span,
381381
yield_span: Span,
382-
) -> DiagnosticBuilder<'tcx> {
382+
) -> Diag<'tcx> {
383383
let coroutine_kind = self.body.coroutine.as_ref().unwrap().coroutine_kind;
384384
struct_span_code_err!(
385385
self.dcx(),
@@ -390,10 +390,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
390390
.with_span_label(yield_span, "possible yield occurs here")
391391
}
392392

393-
pub(crate) fn cannot_borrow_across_destructor(
394-
&self,
395-
borrow_span: Span,
396-
) -> DiagnosticBuilder<'tcx> {
393+
pub(crate) fn cannot_borrow_across_destructor(&self, borrow_span: Span) -> Diag<'tcx> {
397394
struct_span_code_err!(
398395
self.dcx(),
399396
borrow_span,
@@ -402,11 +399,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
402399
)
403400
}
404401

405-
pub(crate) fn path_does_not_live_long_enough(
406-
&self,
407-
span: Span,
408-
path: &str,
409-
) -> DiagnosticBuilder<'tcx> {
402+
pub(crate) fn path_does_not_live_long_enough(&self, span: Span, path: &str) -> Diag<'tcx> {
410403
struct_span_code_err!(self.dcx(), span, E0597, "{} does not live long enough", path,)
411404
}
412405

@@ -416,7 +409,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
416409
return_kind: &str,
417410
reference_desc: &str,
418411
path_desc: &str,
419-
) -> DiagnosticBuilder<'tcx> {
412+
) -> Diag<'tcx> {
420413
struct_span_code_err!(
421414
self.dcx(),
422415
span,
@@ -439,7 +432,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
439432
borrowed_path: &str,
440433
capture_span: Span,
441434
scope: &str,
442-
) -> DiagnosticBuilder<'tcx> {
435+
) -> Diag<'tcx> {
443436
struct_span_code_err!(
444437
self.dcx(),
445438
closure_span,
@@ -451,10 +444,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
451444
.with_span_label(closure_span, format!("may outlive borrowed value {borrowed_path}"))
452445
}
453446

454-
pub(crate) fn thread_local_value_does_not_live_long_enough(
455-
&self,
456-
span: Span,
457-
) -> DiagnosticBuilder<'tcx> {
447+
pub(crate) fn thread_local_value_does_not_live_long_enough(&self, span: Span) -> Diag<'tcx> {
458448
struct_span_code_err!(
459449
self.dcx(),
460450
span,
@@ -463,10 +453,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
463453
)
464454
}
465455

466-
pub(crate) fn temporary_value_borrowed_for_too_long(
467-
&self,
468-
span: Span,
469-
) -> DiagnosticBuilder<'tcx> {
456+
pub(crate) fn temporary_value_borrowed_for_too_long(&self, span: Span) -> Diag<'tcx> {
470457
struct_span_code_err!(self.dcx(), span, E0716, "temporary value dropped while borrowed",)
471458
}
472459
}
@@ -475,7 +462,7 @@ pub(crate) fn borrowed_data_escapes_closure<'tcx>(
475462
tcx: TyCtxt<'tcx>,
476463
escape_span: Span,
477464
escapes_from: &str,
478-
) -> DiagnosticBuilder<'tcx> {
465+
) -> Diag<'tcx> {
479466
struct_span_code_err!(
480467
tcx.dcx(),
481468
escape_span,

0 commit comments

Comments
 (0)