pub(crate) struct DiagnosticDeriveVariantBuilder {
pub formatting_init: TokenStream,
pub span: Span,
pub field_map: IndexMap<String, (Ident, TokenStream)>,
pub message: Option<Message>,
pub code: Option<((), Span)>,
pub used_fields: HashSet<Ident>,
}Expand description
Tracks persistent information required for a specific variant when building up individual calls to diagnostic methods for generated diagnostic derives.
Fields§
§formatting_init: TokenStreamInitialization of format strings for code suggestions.
span: SpanSpan of the struct or the enum variant.
field_map: IndexMap<String, (Ident, TokenStream)>Store a map of field name to its corresponding field. This is built on construction of the derive builder.
message: Option<Message>Message is a mandatory part of the struct attribute as corresponds to the Fluent message that has the actual diagnostic message.
code: Option<((), Span)>Error codes are a optional part of the struct attribute - this is only set to detect multiple specifications.
used_fields: HashSet<Ident>Implementations§
Source§impl DiagnosticDeriveVariantBuilder
impl DiagnosticDeriveVariantBuilder
pub(crate) fn primary_message(&self) -> Option<&Message>
Sourcepub(crate) fn preamble(&mut self, variant: &VariantInfo<'_>) -> TokenStream
pub(crate) fn preamble(&mut self, variant: &VariantInfo<'_>) -> TokenStream
Generates calls to code and similar functions based on the attributes on the type or
variant.
Sourcepub(crate) fn body(&mut self, variant: &VariantInfo<'_>) -> TokenStream
pub(crate) fn body(&mut self, variant: &VariantInfo<'_>) -> TokenStream
Generates calls to span_label and similar functions based on the attributes on fields or
calls to arg when no attributes are present.
fn is_used_in_message(&self, binding: &BindingInfo<'_>) -> bool
Sourcefn parse_subdiag_attribute(
&mut self,
attr: &Attribute,
) -> Result<Option<(SubdiagnosticKind, Message, bool)>, DiagnosticDeriveError>
fn parse_subdiag_attribute( &mut self, attr: &Attribute, ) -> Result<Option<(SubdiagnosticKind, Message, bool)>, DiagnosticDeriveError>
Parse a SubdiagnosticKind from an Attribute.
Sourcefn generate_structure_code_for_attr(
&mut self,
attr: &Attribute,
) -> Result<TokenStream, DiagnosticDeriveError>
fn generate_structure_code_for_attr( &mut self, attr: &Attribute, ) -> Result<TokenStream, DiagnosticDeriveError>
Establishes state in the DiagnosticDeriveBuilder resulting from the struct
attributes like #[diag(..)], such as the message and error code. Generates
diagnostic builder calls for setting error code and creating note/help messages.
fn generate_field_code(&mut self, binding_info: &BindingInfo<'_>) -> TokenStream
fn generate_field_attrs_code( &mut self, binding_info: &BindingInfo<'_>, ) -> TokenStream
fn generate_inner_field_code( &mut self, attr: &Attribute, info: FieldInfo<'_>, binding: TokenStream, ) -> Result<TokenStream, DiagnosticDeriveError>
Sourcefn add_spanned_subdiagnostic(
&self,
field_binding: TokenStream,
kind: &Ident,
message: Message,
) -> TokenStream
fn add_spanned_subdiagnostic( &self, field_binding: TokenStream, kind: &Ident, message: Message, ) -> TokenStream
Adds a spanned subdiagnostic by generating a diag.span_$kind call with the current message
and fluent_attr_identifier.
Sourcefn add_subdiagnostic(&self, kind: &Ident, message: Message) -> TokenStream
fn add_subdiagnostic(&self, kind: &Ident, message: Message) -> TokenStream
Adds a subdiagnostic by generating a diag.span_$kind call with the current message
and fluent_attr_identifier.
fn span_and_applicability_of_ty( &self, info: FieldInfo<'_>, ) -> Result<(TokenStream, Option<(TokenStream, Span)>), DiagnosticDeriveError>
Auto Trait Implementations§
impl !Send for DiagnosticDeriveVariantBuilder
impl !Sync for DiagnosticDeriveVariantBuilder
impl Freeze for DiagnosticDeriveVariantBuilder
impl RefUnwindSafe for DiagnosticDeriveVariantBuilder
impl Unpin for DiagnosticDeriveVariantBuilder
impl UnsafeUnpin for DiagnosticDeriveVariantBuilder
impl UnwindSafe for DiagnosticDeriveVariantBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more