Struct syntex_errors::diagnostic_builder::DiagnosticBuilder
[−]
[src]
#[must_use]pub struct DiagnosticBuilder<'a> { /* fields omitted */ }
Used for emitting structured error messages and other diagnostic information.
Methods
impl<'a> DiagnosticBuilder<'a>
[src]
fn emit(&mut self)
Emit the diagnostic.
fn span_label<T: Into<String>>(&mut self, span: Span, label: T) -> &mut Self
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: DiagnosticStyledString,
found: DiagnosticStyledString
) -> &mut Self
&mut self,
label: &Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString
) -> &mut Self
fn note_expected_found_extra(
&mut self,
label: &Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString,
expected_extra: &Display,
found_extra: &Display
) -> &mut Self
&mut self,
label: &Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString,
expected_extra: &Display,
found_extra: &Display
) -> &mut Self
fn note(&mut self, msg: &str) -> &mut Self
fn span_note<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self
fn warn(&mut self, msg: &str) -> &mut Self
fn span_warn<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self
fn help(&mut self, msg: &str) -> &mut Self
fn span_help<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self
fn span_suggestion(
&mut self,
sp: Span,
msg: &str,
suggestion: String
) -> &mut Self
&mut self,
sp: Span,
msg: &str,
suggestion: String
) -> &mut Self
fn span_suggestions(
&mut self,
sp: Span,
msg: &str,
suggestions: Vec<String>
) -> &mut Self
&mut self,
sp: Span,
msg: &str,
suggestions: Vec<String>
) -> &mut Self
fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self
fn code(&mut self, s: String) -> &mut Self
fn new(
handler: &'a Handler,
level: Level,
message: &str
) -> DiagnosticBuilder<'a>
handler: &'a Handler,
level: Level,
message: &str
) -> DiagnosticBuilder<'a>
Convenience function for internal use, clients should use one of the struct_* methods on Handler.
fn new_with_code(
handler: &'a Handler,
level: Level,
code: Option<String>,
message: &str
) -> DiagnosticBuilder<'a>
handler: &'a Handler,
level: Level,
code: Option<String>,
message: &str
) -> DiagnosticBuilder<'a>
Convenience function for internal use, clients should use one of the struct_* methods on Handler.
fn into_diagnostic(self) -> Diagnostic
Methods from Deref<Target = 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<T: Into<String>>(&mut self, span: Span, label: T) -> &mut Self
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: DiagnosticStyledString,
found: DiagnosticStyledString
) -> &mut Self
&mut self,
label: &Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString
) -> &mut Self
fn note_expected_found_extra(
&mut self,
label: &Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString,
expected_extra: &Display,
found_extra: &Display
) -> &mut Self
&mut self,
label: &Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString,
expected_extra: &Display,
found_extra: &Display
) -> &mut Self
fn note(&mut self, msg: &str) -> &mut Self
fn highlighted_note(&mut self, msg: Vec<(String, Style)>) -> &mut Self
fn span_note<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self
fn warn(&mut self, msg: &str) -> &mut Self
fn span_warn<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self
fn help(&mut self, msg: &str) -> &mut Self
fn span_help<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self
fn span_suggestion(
&mut self,
sp: Span,
msg: &str,
suggestion: String
) -> &mut Self
&mut self,
sp: Span,
msg: &str,
suggestion: String
) -> &mut Self
Prints out a message with a suggested edit of the code.
See diagnostic::CodeSuggestion
for more information.
fn span_suggestions(
&mut self,
sp: Span,
msg: &str,
suggestions: Vec<String>
) -> &mut Self
&mut self,
sp: Span,
msg: &str,
suggestions: Vec<String>
) -> &mut Self
fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self
fn code(&mut self, s: String) -> &mut Self
fn message(&self) -> String
fn styled_message(&self) -> &Vec<(String, Style)>
fn level(&self) -> Level
fn copy_details_not_message(&mut self, from: &Diagnostic)
Used by a lint. Copies over all details but the "main message".
Trait Implementations
impl<'a> Clone for DiagnosticBuilder<'a>
[src]
fn clone(&self) -> DiagnosticBuilder<'a>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<'a> Deref for DiagnosticBuilder<'a>
[src]
type Target = Diagnostic
The resulting type after dereferencing
fn deref(&self) -> &Diagnostic
The method called to dereference a value
impl<'a> DerefMut for DiagnosticBuilder<'a>
[src]
fn deref_mut(&mut self) -> &mut Diagnostic
The method called to mutably dereference a value
impl<'a> Debug for DiagnosticBuilder<'a>
[src]
impl<'a> Drop for DiagnosticBuilder<'a>
[src]
Destructor bomb - a DiagnosticBuilder
must be either emitted or cancelled
or we emit a bug.