Struct lexx::DiagnosticBuilder [] [src]

#[must_use]
pub struct DiagnosticBuilder<'a> {
    pub level: Level,
    pub message: String,
    pub code: Option<String>,
    pub span: MultiSpan,
    pub children: Vec<SubDiagnostic>,
    // some fields omitted
}

Used for emitting structured error messages and other diagnostic information.

Fields

level: Level message: String code: Option<String> span: MultiSpan children: Vec<SubDiagnostic>

Methods

impl<'a> DiagnosticBuilder<'a>

fn emit(&mut self)

Emit the diagnostic.

fn cancel(&mut self)

Cancel the diagnostic (a structured diagnostic must either be emitted or cancelled or it will panic when dropped). BEWARE: if this DiagnosticBuilder is an error, then creating it will bump the error count on the Handler and cancelling it won't undo that. If you want to decrement the error count you should use Handler::cancel.

fn cancelled(&self) -> bool

fn is_fatal(&self) -> bool

fn span_label(&mut self, span: Span, label: &Display) -> &mut DiagnosticBuilder<'a>

Add a span/label to be included in the resulting snippet. This is pushed onto the MultiSpan that was created when the diagnostic was first built. If you don't call this function at all, and you just supplied a Span to create the diagnostic, then the snippet will just include that Span, which is called the primary span.

fn note_expected_found(&mut self, label: &Display, expected: &Display, found: &Display) -> &mut DiagnosticBuilder<'a>

fn note_expected_found_extra(&mut self, label: &Display, expected: &Display, found: &Display, expected_extra: &Display, found_extra: &Display) -> &mut DiagnosticBuilder<'a>

fn note(&mut self, msg: &str) -> &mut DiagnosticBuilder<'a>

fn span_note<S>(&mut self, sp: S, msg: &str) -> &mut DiagnosticBuilder<'a> where S: Into<MultiSpan>

fn warn(&mut self, msg: &str) -> &mut DiagnosticBuilder<'a>

fn span_warn<S>(&mut self, sp: S, msg: &str) -> &mut DiagnosticBuilder<'a> where S: Into<MultiSpan>

fn help(&mut self, msg: &str) -> &mut DiagnosticBuilder<'a>

fn span_help<S>(&mut self, sp: S, msg: &str) -> &mut DiagnosticBuilder<'a> where S: Into<MultiSpan>

fn span_suggestion<S>(&mut self, sp: S, msg: &str, suggestion: String) -> &mut DiagnosticBuilder<'a> where S: Into<MultiSpan>

Prints out a message with a suggested edit of the code.

See diagnostic::RenderSpan::Suggestion for more information.

fn set_span<S>(&mut self, sp: S) -> &mut DiagnosticBuilder<'a> where S: Into<MultiSpan>

fn code(&mut self, s: String) -> &mut DiagnosticBuilder<'a>

fn message(&self) -> &str

fn level(&self) -> Level

Trait Implementations

impl<'a> Clone for DiagnosticBuilder<'a>

fn clone(&self) -> DiagnosticBuilder<'a>

impl<'a> Debug for DiagnosticBuilder<'a>

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

impl<'a> Drop for DiagnosticBuilder<'a>

Destructor bomb - a DiagnosticBuilder must be either emitted or cancelled or we emit a bug.

fn drop(&mut self)