[−][src]Trait diagnostics::Printable
This abstraction allows us to call the diagnostics API with pretty much everything.
The following examples are all equivalent and will print a warning without a source code snippet below the message:
ⓘThis example is not tested
context.diagnostics.warning(&"Something went wrong"); context .diagnostics .warning(&WithoutSpan("Something went wrong"));
The following examples will print a message with a source code
snippet. Note that all errors generated by the compiler are
a Spanned<_, Fail>
and can therefore be directly passed to
the diagnostics API.
ⓘThis example is not tested
// `lexer_error` is the `Err` returned by `Lexer::next` context.diagnostics.error(&lexer_error); // `span` is some `asciifile::Span` context.diagnostics.error({ span: span, data: "something went wrong" });
Required methods
fn as_maybe_spanned(&'b self) -> MaybeSpanned<'a, &'b dyn Display>
Implementations on Foreign Types
impl<'a, 'b> Printable<'a, 'b> for &'b str
[src]
impl<'a, 'b> Printable<'a, 'b> for &'b str
fn as_maybe_spanned(&'b self) -> MaybeSpanned<'a, &'b dyn Display>
[src]
fn as_maybe_spanned(&'b self) -> MaybeSpanned<'a, &'b dyn Display>
impl<'a, 'b, T: Display + 'b> Printable<'a, 'b> for Spanned<'a, T>
[src]
impl<'a, 'b, T: Display + 'b> Printable<'a, 'b> for Spanned<'a, T>
fn as_maybe_spanned(&'b self) -> MaybeSpanned<'a, &'b dyn Display>
[src]
fn as_maybe_spanned(&'b self) -> MaybeSpanned<'a, &'b dyn Display>
impl<'a, 'b, T: Display + 'b> Printable<'a, 'b> for MaybeSpanned<'a, T>
[src]
impl<'a, 'b, T: Display + 'b> Printable<'a, 'b> for MaybeSpanned<'a, T>
fn as_maybe_spanned(&'b self) -> MaybeSpanned<'a, &'b dyn Display>
[src]
fn as_maybe_spanned(&'b self) -> MaybeSpanned<'a, &'b dyn Display>