diff --git a/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs b/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs index a671cf49dbdc..d7f06bde1fd1 100644 --- a/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs +++ b/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs @@ -12,7 +12,7 @@ use syn::Token; use syn::{parse_quote, spanned::Spanned, Attribute, Meta, Path, Type}; use synstructure::{BindingInfo, Structure, VariantInfo}; -use super::utils::SubdiagnosticVariant; +use super::utils::SubdiagVariant; /// What kind of diagnostic is being derived - a fatal/error/warning or a lint? #[derive(Clone, Copy, PartialEq, Eq)] @@ -142,7 +142,7 @@ impl DiagDeriveVariantBuilder { &self, attr: &Attribute, ) -> Result, DiagDeriveError> { - let Some(subdiag) = SubdiagnosticVariant::from_attr(attr, self)? else { + let Some(subdiag) = SubdiagVariant::from_attr(attr, self)? else { // Some attributes aren't errors - like documentation comments - but also aren't // subdiagnostics. return Ok(None); diff --git a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs index 08502705fd15..d0baef9723ef 100644 --- a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs @@ -14,7 +14,7 @@ use quote::{format_ident, quote}; use syn::{spanned::Spanned, Attribute, Meta, MetaList, Path}; use synstructure::{BindingInfo, Structure, VariantInfo}; -use super::utils::SubdiagnosticVariant; +use super::utils::SubdiagVariant; /// The central struct for constructing the `add_to_diag` method from an annotated struct. pub(crate) struct AddToDiagDerive { @@ -183,8 +183,8 @@ impl<'parent, 'a> SubdiagDeriveVariantBuilder<'parent, 'a> { let mut kind_slugs = vec![]; for attr in self.variant.ast().attrs { - let Some(SubdiagnosticVariant { kind, slug, no_span }) = - SubdiagnosticVariant::from_attr(attr, self)? + let Some(SubdiagVariant { kind, slug, no_span }) = + SubdiagVariant::from_attr(attr, self)? else { // Some attributes aren't errors - like documentation comments - but also aren't // subdiagnostics. diff --git a/compiler/rustc_macros/src/diagnostics/utils.rs b/compiler/rustc_macros/src/diagnostics/utils.rs index a1401bb3a3c7..3099d637033a 100644 --- a/compiler/rustc_macros/src/diagnostics/utils.rs +++ b/compiler/rustc_macros/src/diagnostics/utils.rs @@ -592,20 +592,20 @@ pub(super) enum SubdiagKind { }, } -pub(super) struct SubdiagnosticVariant { +pub(super) struct SubdiagVariant { pub(super) kind: SubdiagKind, pub(super) slug: Option, pub(super) no_span: bool, } -impl SubdiagnosticVariant { - /// Constructs a `SubdiagnosticVariant` from a field or type attribute such as `#[note]`, +impl SubdiagVariant { + /// Constructs a `SubdiagVariant` from a field or type attribute such as `#[note]`, /// `#[error(parser::add_paren, no_span)]` or `#[suggestion(code = "...")]`. Returns the /// `SubdiagKind` and the diagnostic slug, if specified. pub(super) fn from_attr( attr: &Attribute, fields: &impl HasFieldMap, - ) -> Result, DiagDeriveError> { + ) -> Result, DiagDeriveError> { // Always allow documentation comments. if is_doc_comment(attr) { return Ok(None); @@ -680,7 +680,7 @@ impl SubdiagnosticVariant { | SubdiagKind::Help | SubdiagKind::Warn | SubdiagKind::MultipartSuggestion { .. } => { - return Ok(Some(SubdiagnosticVariant { kind, slug: None, no_span: false })); + return Ok(Some(SubdiagVariant { kind, slug: None, no_span: false })); } SubdiagKind::Suggestion { .. } => { throw_span_err!(span, "suggestion without `code = \"...\"`") @@ -830,7 +830,7 @@ impl SubdiagnosticVariant { SubdiagKind::Label | SubdiagKind::Note | SubdiagKind::Help | SubdiagKind::Warn => {} } - Ok(Some(SubdiagnosticVariant { kind, slug, no_span })) + Ok(Some(SubdiagVariant { kind, slug, no_span })) } }