pub struct Diag {
pub messages: Vec<(DiagMsg, Style)>,
pub span: MultiSpan,
pub children: Vec<SubDiagnostic>,
pub code: Option<DiagId>,
pub created_at: &'static Location<'static>,
/* private fields */
}
Expand description
A compiler diagnostic.
Fields§
§messages: Vec<(DiagMsg, Style)>
§span: MultiSpan
§children: Vec<SubDiagnostic>
§code: Option<DiagId>
§created_at: &'static Location<'static>
Implementations§
Source§impl Diag
impl Diag
Source§impl Diag
Setters.
impl Diag
Setters.
Sourcepub fn span(&mut self, span: impl Into<MultiSpan>) -> &mut Self
pub fn span(&mut self, span: impl Into<MultiSpan>) -> &mut Self
Sets the span of this diagnostic.
Sourcepub fn span_label(&mut self, span: Span, label: impl Into<DiagMsg>) -> &mut Self
pub fn span_label(&mut self, span: Span, label: impl Into<DiagMsg>) -> &mut Self
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.
Sourcepub fn span_labels(
&mut self,
spans: impl IntoIterator<Item = Span>,
label: impl Into<DiagMsg>,
) -> &mut Self
pub fn span_labels( &mut self, spans: impl IntoIterator<Item = Span>, label: impl Into<DiagMsg>, ) -> &mut Self
Labels all the given spans with the provided label.
See Self::span_label()
for more information.
Source§impl Diag
Sub-diagnostics.
impl Diag
Sub-diagnostics.
Sourcepub fn warn(&mut self, msg: impl Into<DiagMsg>) -> &mut Self
pub fn warn(&mut self, msg: impl Into<DiagMsg>) -> &mut Self
Add a warning attached to this diagnostic.
Sourcepub fn span_warn(
&mut self,
span: impl Into<MultiSpan>,
msg: impl Into<DiagMsg>,
) -> &mut Self
pub fn span_warn( &mut self, span: impl Into<MultiSpan>, msg: impl Into<DiagMsg>, ) -> &mut Self
Prints the span with a warning above it.
This is like Diag::warn()
, but it gets its own span.
Sourcepub fn span_note(
&mut self,
span: impl Into<MultiSpan>,
msg: impl Into<DiagMsg>,
) -> &mut Self
pub fn span_note( &mut self, span: impl Into<MultiSpan>, msg: impl Into<DiagMsg>, ) -> &mut Self
Prints the span with a note above it.
This is like Diag::note()
, but it gets its own span.
pub fn highlighted_note( &mut self, messages: Vec<(impl Into<DiagMsg>, Style)>, ) -> &mut Self
Sourcepub fn note_once(&mut self, msg: impl Into<DiagMsg>) -> &mut Self
pub fn note_once(&mut self, msg: impl Into<DiagMsg>) -> &mut Self
Prints the span with a note above it.
This is like Diag::note()
, but it gets emitted only once.
Sourcepub fn span_note_once(
&mut self,
span: impl Into<MultiSpan>,
msg: impl Into<DiagMsg>,
) -> &mut Self
pub fn span_note_once( &mut self, span: impl Into<MultiSpan>, msg: impl Into<DiagMsg>, ) -> &mut Self
Prints the span with a note above it.
This is like Diag::note_once()
, but it gets its own span.
Sourcepub fn help(&mut self, msg: impl Into<DiagMsg>) -> &mut Self
pub fn help(&mut self, msg: impl Into<DiagMsg>) -> &mut Self
Add a help message attached to this diagnostic.
Sourcepub fn help_once(&mut self, msg: impl Into<DiagMsg>) -> &mut Self
pub fn help_once(&mut self, msg: impl Into<DiagMsg>) -> &mut Self
Prints the span with a help above it.
This is like Diag::help()
, but it gets its own span.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Diag
impl RefUnwindSafe for Diag
impl Send for Diag
impl Sync for Diag
impl Unpin for Diag
impl UnwindSafe for Diag
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, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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