pub struct Diagnostic {
pub severity: Severity,
pub message: String,
pub location: Option<SourceSpan>,
pub expression_index: Option<usize>,
}Expand description
A single diagnostic produced during tolerant compilation.
Fields§
§severity: SeveritySeverity of the diagnostic.
message: StringHuman-readable message.
location: Option<SourceSpan>Optional source location.
expression_index: Option<usize>Index into the slice passed to the tolerant compiler, if the diagnostic is tied to one particular expression.
Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn new(severity: Severity, message: impl Into<String>) -> Self
pub fn new(severity: Severity, message: impl Into<String>) -> Self
Construct a diagnostic from scratch.
Sourcepub fn info(message: impl Into<String>) -> Self
pub fn info(message: impl Into<String>) -> Self
Convenience constructor for Severity::Info diagnostics.
Sourcepub fn warning(message: impl Into<String>) -> Self
pub fn warning(message: impl Into<String>) -> Self
Convenience constructor for Severity::Warning diagnostics.
Sourcepub fn error(message: impl Into<String>) -> Self
pub fn error(message: impl Into<String>) -> Self
Convenience constructor for Severity::Error diagnostics.
Sourcepub fn fatal(message: impl Into<String>) -> Self
pub fn fatal(message: impl Into<String>) -> Self
Convenience constructor for Severity::Fatal diagnostics.
Sourcepub fn with_expression_index(self, idx: usize) -> Self
pub fn with_expression_index(self, idx: usize) -> Self
Attach an expression index (builder-style).
Sourcepub fn with_location(self, span: SourceSpan) -> Self
pub fn with_location(self, span: SourceSpan) -> Self
Attach a source span (builder-style).
Sourcepub fn is_blocking(&self) -> bool
pub fn is_blocking(&self) -> bool
Returns true when this diagnostic is blocking
(i.e. Severity::Error or Severity::Fatal).
Sourcepub fn is_fatal(&self) -> bool
pub fn is_fatal(&self) -> bool
Returns true when this diagnostic is fatal
(i.e. Severity::Fatal).
Trait Implementations§
Source§impl Clone for Diagnostic
impl Clone for Diagnostic
Source§fn clone(&self) -> Diagnostic
fn clone(&self) -> Diagnostic
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Diagnostic
impl Debug for Diagnostic
Source§impl Display for Diagnostic
impl Display for Diagnostic
Source§impl PartialEq for Diagnostic
impl PartialEq 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
Mutably borrows from an owned value. Read more
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
Compare self to
key and return true if they are equal.