pub trait Diagnostic: Debug {
// Required method
fn message(&self) -> String;
// Provided methods
fn severity(&self) -> Severity { ... }
fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>> { ... }
fn source_code(&self) -> Option<Arc<dyn Source>> { ... }
fn labels(&self) -> Option<Box<dyn Iterator<Item = Label> + '_>> { ... }
fn causes(
&self,
) -> Box<dyn Iterator<Item = &(dyn Diagnostic + Send + Sync)> + '_> { ... }
fn related(
&self,
) -> Box<dyn Iterator<Item = &(dyn Diagnostic + Send + Sync)> + '_> { ... }
fn help(&self) -> Option<Box<dyn Iterator<Item = Help> + '_>> { ... }
}
Expand description
Represents a single diagnostic message, which can be pretty-printed into an intuitive and fancy error message.
Required Methods§
Provided Methods§
Sourcefn severity(&self) -> Severity
fn severity(&self) -> Severity
Diagnostic severity level.
This may be used by the renderer to determine how to display the diagnostic or even halt the program, depending on the severity level.
Sourcefn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Unique diagnostic code, which can be used to look up more information about the error.
Sourcefn source_code(&self) -> Option<Arc<dyn Source>>
fn source_code(&self) -> Option<Arc<dyn Source>>
Gets the source code which the diagnostic refers to.
This isn’t used if only defined by itself. It will only be used if one or more labels are defined without any source directly attached.
Sourcefn labels(&self) -> Option<Box<dyn Iterator<Item = Label> + '_>>
fn labels(&self) -> Option<Box<dyn Iterator<Item = Label> + '_>>
Labels to attach to snippets of the source code.
Sourcefn causes(
&self,
) -> Box<dyn Iterator<Item = &(dyn Diagnostic + Send + Sync)> + '_>
fn causes( &self, ) -> Box<dyn Iterator<Item = &(dyn Diagnostic + Send + Sync)> + '_>
Any errors which were the underlying cause for the diagnostic to be raised.
Any related errors, which can be used to provide additional information about the diagnostic.