pub struct Diagnostic(pub Diagnostic<SourceId>);
reporting
only.Expand description
Wright’s Diagnostic type wraps one from codespan_reporting to make it compatible with things like Fragment and SourceId.
Tuple Fields§
§0: Diagnostic<SourceId>
Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn new(severity: Severity) -> Self
pub fn new(severity: Severity) -> Self
Construct a new Diagnostic with the given Severity.
Sourcepub fn bug() -> Self
pub fn bug() -> Self
Construct a new Diagnostic representing a wright compiler bug.
Sourcepub fn error() -> Self
pub fn error() -> Self
Construct a new Diagnostic representing an error.
Sourcepub fn warning() -> Self
pub fn warning() -> Self
Construct a new Diagnostic representing a warning.
Sourcepub fn note() -> Self
pub fn note() -> Self
Construct a new Diagnostic representing a note.
Sourcepub fn help() -> Self
pub fn help() -> Self
Construct a new Diagnostic representing a note to the user.
Sourcepub fn with_code(self, code: impl Into<String>) -> Self
pub fn with_code(self, code: impl Into<String>) -> Self
Builder style function to set an error/warning code for this Diagnostic.
Sourcepub fn with_message(self, message: impl Into<String>) -> Self
pub fn with_message(self, message: impl Into<String>) -> Self
Builder style function to set a message for this Diagnostic.
Sourcepub fn with_notes<I: Into<String>>(
self,
notes: impl IntoIterator<Item = I>,
) -> Self
pub fn with_notes<I: Into<String>>( self, notes: impl IntoIterator<Item = I>, ) -> Self
Add all the notes from the given Iterator to this Diagnostic.
Sourcepub fn with_highlights(
self,
highlights: impl IntoIterator<Item = Highlight>,
) -> Self
pub fn with_highlights( self, highlights: impl IntoIterator<Item = Highlight>, ) -> Self
Add all the Highlights from a given Iterator to this Diagnostic.
Sourcepub fn write(
&self,
map: &SourceMap,
writer: &mut dyn WriteColor,
config: &Config,
) -> Result<(), CRError>
pub fn write( &self, map: &SourceMap, writer: &mut dyn WriteColor, config: &Config, ) -> Result<(), CRError>
Write this Diagnostic to a given WriteColor. This will error if any of the Highlights are not in the referenced SourceMap, or if any were constructed from invalid Fragments.
Sourcepub fn print(&self, map: &SourceMap) -> Result<(), Error>
pub fn print(&self, map: &SourceMap) -> Result<(), Error>
Print this Diagnostic to the standard output. This locks the standard output until the diagnostic is printed. This uses the global get_stdout_color function to determine whether or not to use colors while printing. This uses the Config::default configuration from codespan_reporting when printing.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Diagnostic
impl RefUnwindSafe for Diagnostic
impl Send for Diagnostic
impl Sync for Diagnostic
impl Unpin 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> 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