pub struct Diagnostic {
pub level: DiagnosticLevel,
pub labels: Labels,
pub subdiagnostics: Vec<Subdiagnostic>,
}
Expand description
Something that is wrong in the code.
Fields§
§level: DiagnosticLevel
§labels: Labels
§subdiagnostics: Vec<Subdiagnostic>
Extra diagnostics that are shown after the main diagnostic.
Implementations§
Source§impl Diagnostic
impl Diagnostic
fn new( level: DiagnosticLevel, span: impl Into<FullSpan>, message: impl Into<Message>, ) -> Self
Sourcepub fn bug(span: impl Into<FullSpan>, message: impl Into<Message>) -> Self
pub fn bug(span: impl Into<FullSpan>, message: impl Into<Message>) -> Self
Report that something happened in the compiler that shouldn’t be possible. This signifies that something is wrong with the compiler. It will include a large footer instructing the user to create an issue or otherwise get in touch.
Sourcepub fn error(span: impl Into<FullSpan>, message: impl Into<Message>) -> Self
pub fn error(span: impl Into<FullSpan>, message: impl Into<Message>) -> Self
Report that something is wrong with the supplied code.
pub fn level(self, level: DiagnosticLevel) -> Self
pub fn message(self, message: impl Into<Message>) -> Self
Sourcepub fn primary_label(self, primary_label: impl Into<Message>) -> Self
pub fn primary_label(self, primary_label: impl Into<Message>) -> Self
Attach a message to the primary label of this diagnostic.
Sourcepub fn secondary_label(
self,
span: impl Into<FullSpan>,
message: impl Into<Message>,
) -> Self
pub fn secondary_label( self, span: impl Into<FullSpan>, message: impl Into<Message>, ) -> Self
Attach a secondary label to this diagnostic.
Sourcepub fn note(self, message: impl Into<Message>) -> Self
pub fn note(self, message: impl Into<Message>) -> Self
Attach a simple (one-line) note to this diagnostic.
Sourcepub fn add_note(&mut self, message: impl Into<Message>) -> &mut Self
pub fn add_note(&mut self, message: impl Into<Message>) -> &mut Self
Attach a simple (one-line) note to this diagnostic.
Modifying version of Self::note.
Sourcepub fn help(self, message: impl Into<Message>) -> Self
pub fn help(self, message: impl Into<Message>) -> Self
Attach a simple (one-line) help to this diagnostic.
Builder version of Self::add_help.
Sourcepub fn add_help(&mut self, message: impl Into<Message>) -> &mut Self
pub fn add_help(&mut self, message: impl Into<Message>) -> &mut Self
Attach a simple (one-line) help to this diagnostic.
Modifying version of Self::help.
Sourcepub fn subdiagnostic(self, subdiagnostic: Subdiagnostic) -> Self
pub fn subdiagnostic(self, subdiagnostic: Subdiagnostic) -> Self
Attach a general subdiagnostic to this diagnostic.
Prefer a more specific convenicence method (see the crate documentation) if you can. This is intended for spanned notes since they need a builder in order to be constructed.
Sourcepub fn push_subdiagnostic(&mut self, subdiagnostic: Subdiagnostic) -> &mut Self
pub fn push_subdiagnostic(&mut self, subdiagnostic: Subdiagnostic) -> &mut Self
See Self::subdiagnostic.
pub fn span_suggest( self, message: impl Into<Message>, span: impl Into<FullSpan>, code: impl Into<String>, ) -> Self
Sourcepub fn span_suggest_insert_before(
self,
message: impl Into<Message>,
span: impl Into<FullSpan>,
code: impl Into<String>,
) -> Self
pub fn span_suggest_insert_before( self, message: impl Into<Message>, span: impl Into<FullSpan>, code: impl Into<String>, ) -> Self
Convenience method to suggest some code that can be inserted directly before some span.
Note that this will be after any preceding whitespace. Use
Diagnostic::span_suggest_insert_after
if you want the suggestion to insert before
preceding whitespace.
Sourcepub fn span_suggest_insert_after(
self,
message: impl Into<Message>,
span: impl Into<FullSpan>,
code: impl Into<String>,
) -> Self
pub fn span_suggest_insert_after( self, message: impl Into<Message>, span: impl Into<FullSpan>, code: impl Into<String>, ) -> Self
Convenience method to suggest some code that can be inserted directly after some span.
Note that this will be before any preceding whitespace. Use
Diagnostic::span_suggest_insert_before
if you want the suggestion to insert after
preceding whitespace.
Sourcepub fn span_suggest_replace(
self,
message: impl Into<Message>,
span: impl Into<FullSpan>,
code: impl Into<String>,
) -> Self
pub fn span_suggest_replace( self, message: impl Into<Message>, span: impl Into<FullSpan>, code: impl Into<String>, ) -> Self
Convenience method to suggest some code that can be replaced.
Sourcepub fn span_suggest_remove(
self,
message: impl Into<Message>,
span: impl Into<FullSpan>,
) -> Self
pub fn span_suggest_remove( self, message: impl Into<Message>, span: impl Into<FullSpan>, ) -> Self
Convenience method to suggest some code that can be removed.
Sourcepub fn span_suggest_multipart(
self,
message: impl Into<Message>,
parts: SuggestionParts,
) -> Self
pub fn span_suggest_multipart( self, message: impl Into<Message>, parts: SuggestionParts, ) -> Self
Suggest a change that consists of multiple parts.
Sourcepub fn push_span_suggest_multipart(
&mut self,
message: impl Into<Message>,
SuggestionParts: SuggestionParts,
) -> &mut Self
pub fn push_span_suggest_multipart( &mut self, message: impl Into<Message>, SuggestionParts: SuggestionParts, ) -> &mut Self
Suggest a change that consists of multiple parts, but usable outside of builders.
pub fn type_error( self, expected: String, expected_outer: Option<String>, got: String, got_outer: Option<String>, ) -> Self
Trait Implementations§
Source§impl Clone for Diagnostic
impl Clone for Diagnostic
Source§fn clone(&self) -> Diagnostic
fn clone(&self) -> Diagnostic
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl CompilationError for Diagnostic
impl CompilationError for Diagnostic
fn report( &self, buffer: &mut Buffer, code: &CodeBundle, diag_handler: &mut DiagHandler, )
Source§impl Debug for Diagnostic
impl Debug for Diagnostic
Source§impl PartialEq for Diagnostic
impl PartialEq for Diagnostic
impl StructuralPartialEq for Diagnostic
Auto Trait Implementations§
impl Freeze for Diagnostic
impl RefUnwindSafe for Diagnostic
impl Send for Diagnostic
impl Sync for Diagnostic
impl Unpin for Diagnostic
impl UnwindSafe for Diagnostic
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more