Skip to main content

DiagnosticCode

Enum DiagnosticCode 

Source
#[non_exhaustive]
pub enum DiagnosticCode {
Show 25 variants Syntax, UnterminatedString, BadEscape, ReservedName, DuplicateName, DeclarationIncomplete, LiteralRequired, LimitDeclarations, DuplicateProp, DuplicateKey, MismatchedClose, UnclosedTag, ReplyForbidden, LimitTags, Nesting, NonAssoc, MixedCoalesce, NumberLiteral, ParseWork, LimitAst, LimitBlocks, LimitText, SourceTooLarge, ReferenceLimit, Encoding,
}
Expand description

A diagnostic’s stable code. New codes may be added in minor releases, so a match needs a wildcard arm; DiagnosticCode::as_str gives the code as it is written in documentation and logs, such as E_SYNTAX.

Naming every code without a wildcard arm does not compile outside this crate:

ⓘ
use cortexkit_rich_ui_syntax::DiagnosticCode as C;
fn rank(code: C) -> u8 {
    match code {
        C::Syntax => 0,
        C::UnterminatedString => 1,
        C::BadEscape => 2,
        C::ReservedName => 3,
        C::DuplicateName => 4,
        C::DeclarationIncomplete => 5,
        C::LiteralRequired => 6,
        C::LimitDeclarations => 7,
        C::DuplicateProp => 8,
        C::DuplicateKey => 9,
        C::MismatchedClose => 10,
        C::UnclosedTag => 11,
        C::ReplyForbidden => 12,
        C::LimitTags => 13,
        C::Nesting => 14,
        C::NonAssoc => 15,
        C::MixedCoalesce => 16,
        C::NumberLiteral => 17,
        C::ParseWork => 18,
        C::LimitAst => 19,
        C::LimitBlocks => 20,
        C::LimitText => 21,
        C::SourceTooLarge => 22,
        C::ReferenceLimit => 23,
        C::Encoding => 24,
    }
}

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Syntax

E_SYNTAX: source that fits no rule of the grammar.

§

UnterminatedString

E_UNTERMINATED_STRING: a string literal that reaches a raw line break, or the end of its construct, before its closing quote.

§

BadEscape

E_BAD_ESCAPE: an unknown escape in a string literal, or a \u{…} escape that is malformed or names no Unicode scalar value.

§

ReservedName

E_RESERVED_NAME: a declaration whose name is reserved.

§

DuplicateName

E_DUPLICATE_NAME: a second declaration of the same name.

§

DeclarationIncomplete

E_DECLARATION_INCOMPLETE: a declaration whose value expression is missing or cut short.

§

LiteralRequired

E_LITERAL_REQUIRED: a state initializer or handle path that is not a literal.

§

LimitDeclarations

E_LIMIT_DECLARATIONS: more than DECLARATIONS declarations.

§

DuplicateProp

E_DUPLICATE_PROP: a tag that sets the same prop twice.

§

DuplicateKey

E_DUPLICATE_KEY: a record literal that repeats a key.

§

MismatchedClose

E_MISMATCHED_CLOSE: a closing tag that does not close the open tag.

§

UnclosedTag

E_UNCLOSED_TAG: a paired tag without its closing tag.

§

ReplyForbidden

E_REPLY_FORBIDDEN: a reply tag prop outside the reply-value grammar.

§

LimitTags

E_LIMIT_TAGS: more than 64 tags in a reply.

§

Nesting

E_NESTING: a nesting limit was exceeded.

§

NonAssoc

E_NONASSOC: chained comparison or equality operators.

§

MixedCoalesce

E_MIXED_COALESCE: ?? mixed with && or || without grouping.

§

NumberLiteral

E_NUMBER_LITERAL: a number outside the exact decimal grammar.

§

ParseWork

E_PARSE_WORK: the deterministic parsing work allowance ran out.

§

LimitAst

E_LIMIT_AST: more than AST_NODES syntax nodes.

§

LimitBlocks

E_LIMIT_BLOCKS: more than BLOCKS Markdown blocks.

§

LimitText

E_LIMIT_TEXT: more than OUTPUT_SCALARS text scalars in a reply.

§

SourceTooLarge

E_SOURCE_TOO_LARGE: a program longer than PROGRAM_BYTES.

§

ReferenceLimit

E_REFERENCE_LIMIT: more than REFERENCES references or HANDLES handles.

§

Encoding

W_ENCODING: invalid UTF-8 was replaced before parsing.

Implementations§

Source§

impl DiagnosticCode

Source

pub const fn as_str(self) -> &'static str

The code as written in documentation and logs, such as E_SYNTAX.

Trait Implementations§

Source§

impl Clone for DiagnosticCode

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for DiagnosticCode

Source§

impl Debug for DiagnosticCode

Source§

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

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

impl Display for DiagnosticCode

Source§

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

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

impl Eq for DiagnosticCode

Source§

impl Hash for DiagnosticCode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for DiagnosticCode

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DiagnosticCode

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.