mf2_parser

Enum Diagnostic

source
pub enum Diagnostic<'text> {
Show 56 variants NumberMissingIntegralPart { number: Number<'text>, }, NumberLeadingZeroIntegralPart { number: Number<'text>, }, NumberMissingFractionalPart { number: Number<'text>, }, NumberMissingExponentPart { number: Number<'text>, }, OptionMissingKey { span: Span, }, OptionMissingValue { span: Span, }, LoneEqualsSign { loc: Location, }, MarkupMissingIdentifier { span: Span, }, MarkupInvalidSpaceBeforeIdentifier { id: Identifier<'text>, start_loc: Location, }, MarkupMissingClosingBrace { span: Span, }, MarkupCloseInvalidSelfClose { self_close_loc: Location, }, MarkupInvalidSpaceBetweenSelfCloseAndBrace { space: Span, }, MarkupOptionAfterAttribute { previous_attribute: Attribute<'text>, option: FnOrMarkupOption<'text>, }, FunctionMissingIdentifier { span: Span, }, UnterminatedQuoted { span: Span, }, PlaceholderMissingClosingBrace { span: Span, }, PlaceholderMissingBody { span: Span, }, PlaceholderInvalidLiteral { span: Span, }, PlaceholderInvalidContents { span: Span, }, QuotedPatternInsidePattern { open_span: Span, close_span: Option<Span>, }, MarkupInvalidContents { span: Span, }, MissingIdentifierName { identifier: Identifier<'text>, }, MissingIdentifierNamespace { identifier: Identifier<'text>, }, EscapeInvalidCharacter { char_loc: Location, char: char, }, EscapeMissingCharacter { slash_loc: Location, }, InvalidNullCharacter { char_loc: Location, }, InvalidClosingBrace { brace_loc: Location, }, AnnotationMissingSpaceBefore { span: Span, }, AttributeMissingSpaceBefore { span: Span, }, AttributeMissingKey { span: Span, }, AttributeMissingValue { span: Span, }, AttributeValueIsVariable { span: Span, }, VariableMissingName { span: Span, }, UnterminatedQuotedPattern { span: Span, }, LocalKeywordMissingTrailingSpace { span: Span, }, LocalVariableMissingDollar { span: Span, }, MissingSpaceBeforeMatcherSelector { span: Span, }, MissingSpaceBeforeMatcherKey { span: Span, }, ComplexMessageMissingBody { span: Span, }, ComplexMessageTrailingContent { span: Span, }, ComplexMessageBodyNotQuoted { span: Span, }, ComplexMessageDeclarationAfterBody { span: Span, }, ComplexMessageMultipleBodies { span: Span, }, MatcherKeyIsVariable { span: Span, }, InvalidMatcherLiteralKey { span: Span, }, InvalidStatement { span: Span, keyword: &'text str, }, LocalDeclarationMalformed { span: Span, }, LocalDeclarationValueNotWrappedInBraces { span: Span, }, LocalDeclarationVariableMissingTrailingEquals { span: Span, }, LocalDeclarationMissingExpression { span: Span, }, InputDeclarationMissingExpression { span: Span, }, InputDeclarationWithInvalidExpression { span: Span, expression: Expression<'text>, }, MatcherMissingSelectors { span: Span, }, MatcherVariantMissingKeys { span: Span, }, MatcherVariantExpressionBodyNotQuoted { span: Span, }, MatcherVariantMissingBody { span: Span, },
}
Expand description

Diagnostics that can be produced by the parser. Each diagnostic has a message that describes the error, and a span that indicates the location in the source text where the error occurred.

Fatal diagnostics indicate that the parser was unable to recover from the error, and the AST may be incomplete or incorrect. Non-fatal diagnostics indicate that the parser was able to recover from the error, and the AST still fully represents the input text, but the AST may still be invalid in some way (like escaping a character that can not be escaped).

Variants§

§

NumberMissingIntegralPart

Fields

§number: Number<'text>
§

NumberLeadingZeroIntegralPart

Fields

§number: Number<'text>
§

NumberMissingFractionalPart

Fields

§number: Number<'text>
§

NumberMissingExponentPart

Fields

§number: Number<'text>
§

OptionMissingKey

Fields

§span: Span
§

OptionMissingValue

Fields

§span: Span
§

LoneEqualsSign

Fields

§

MarkupMissingIdentifier

Fields

§span: Span
§

MarkupInvalidSpaceBeforeIdentifier

Fields

§id: Identifier<'text>
§start_loc: Location
§

MarkupMissingClosingBrace

Fields

§span: Span
§

MarkupCloseInvalidSelfClose

Fields

§self_close_loc: Location
§

MarkupInvalidSpaceBetweenSelfCloseAndBrace

Fields

§space: Span
§

MarkupOptionAfterAttribute

Fields

§previous_attribute: Attribute<'text>
§option: FnOrMarkupOption<'text>
§

FunctionMissingIdentifier

Fields

§span: Span
§

UnterminatedQuoted

Fields

§span: Span
§

PlaceholderMissingClosingBrace

Fields

§span: Span
§

PlaceholderMissingBody

Fields

§span: Span
§

PlaceholderInvalidLiteral

Fields

§span: Span
§

PlaceholderInvalidContents

Fields

§span: Span
§

QuotedPatternInsidePattern

Fields

§open_span: Span
§close_span: Option<Span>
§

MarkupInvalidContents

Fields

§span: Span
§

MissingIdentifierName

Fields

§identifier: Identifier<'text>
§

MissingIdentifierNamespace

Fields

§identifier: Identifier<'text>
§

EscapeInvalidCharacter

Fields

§char_loc: Location
§char: char
§

EscapeMissingCharacter

Fields

§slash_loc: Location
§

InvalidNullCharacter

Fields

§char_loc: Location
§

InvalidClosingBrace

Fields

§brace_loc: Location
§

AnnotationMissingSpaceBefore

Fields

§span: Span
§

AttributeMissingSpaceBefore

Fields

§span: Span
§

AttributeMissingKey

Fields

§span: Span
§

AttributeMissingValue

Fields

§span: Span
§

AttributeValueIsVariable

Fields

§span: Span
§

VariableMissingName

Fields

§span: Span
§

UnterminatedQuotedPattern

Fields

§span: Span
§

LocalKeywordMissingTrailingSpace

Fields

§span: Span
§

LocalVariableMissingDollar

Fields

§span: Span
§

MissingSpaceBeforeMatcherSelector

Fields

§span: Span
§

MissingSpaceBeforeMatcherKey

Fields

§span: Span
§

ComplexMessageMissingBody

Fields

§span: Span
§

ComplexMessageTrailingContent

Fields

§span: Span
§

ComplexMessageBodyNotQuoted

Fields

§span: Span
§

ComplexMessageDeclarationAfterBody

Fields

§span: Span
§

ComplexMessageMultipleBodies

Fields

§span: Span
§

MatcherKeyIsVariable

Fields

§span: Span
§

InvalidMatcherLiteralKey

Fields

§span: Span
§

InvalidStatement

Fields

§span: Span
§keyword: &'text str
§

LocalDeclarationMalformed

Fields

§span: Span
§

LocalDeclarationValueNotWrappedInBraces

Fields

§span: Span
§

LocalDeclarationVariableMissingTrailingEquals

Fields

§span: Span
§

LocalDeclarationMissingExpression

Fields

§span: Span
§

InputDeclarationMissingExpression

Fields

§span: Span
§

InputDeclarationWithInvalidExpression

Fields

§span: Span
§expression: Expression<'text>
§

MatcherMissingSelectors

Fields

§span: Span
§

MatcherVariantMissingKeys

Fields

§span: Span
§

MatcherVariantExpressionBodyNotQuoted

Fields

§span: Span
§

MatcherVariantMissingBody

Fields

§span: Span

Implementations§

source§

impl<'text> Diagnostic<'text>

source

pub fn span(&self) -> Span

Get the span of the diagnostic.

source

pub fn message(&self) -> String

Get a human-readable message describing the diagnostic.

source

pub fn fatal(&self) -> bool

Check if the diagnostic is fatal. Fatal diagnostics indicate that the parser was unable to recover from the error, and the AST may be incomplete or incorrect.

Non-fatal diagnostics indicate that the parser was able to recover from the error, and the AST still fully represents the input text, but the AST may still be invalid in some way (like escaping a character that can not be escaped).

Trait Implementations§

source§

impl Debug for Diagnostic<'_>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Diagnostic<'_>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'text> Freeze for Diagnostic<'text>

§

impl<'text> RefUnwindSafe for Diagnostic<'text>

§

impl<'text> Send for Diagnostic<'text>

§

impl<'text> Sync for Diagnostic<'text>

§

impl<'text> Unpin for Diagnostic<'text>

§

impl<'text> UnwindSafe for Diagnostic<'text>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.