[−][src]Struct rustc_errors::Diagnostic
Fields
level: Level
message: Vec<(String, Style)>
code: Option<DiagnosticId>
span: MultiSpan
children: Vec<SubDiagnostic>
suggestions: Vec<CodeSuggestion>
Methods
impl Diagnostic
[src]
pub fn new(level: Level, message: &str) -> Self
[src]
pub fn new_with_code(
level: Level,
code: Option<DiagnosticId>,
message: &str
) -> Self
[src]
level: Level,
code: Option<DiagnosticId>,
message: &str
) -> Self
pub fn is_error(&self) -> bool
[src]
pub fn cancel(&mut self)
[src]
Cancel the diagnostic (a structured diagnostic must either be emitted or canceled or it will panic when dropped).
pub fn cancelled(&self) -> bool
[src]
pub fn span_label<T: Into<String>>(&mut self, span: Span, label: T) -> &mut Self
[src]
Adds 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.
pub fn replace_span_with(&mut self, after: Span) -> &mut Self
[src]
pub fn note_expected_found(
&mut self,
label: &dyn Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString
) -> &mut Self
[src]
&mut self,
label: &dyn Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString
) -> &mut Self
pub fn note_expected_found_extra(
&mut self,
label: &dyn Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString,
expected_extra: &dyn Display,
found_extra: &dyn Display
) -> &mut Self
[src]
&mut self,
label: &dyn Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString,
expected_extra: &dyn Display,
found_extra: &dyn Display
) -> &mut Self
pub fn note_trait_signature(
&mut self,
name: String,
signature: String
) -> &mut Self
[src]
&mut self,
name: String,
signature: String
) -> &mut Self
pub fn note(&mut self, msg: &str) -> &mut Self
[src]
pub fn highlighted_note(&mut self, msg: Vec<(String, Style)>) -> &mut Self
[src]
pub fn span_note<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self
[src]
pub fn warn(&mut self, msg: &str) -> &mut Self
[src]
pub fn span_warn<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self
[src]
pub fn help(&mut self, msg: &str) -> &mut Self
[src]
pub fn span_help<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self
[src]
pub fn multipart_suggestion(
&mut self,
msg: &str,
suggestion: Vec<(Span, String)>,
applicability: Applicability
) -> &mut Self
[src]
&mut self,
msg: &str,
suggestion: Vec<(Span, String)>,
applicability: Applicability
) -> &mut Self
pub fn tool_only_multipart_suggestion(
&mut self,
msg: &str,
suggestion: Vec<(Span, String)>,
applicability: Applicability
) -> &mut Self
[src]
&mut self,
msg: &str,
suggestion: Vec<(Span, String)>,
applicability: Applicability
) -> &mut Self
Prints out a message with for a multipart suggestion without showing the suggested code.
This is intended to be used for suggestions that are obvious in what the changes need to be from the message, showing the span label inline would be visually unpleasant (marginally overlapping spans or multiline spans) and showing the snippet window wouldn't improve understandability.
pub fn span_suggestion(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
[src]
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
Prints out a message with a suggested edit of the code.
In case of short messages and a simple suggestion, rustc displays it as a label:
try adding parentheses: `(tup.0).1`
The message
- should not end in any punctuation (a
:
is added automatically) - should not be a question (avoid language like "did you mean")
- should not contain any phrases like "the following", "as shown", etc.
- may look like "to do xyz, use" or "to do xyz, use abc"
- may contain a name of a function, variable, or type, but not whole expressions
See CodeSuggestion
for more information.
pub fn span_suggestions(
&mut self,
sp: Span,
msg: &str,
suggestions: impl Iterator<Item = String>,
applicability: Applicability
) -> &mut Self
[src]
&mut self,
sp: Span,
msg: &str,
suggestions: impl Iterator<Item = String>,
applicability: Applicability
) -> &mut Self
Prints out a message with multiple suggested edits of the code.
pub fn span_suggestion_short(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
[src]
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
Prints out a message with a suggested edit of the code. If the suggestion is presented inline, it will only show the message and not the suggestion.
See CodeSuggestion
for more information.
[src]
Prints out a message with for a suggestion without showing the suggested code.
This is intended to be used for suggestions that are obvious in what the changes need to be from the message, showing the span label inline would be visually unpleasant (marginally overlapping spans or multiline spans) and showing the snippet window wouldn't improve understandability.
pub fn tool_only_span_suggestion(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
[src]
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
Adds a suggestion to the json output, but otherwise remains silent/undisplayed in the cli.
This is intended to be used for suggestions that are very obvious in what the changes need to be from the message, but we still want other tools to be able to apply them.
pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self
[src]
pub fn code(&mut self, s: DiagnosticId) -> &mut Self
[src]
pub fn get_code(&self) -> Option<DiagnosticId>
[src]
pub fn message(&self) -> String
[src]
pub fn styled_message(&self) -> &Vec<(String, Style)>
[src]
pub fn copy_details_not_message(&mut self, from: &Diagnostic)
[src]
Used by a lint. Copies over all details but the "main message".
pub fn sub(
&mut self,
level: Level,
message: &str,
span: MultiSpan,
render_span: Option<MultiSpan>
)
[src]
&mut self,
level: Level,
message: &str,
span: MultiSpan,
render_span: Option<MultiSpan>
)
Convenience function for internal use, clients should use one of the public methods above.
Trait Implementations
impl PartialEq<Diagnostic> for Diagnostic
[src]
fn eq(&self, other: &Diagnostic) -> bool
[src]
fn ne(&self, other: &Diagnostic) -> bool
[src]
impl Clone for Diagnostic
[src]
fn clone(&self) -> Diagnostic
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Diagnostic
[src]
impl Hash for Diagnostic
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Encodable for Diagnostic
[src]
impl Decodable for Diagnostic
[src]
Auto Trait Implementations
impl !Send for Diagnostic
impl !Sync for Diagnostic
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Encodable for T where
T: UseSpecializedEncodable + ?Sized,
[src]
T: UseSpecializedEncodable + ?Sized,
impl<T> Decodable for T where
T: UseSpecializedDecodable,
[src]
T: UseSpecializedDecodable,
impl<E> SpecializationError for E
[src]
impl<T> Erased for T
[src]
impl<T> Send for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Sync for T where
T: ?Sized,
[src]
T: ?Sized,