Skip to content

Commit 7b8644e

Browse files
committed
Rename DiagnosticDeriveKind::Diagnostic::handler as DiagnosticDeriveKind::Diagnostic::dcx.
1 parent f7125f1 commit 7b8644e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

compiler/rustc_macros/src/diagnostics/diagnostic.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ pub(crate) struct DiagnosticDerive<'a> {
1717
}
1818

1919
impl<'a> DiagnosticDerive<'a> {
20-
pub(crate) fn new(diag: syn::Ident, handler: syn::Ident, structure: Structure<'a>) -> Self {
20+
pub(crate) fn new(diag: syn::Ident, dcx: syn::Ident, structure: Structure<'a>) -> Self {
2121
Self {
2222
builder: DiagnosticDeriveBuilder {
2323
diag,
24-
kind: DiagnosticDeriveKind::Diagnostic { handler },
24+
kind: DiagnosticDeriveKind::Diagnostic { dcx },
2525
},
2626
structure,
2727
}
@@ -36,7 +36,7 @@ impl<'a> DiagnosticDerive<'a> {
3636
let body = builder.body(variant);
3737

3838
let diag = &builder.parent.diag;
39-
let DiagnosticDeriveKind::Diagnostic { handler } = &builder.parent.kind else {
39+
let DiagnosticDeriveKind::Diagnostic { dcx } = &builder.parent.kind else {
4040
unreachable!()
4141
};
4242
let init = match builder.slug.value_ref() {
@@ -62,7 +62,7 @@ impl<'a> DiagnosticDerive<'a> {
6262
Some(slug) => {
6363
slugs.borrow_mut().push(slug.clone());
6464
quote! {
65-
let mut #diag = #handler.struct_diagnostic(crate::fluent_generated::#slug);
65+
let mut #diag = #dcx.struct_diagnostic(crate::fluent_generated::#slug);
6666
}
6767
}
6868
};
@@ -77,7 +77,7 @@ impl<'a> DiagnosticDerive<'a> {
7777
}
7878
});
7979

80-
let DiagnosticDeriveKind::Diagnostic { handler } = &builder.kind else { unreachable!() };
80+
let DiagnosticDeriveKind::Diagnostic { dcx } = &builder.kind else { unreachable!() };
8181

8282
let mut imp = structure.gen_impl(quote! {
8383
gen impl<'__diagnostic_handler_sess, G>
@@ -89,7 +89,7 @@ impl<'a> DiagnosticDerive<'a> {
8989
#[track_caller]
9090
fn into_diagnostic(
9191
self,
92-
#handler: &'__diagnostic_handler_sess rustc_errors::DiagCtxt
92+
#dcx: &'__diagnostic_handler_sess rustc_errors::DiagCtxt
9393
) -> rustc_errors::DiagnosticBuilder<'__diagnostic_handler_sess, G> {
9494
use rustc_errors::IntoDiagnosticArg;
9595
#implementation

compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use super::utils::SubdiagnosticVariant;
1919
/// What kind of diagnostic is being derived - a fatal/error/warning or a lint?
2020
#[derive(Clone, PartialEq, Eq)]
2121
pub(crate) enum DiagnosticDeriveKind {
22-
Diagnostic { handler: syn::Ident },
22+
Diagnostic { dcx: syn::Ident },
2323
LintDiagnostic,
2424
}
2525

@@ -348,11 +348,11 @@ impl<'a> DiagnosticDeriveVariantBuilder<'a> {
348348
}
349349
(Meta::Path(_), "subdiagnostic") => {
350350
if FieldInnerTy::from_type(&info.binding.ast().ty).will_iterate() {
351-
let DiagnosticDeriveKind::Diagnostic { handler } = &self.parent.kind else {
351+
let DiagnosticDeriveKind::Diagnostic { dcx } = &self.parent.kind else {
352352
// No eager translation for lints.
353353
return Ok(quote! { #diag.subdiagnostic(#binding); });
354354
};
355-
return Ok(quote! { #diag.eager_subdiagnostic(#handler, #binding); });
355+
return Ok(quote! { #diag.eager_subdiagnostic(#dcx, #binding); });
356356
} else {
357357
return Ok(quote! { #diag.subdiagnostic(#binding); });
358358
}
@@ -377,7 +377,7 @@ impl<'a> DiagnosticDeriveVariantBuilder<'a> {
377377
}
378378

379379
let handler = match &self.parent.kind {
380-
DiagnosticDeriveKind::Diagnostic { handler } => handler,
380+
DiagnosticDeriveKind::Diagnostic { dcx } => dcx,
381381
DiagnosticDeriveKind::LintDiagnostic => {
382382
throw_invalid_attr!(attr, |diag| {
383383
diag.help("eager subdiagnostics are not supported on lints")

0 commit comments

Comments
 (0)