#[non_exhaustive]pub struct Diagnostic {
pub severity: Severity,
pub code: Arc<str>,
pub message: Arc<str>,
pub span: Option<Span>,
pub suggestion: Option<Arc<str>>,
pub limit_kind: Option<LimitKind>,
}Expand description
A non-fatal diagnostic.
code is a stable, machine-readable identifier like "TF1001"; tooling
uses it to allowlist / ignore specific diagnostics without matching the
message string. limit_kind is set on diagnostics emitted in response to
a configured cap breach, so consumers can pivot on the structured kind
rather than parsing the message.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.severity: SeveritySeverity.
code: Arc<str>Stable identifier (e.g. "TF1001", "TG2003").
message: Arc<str>Human-readable message; safe to log at the diagnostic’s severity.
span: Option<Span>Optional location.
suggestion: Option<Arc<str>>Optional fix-it / suggestion to surface in CLI output.
limit_kind: Option<LimitKind>Set when this diagnostic is the result of a configured-cap breach
(max_blocks_per_file, max_attr_depth, etc.). Lets consumers
disambiguate without parsing the message.
Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn builder() -> DiagnosticBuilder<((), (), (), (), (), ())>
pub fn builder() -> DiagnosticBuilder<((), (), (), (), (), ())>
Create a builder for building Diagnostic.
On the builder, call .severity(...), .code(...), .message(...), .span(...)(optional), .suggestion(...)(optional), .limit_kind(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of Diagnostic.
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn new(
severity: Severity,
code: impl Into<Arc<str>>,
message: impl Into<Arc<str>>,
) -> Self
pub fn new( severity: Severity, code: impl Into<Arc<str>>, message: impl Into<Arc<str>>, ) -> Self
Construct a diagnostic.
Sourcepub fn limit(
kind: LimitKind,
code: impl Into<Arc<str>>,
message: impl Into<Arc<str>>,
) -> Self
pub fn limit( kind: LimitKind, code: impl Into<Arc<str>>, message: impl Into<Arc<str>>, ) -> Self
Construct a diagnostic for a configured-cap breach.
The structured LimitKind is preserved as self.limit_kind so
downstream tooling can match on it directly. The message should
still spell out the observed/limit values for log readability.
Sourcepub fn with_suggestion(self, suggestion: impl Into<Arc<str>>) -> Self
pub fn with_suggestion(self, suggestion: impl Into<Arc<str>>) -> Self
Add a suggestion.
Trait Implementations§
Source§impl Clone for Diagnostic
impl Clone for Diagnostic
Source§fn clone(&self) -> Diagnostic
fn clone(&self) -> Diagnostic
1.0.0 (const: unstable) · 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<'de> Deserialize<'de> for Diagnostic
impl<'de> Deserialize<'de> for Diagnostic
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Hash for Diagnostic
impl Hash for Diagnostic
Source§impl PartialEq for Diagnostic
impl PartialEq for Diagnostic
Source§fn eq(&self, other: &Diagnostic) -> bool
fn eq(&self, other: &Diagnostic) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for Diagnostic
impl Serialize for Diagnostic
impl Eq 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 UnsafeUnpin 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.