Struct syntex_errors::diagnostic::Diagnostic
[−]
[src]
#[must_use]pub struct Diagnostic { pub level: Level, pub message: Vec<(String, Style)>, pub code: Option<String>, pub span: MultiSpan, pub children: Vec<SubDiagnostic>, }
Fields
level: Level
message: Vec<(String, Style)>
code: Option<String>
span: MultiSpan
children: Vec<SubDiagnostic>
Methods
impl Diagnostic
[src]
fn new(level: Level, message: &str) -> Self
fn new_with_code(level: Level, code: Option<String>, message: &str) -> Self
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 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: &Display,
found: &Display)
-> &mut Self
label: &Display,
expected: &Display,
found: &Display)
-> &mut Self
fn note_expected_found_extra(&mut self,
label: &Display,
expected: &Display,
found: &Display,
expected_extra: &Display,
found_extra: &Display)
-> &mut Self
label: &Display,
expected: &Display,
found: &Display,
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<S: Into<MultiSpan>>(&mut self,
sp: S,
msg: &str,
suggestion: String)
-> &mut Self
sp: S,
msg: &str,
suggestion: String)
-> &mut Self
Prints out a message with a suggested edit of the code.
See diagnostic::RenderSpan::Suggestion
for more information.
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 Clone for Diagnostic
[src]
fn clone(&self) -> Diagnostic
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 Debug for Diagnostic
[src]
impl PartialEq for Diagnostic
[src]
fn eq(&self, __arg_0: &Diagnostic) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Diagnostic) -> bool
This method tests for !=
.