Skip to content

Commit

Permalink
Rename SubdiagnosticVariant as SubdiagVariant.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Mar 7, 2024
1 parent c90dc20 commit 7222172
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -142,7 +142,7 @@ impl DiagDeriveVariantBuilder {
&self,
attr: &Attribute,
) -> Result<Option<(SubdiagKind, Path, bool)>, 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);
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_macros/src/diagnostics/subdiagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_macros/src/diagnostics/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,20 +592,20 @@ pub(super) enum SubdiagKind {
},
}

pub(super) struct SubdiagnosticVariant {
pub(super) struct SubdiagVariant {
pub(super) kind: SubdiagKind,
pub(super) slug: Option<Path>,
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<Option<SubdiagnosticVariant>, DiagDeriveError> {
) -> Result<Option<SubdiagVariant>, DiagDeriveError> {
// Always allow documentation comments.
if is_doc_comment(attr) {
return Ok(None);
Expand Down Expand Up @@ -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 = \"...\"`")
Expand Down Expand Up @@ -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 }))
}
}

Expand Down

0 comments on commit 7222172

Please sign in to comment.