Struct rustc_ap_rustc_errors::Diagnostic [−][src]
#[must_use]pub struct Diagnostic { pub level: Level, pub message: Vec<(String, Style)>, pub code: Option<DiagnosticId>, pub span: MultiSpan, pub children: Vec<SubDiagnostic>, pub suggestions: Vec<CodeSuggestion>, pub sort_span: Span, }
Fields
level: Level
message: Vec<(String, Style)>
code: Option<DiagnosticId>
span: MultiSpan
children: Vec<SubDiagnostic>
suggestions: Vec<CodeSuggestion>
sort_span: Span
This is not used for highlighting or rendering any error message. Rather, it can be used
as a sort key to sort a buffer of diagnostics. By default, it is the primary span of
span
if there is one. Otherwise, it is DUMMY_SP
.
Implementations
impl Diagnostic
[src]
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 has_future_breakage(&self) -> bool
[src]
pub fn cancel(&mut self)
[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 cancelled(&self) -> bool
[src]Check if this diagnostic was cancelled.
pub fn span_label<T: Into<String>>(&mut self, span: Span, label: T) -> &mut Self
[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. That means it will be shown together with the original
span/label, not a span added by one of the span_{note,warn,help,suggestions}
methods.
This span is not considered a “primary span”; only
the Span
supplied when creating the diagnostic is primary.
pub fn replace_span_with(&mut self, after: Span) -> &mut Self
[src]
pub fn note_expected_found_extra(
&mut self,
expected_label: &dyn Display,
expected: DiagnosticStyledString,
found_label: &dyn Display,
found: DiagnosticStyledString,
expected_extra: &dyn Display,
found_extra: &dyn Display
) -> &mut Self
[src]
&mut self,
expected_label: &dyn Display,
expected: DiagnosticStyledString,
found_label: &dyn Display,
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 highlighted_note(&mut self, msg: Vec<(String, Style)>) -> &mut Self
[src]
pub fn multipart_suggestion(
&mut self,
msg: &str,
suggestion: Vec<(Span, String)>,
applicability: Applicability
) -> &mut Self
[src]
pub fn multipart_suggestion(
&mut self,
msg: &str,
suggestion: Vec<(Span, String)>,
applicability: Applicability
) -> &mut Self
[src]Show a suggestion that has multiple parts to it. In other words, multiple changes need to be applied as part of this suggestion.
pub fn multipart_suggestion_with_style(
&mut self,
msg: &str,
suggestion: Vec<(Span, String)>,
applicability: Applicability,
style: SuggestionStyle
) -> &mut Self
[src]
pub fn multipart_suggestion_with_style(
&mut self,
msg: &str,
suggestion: Vec<(Span, String)>,
applicability: Applicability,
style: SuggestionStyle
) -> &mut Self
[src]Diagnostic::multipart_suggestion()
but you can set the SuggestionStyle
.
pub fn tool_only_multipart_suggestion(
&mut self,
msg: &str,
suggestion: Vec<(Span, String)>,
applicability: Applicability
) -> &mut Self
[src]
pub fn tool_only_multipart_suggestion(
&mut self,
msg: &str,
suggestion: Vec<(Span, String)>,
applicability: Applicability
) -> &mut Self
[src]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]
pub fn span_suggestion(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
[src]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_suggestion_with_style(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability,
style: SuggestionStyle
) -> &mut Self
[src]
pub fn span_suggestion_with_style(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability,
style: SuggestionStyle
) -> &mut Self
[src]Diagnostic::span_suggestion()
but you can set the SuggestionStyle
.
pub fn span_suggestion_verbose(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
[src]
pub fn span_suggestion_verbose(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
[src]Always show the suggested change.
pub fn span_suggestions(
&mut self,
sp: Span,
msg: &str,
suggestions: impl Iterator<Item = String>,
applicability: Applicability
) -> &mut Self
[src]
pub fn span_suggestions(
&mut self,
sp: Span,
msg: &str,
suggestions: impl Iterator<Item = String>,
applicability: Applicability
) -> &mut Self
[src]Prints out a message with multiple suggested edits of the code.
See also Diagnostic::span_suggestion()
.
pub fn span_suggestion_short(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
[src]
pub fn span_suggestion_short(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
[src]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.
pub fn span_suggestion_hidden(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
[src]
pub fn span_suggestion_hidden(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
[src]Prints out a message 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]
pub fn tool_only_span_suggestion(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
[src]Adds a suggestion to the JSON output that will not be shown 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 tool_only_suggestion_with_metadata(
&mut self,
msg: &str,
applicability: Applicability,
tool_metadata: Json
)
[src]
pub fn tool_only_suggestion_with_metadata(
&mut self,
msg: &str,
applicability: Applicability,
tool_metadata: Json
)
[src]Adds a suggestion intended only for a tool. The intent is that the metadata encodes the suggestion in a tool-specific way, as it may not even directly involve Rust code.
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 clear_code(&mut self) -> &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]
Trait Implementations
impl Clone for Diagnostic
[src]
impl Clone for Diagnostic
[src]fn clone(&self) -> Diagnostic
[src]
fn clone(&self) -> Diagnostic
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[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 Debug for Diagnostic
[src]impl<__D: Decoder> Decodable<__D> for Diagnostic
[src]
impl<__D: Decoder> Decodable<__D> for Diagnostic
[src]impl<__E: Encoder> Encodable<__E> for Diagnostic
[src]
impl<__E: Encoder> Encodable<__E> for Diagnostic
[src]impl Hash for Diagnostic
[src]
impl Hash for Diagnostic
[src]impl PartialEq<Diagnostic> for Diagnostic
[src]
impl PartialEq<Diagnostic> for Diagnostic
[src]fn eq(&self, other: &Diagnostic) -> bool
[src]
fn eq(&self, other: &Diagnostic) -> bool
[src]This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &Diagnostic) -> bool
[src]
fn ne(&self, other: &Diagnostic) -> bool
[src]This method tests for !=
.
impl StructuralPartialEq for Diagnostic
[src]
Auto Trait Implementations
impl RefUnwindSafe for Diagnostic
impl !Send for Diagnostic
impl !Sync for Diagnostic
impl Unpin for Diagnostic
impl UnwindSafe for Diagnostic
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> MaybeResult<T> for T
[src]
impl<T> MaybeResult<T> for T
[src]impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<'a, T> Captures<'a> for T where
T: ?Sized,
[src]
T: ?Sized,