#[repr(C, align(64))]pub struct Diagnostic {
pub severity: Severity,
pub start_cursor: Cursor,
pub end_cursor: Cursor,
pub desired_cursor: Option<Cursor>,
pub formatter: fn(&Diagnostic, &str) -> DiagnosticMeta,
}
Expand description
An issue that occured during parse time.
Fields§
§severity: Severity
How severe this error is.
start_cursor: Cursor
The first cursor where this error occured.
end_cursor: Cursor
The last cursor that was consumed to recover from this error.
desired_cursor: Option<Cursor>
A cursor representing what was expected.
formatter: fn(&Diagnostic, &str) -> DiagnosticMeta
Function pointer to format the message template with cursor/span data
Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn new(
start_cursor: Cursor,
formatter: fn(&Diagnostic, &str) -> DiagnosticMeta,
) -> Self
pub fn new( start_cursor: Cursor, formatter: fn(&Diagnostic, &str) -> DiagnosticMeta, ) -> Self
Create a new diagnostic
Sourcepub fn with_severity(self, severity: Severity) -> Self
pub fn with_severity(self, severity: Severity) -> Self
Apply a severity to the given Diagnostic.
Sourcepub fn with_end_cursor(self, end_cursor: Cursor) -> Self
pub fn with_end_cursor(self, end_cursor: Cursor) -> Self
Apply an end Cursor to the given Diagnostic.
Sourcepub fn with_desired_cursor(self, cursor: Cursor) -> Self
pub fn with_desired_cursor(self, cursor: Cursor) -> Self
Add a desired cursor (what was expected)
pub fn unexpected(diagnostic: &Diagnostic, _source: &str) -> DiagnosticMeta
pub fn unexpected_ident(diagnostic: &Diagnostic, source: &str) -> DiagnosticMeta
pub fn unexpected_delim( diagnostic: &Diagnostic, _source: &str, ) -> DiagnosticMeta
pub fn expected_ident(diagnostic: &Diagnostic, _source: &str) -> DiagnosticMeta
pub fn expected_delim(diagnostic: &Diagnostic, _source: &str) -> DiagnosticMeta
pub fn bad_declaration( _diagnostic: &Diagnostic, _source: &str, ) -> DiagnosticMeta
pub fn unknown_declaration( _diagnostic: &Diagnostic, _source: &str, ) -> DiagnosticMeta
pub fn expected_end(_diagnostic: &Diagnostic, _source: &str) -> DiagnosticMeta
pub fn unexpected_end(_diagnostic: &Diagnostic, _source: &str) -> DiagnosticMeta
pub fn unexpected_close_curly( _diagnostic: &Diagnostic, _source: &str, ) -> DiagnosticMeta
pub fn unexpected_tag(diagnostic: &Diagnostic, source: &str) -> DiagnosticMeta
pub fn unexpected_id(diagnostic: &Diagnostic, source: &str) -> DiagnosticMeta
Trait Implementations§
Source§impl Clone for Diagnostic
impl Clone for Diagnostic
Source§fn clone(&self) -> Diagnostic
fn clone(&self) -> Diagnostic
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Diagnostic
impl Debug for Diagnostic
impl Copy for Diagnostic
Auto Trait Implementations§
impl Freeze for Diagnostic
impl RefUnwindSafe for Diagnostic
impl Send for Diagnostic
impl Sync for Diagnostic
impl Unpin 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
Mutably borrows from an owned value. Read more