Struct rustc_errors::Diagnostic
source · pub struct Diagnostic {
pub(crate) level: Level,
pub messages: Vec<(DiagnosticMessage, Style)>,
pub code: Option<ErrCode>,
pub span: MultiSpan,
pub children: Vec<SubDiagnostic>,
pub suggestions: Result<Vec<CodeSuggestion>, SuggestionsDisabled>,
args: FxIndexMap<DiagnosticArgName, DiagnosticArgValue>,
pub sort_span: Span,
pub is_lint: Option<IsLint>,
pub(crate) emitted_at: DiagnosticLocation,
}Expand description
The main part of a diagnostic. Note that DiagnosticBuilder, which wraps
this type, is used for most operations, and should be used instead whenever
possible. This type should only be used when DiagnosticBuilder’s lifetime
causes difficulties, e.g. when storing diagnostics within DiagCtxt.
Fields§
§level: Level§messages: Vec<(DiagnosticMessage, Style)>§code: Option<ErrCode>§span: MultiSpan§children: Vec<SubDiagnostic>§suggestions: Result<Vec<CodeSuggestion>, SuggestionsDisabled>§args: FxIndexMap<DiagnosticArgName, DiagnosticArgValue>§sort_span: SpanThis 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.
is_lint: Option<IsLint>§emitted_at: DiagnosticLocationWith -Ztrack_diagnostics enabled,
we print where in rustc this error was emitted.
Implementations§
source§impl Diagnostic
impl Diagnostic
pub fn new<M: Into<DiagnosticMessage>>(level: Level, message: M) -> Self
pub fn new_with_messages( level: Level, messages: Vec<(DiagnosticMessage, Style)> ) -> Self
pub fn level(&self) -> Level
pub fn is_error(&self) -> bool
pub(crate) fn update_unstable_expectation_id( &mut self, unstable_to_stable: &FxIndexMap<LintExpectationId, LintExpectationId> )
sourcepub(crate) fn has_future_breakage(&self) -> bool
pub(crate) fn has_future_breakage(&self) -> bool
Indicates whether this diagnostic should show up in cargo’s future breakage report.
pub(crate) fn is_force_warn(&self) -> bool
pub(crate) fn subdiagnostic_message_to_diagnostic_message( &self, attr: impl Into<SubdiagnosticMessage> ) -> DiagnosticMessage
pub(crate) fn sub( &mut self, level: Level, message: impl Into<SubdiagnosticMessage>, span: MultiSpan )
pub(crate) fn arg( &mut self, name: impl Into<DiagnosticArgName>, arg: impl IntoDiagnosticArg )
pub fn args(&self) -> impl Iterator<Item = DiagnosticArg<'_>>
pub fn replace_args( &mut self, args: FxIndexMap<DiagnosticArgName, DiagnosticArgValue> )
source§impl Diagnostic
impl Diagnostic
sourcefn keys(
&self
) -> (&Level, &[(DiagnosticMessage, Style)], &Option<ErrCode>, &MultiSpan, &[SubDiagnostic], &Result<Vec<CodeSuggestion>, SuggestionsDisabled>, Vec<(&DiagnosticArgName, &DiagnosticArgValue)>, &Option<IsLint>)
fn keys( &self ) -> (&Level, &[(DiagnosticMessage, Style)], &Option<ErrCode>, &MultiSpan, &[SubDiagnostic], &Result<Vec<CodeSuggestion>, SuggestionsDisabled>, Vec<(&DiagnosticArgName, &DiagnosticArgValue)>, &Option<IsLint>)
Fields used for Hash, and PartialEq trait
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 Debug for Diagnostic
impl Debug for Diagnostic
source§impl<__D: SpanDecoder> Decodable<__D> for Diagnostic
impl<__D: SpanDecoder> Decodable<__D> for Diagnostic
source§impl<__E: SpanEncoder> Encodable<__E> for Diagnostic
impl<__E: SpanEncoder> Encodable<__E> for Diagnostic
source§impl Hash for Diagnostic
impl Hash for Diagnostic
Auto Trait Implementations§
impl DynSend for Diagnostic
impl DynSync for Diagnostic
impl RefUnwindSafe for Diagnostic
impl Send for Diagnostic
impl Sync for Diagnostic
impl Unpin for Diagnostic
impl UnwindSafe for Diagnostic
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§impl<T> Filterable for T
impl<T> Filterable 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>
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 280 bytes