Skip to main content

Error

Struct Error 

Source
pub struct Error {
    pub kind: ErrorKind,
    pub span: NodeSpan,
    pub declaration: Name,
    /* private fields */
}
Expand description

A type error: what went wrong, where, and in which declaration.

§Where the positions come from

The typer does not check the canonical AST directly — it translates it into its own Term language — but that translation now carries the canonical node’s [NodeSpan] along, and each constraint keeps the span of the term that produced it. So a unification failure knows the sub-expression it is about, and labels draws the caret there.

The declaration’s own span is still kept as span, for the one case that has no finer answer: an error whose origin came from a hand-built term, or from a canonical node the parser never spanned. Then the label degrades to the whole declaration rather than disappearing.

Fields§

§kind: ErrorKind§span: NodeSpan

Where the declaration the error was found in was written. Used only as the fallback described above.

§declaration: Name

That declaration’s name, which is what the note names: in a module of a hundred declarations, a caret is not much use without it when the diagnostic is rendered without a file (see compile_package).

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl PhaseError for Error

Type errors are about types, and Type’s Display writes them the way the source does — so the message can name both sides of a mismatch instead of dumping the typer’s internal representation.

Source§

fn labels(&self) -> Vec<SpanLabel>

A caret under the text that disagrees, and — when inference can say where the type it disagrees with came from — a second, secondary one under that.

Falls back to underlining the whole declaration when the failing constraint has no position, which is what a term built by hand, or one translated from a canonical node with no span, produces.

Source§

fn message(&self) -> String

One line naming what went wrong, in the vocabulary of the user’s source. Read more
Source§

fn notes(&self) -> Vec<String>

Supporting detail, one string per rendered note. Empty by default.
Source§

fn message_and_notes(&self) -> Vec<String>

This error’s message followed by its notes. Read more

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl UnwindSafe for Error

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, 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.