Enum Diagnostic
#[non_exhaustive]pub enum Diagnostic {
SourceContainsPua {
at: SourceSpan,
codepoint: char,
span: Span,
},
UnclosedBracket {
at: SourceSpan,
kind: PairKind,
span: Span,
},
UnmatchedClose {
at: SourceSpan,
kind: PairKind,
span: Span,
},
Internal {
at: SourceSpan,
check: InternalCheckCode,
span: Span,
},
}Expand description
Observation emitted by any lexer phase.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
SourceContainsPua
Source contains a codepoint that collides with one of the
lexer’s PUA sentinel reservations
(crate::INLINE_SENTINEL, crate::BLOCK_LEAF_SENTINEL,
crate::BLOCK_OPEN_SENTINEL, crate::BLOCK_CLOSE_SENTINEL).
Downstream phases will emit those same codepoints into normalized
text, so a collision means the placeholder registry can no longer
distinguish source-text occurrences from lexer-inserted markers.
Fields
at: SourceSpanspan: SpanByte-range in the original source for programmatic consumers
that don’t need miette’s [miette::SourceSpan].
UnclosedBracket
An open delimiter reached end-of-input with no matching close on the pairing stack.
Fields
at: SourceSpankind: PairKindspan: SpanByte-range of the unmatched open delimiter in the sanitized source.
UnmatchedClose
A close delimiter was seen with an empty stack, or with a stack
top of a different [PairKind].
Internal
Pipeline-internal sanity-check failure — production parses on
well-formed input never emit this. The check
payload identifies the specific check via the typed
[InternalCheckCode] enum; tooling that prefers the stable
string identifier reaches via
Self::code. Library consumers that just want
to filter “library bugs” out of the stream check
source instead.
Implementations§
§impl Diagnostic
impl Diagnostic
pub fn source_contains_pua(at: Span, codepoint: char) -> Diagnostic
pub fn source_contains_pua(at: Span, codepoint: char) -> Diagnostic
Constructor for Diagnostic::SourceContainsPua.
pub fn unclosed_bracket(at: Span, kind: PairKind) -> Diagnostic
pub fn unclosed_bracket(at: Span, kind: PairKind) -> Diagnostic
Constructor for Diagnostic::UnclosedBracket.
pub fn unmatched_close(at: Span, kind: PairKind) -> Diagnostic
pub fn unmatched_close(at: Span, kind: PairKind) -> Diagnostic
Constructor for Diagnostic::UnmatchedClose.
pub fn internal(at: Span, check: InternalCheckCode) -> Diagnostic
pub fn internal(at: Span, check: InternalCheckCode) -> Diagnostic
Constructor for Diagnostic::Internal. Takes a typed
[InternalCheckCode] — the compiler enforces that every
production emit-site classifies the check correctly.
pub fn severity(&self) -> Severity
pub fn severity(&self) -> Severity
Severity routing axis. See Severity.
#[non_exhaustive] puts the responsibility on every match
here for adding-new-variant time, not on a catch-all arm —
the compiler will refuse to build until the new variant is
classified.
pub fn source(&self) -> DiagnosticSource
pub fn source(&self) -> DiagnosticSource
Origin axis: user input vs. pipeline-internal. See
DiagnosticSource.
pub fn span(&self) -> Span
pub fn span(&self) -> Span
Byte-range covering the diagnostic.
Trait Implementations§
§impl Clone for Diagnostic
impl Clone for Diagnostic
§fn clone(&self) -> Diagnostic
fn clone(&self) -> Diagnostic
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for Diagnostic
impl Debug for Diagnostic
§impl Diagnostic for Diagnostic
impl Diagnostic for Diagnostic
§fn code(&self) -> Option<Box<dyn Display + '_>>
fn code(&self) -> Option<Box<dyn Display + '_>>
Diagnostic. Ideally also globally unique, and documented
in the toplevel crate’s documentation for easy searching. Rust path
format (foo::bar::baz) is recommended, but more classic codes like
E0123 or enums will work just fine.§fn help(&self) -> Option<Box<dyn Display + '_>>
fn help(&self) -> Option<Box<dyn Display + '_>>
Diagnostic. Do you have any
advice for the poor soul who’s just run into this issue?§fn severity(&self) -> Option<Severity>
fn severity(&self) -> Option<Severity>
ReportHandlers to change the display format
of this diagnostic. Read more§fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
Diagnostic’s [Diagnostic::source_code]§fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic.§fn source_code(&self) -> Option<&dyn SourceCode>
fn source_code(&self) -> Option<&dyn SourceCode>
Diagnostic’s [Diagnostic::labels] to.Diagnostics.§fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
§impl Display for Diagnostic
impl Display for Diagnostic
§impl Error for Diagnostic
impl Error for Diagnostic
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Auto Trait Implementations§
impl Freeze for Diagnostic
impl RefUnwindSafe for Diagnostic
impl Send for Diagnostic
impl Sync for Diagnostic
impl Unpin for Diagnostic
impl UnsafeUnpin for Diagnostic
impl UnwindSafe for Diagnostic
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more