Skip to main content

InlineError

Struct InlineError 

Source
pub struct InlineError {
    pub message: String,
    pub span: Option<(usize, usize)>,
    pub annotations: Vec<DiagnosticAnnotation>,
    pub notes: Vec<String>,
    pub helps: Vec<String>,
}
Expand description

User-facing diagnostic collected during parsing.

Fields§

§message: String

Primary message for the diagnostic.

§span: Option<(usize, usize)>

Primary span, if the diagnostic has one.

§annotations: Vec<DiagnosticAnnotation>

Additional annotated spans.

§notes: Vec<String>

Explanatory notes.

§helps: Vec<String>

Suggested fixes or next steps.

Implementations§

Source§

impl InlineError

Source

pub fn new(message: impl Into<String>) -> Self

Create a new diagnostic with message and no span.

Source

pub fn at(span: (usize, usize), message: impl Into<String>) -> Self

Create a new diagnostic anchored at span.

Source

pub fn reporting_span(&self) -> (usize, usize)

Span used when reporting (falls back to (0, 0) if unset).

Source

pub fn with_span(self, span: Option<(usize, usize)>) -> Self

Return a copy of this diagnostic with span replaced.

Source

pub fn set_span(&mut self, span: Option<(usize, usize)>) -> &mut Self

Replace the primary span in place.

Source

pub fn with_note(self, note: impl Into<String>) -> Self

Return a copy of this diagnostic with an additional note.

Source

pub fn add_note(&mut self, note: impl Into<String>) -> &mut Self

Add a note in place.

Source

pub fn with_help(self, help: impl Into<String>) -> Self

Return a copy of this diagnostic with an additional help message.

Source

pub fn add_help(&mut self, help: impl Into<String>) -> &mut Self

Add a help message in place.

Source

pub fn with_annotation( self, span: (usize, usize), message: impl Into<String>, kind: AnnotationKind, ) -> Self

Return a copy of this diagnostic with an additional annotation.

Source

pub fn add_annotation( &mut self, span: (usize, usize), message: impl Into<String>, kind: AnnotationKind, ) -> &mut Self

Add an annotation in place.

Source

pub fn eprint(&self, source_id: &str, source_text: &str)

Available on crate feature annotate-snippets only.

Print to stderr (requires annotate-snippets feature).

Source

pub fn write(&self, source_id: &str, source_text: &str, sink: impl Write)

Available on crate feature annotate-snippets only.

Write to sink (requires annotate-snippets feature).

Trait Implementations§

Source§

impl Clone for InlineError

Source§

fn clone(&self) -> InlineError

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 Debug for InlineError

Source§

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

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

impl Display for InlineError

Source§

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

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

impl From<InlineError> for ParserError

Source§

fn from(value: InlineError) -> Self

Converts to this type from the input type.

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 = 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.
Source§

impl<I> WithLabel for I

Source§

fn with_label<L>(self, label: L) -> Labeled<L, I>

Same as Labeled::new(label, self).
Source§

impl<I> WithTrace for I

Source§

fn trace(self) -> Traced<I>

Trace this parser or matcher using its existing label (if any).
Source§

fn trace_with_label(self, label: impl Into<String>) -> Traced<I>

Trace this parser or matcher with an explicit label.