pub struct Diagnostics(pub Vec<Diagnostic>);Expand description
A collection of compiler diagnostics.
Implements Display (joins all messages) and Error, so it can be
converted to anyhow::Error with ?.
Tuple Fields§
§0: Vec<Diagnostic>Implementations§
Source§impl Diagnostics
impl Diagnostics
Sourcepub fn resolve_sources(&mut self)
pub fn resolve_sources(&mut self)
Resolve source text for all diagnostics (loads from disk).
Sourcepub fn finish<T>(errors: Vec<Diagnostic>, value: T) -> Result<T, Self>
pub fn finish<T>(errors: Vec<Diagnostic>, value: T) -> Result<T, Self>
Turn a pass’s accumulated errors into its result: Ok(value) if
errors is empty, else Err with sources resolved for rendering.
Every pass follows the same shape — collect diagnostics into a
Vec as it walks the AST, then decide Ok/Err at the end — so
this replaces that boilerplate at each call site.
Sourcepub fn as_warnings(self) -> Self
pub fn as_warnings(self) -> Self
Every diagnostic as a warning, for a check whose findings are not yet errors.
Sourcepub fn warn(check: Result<(), Diagnostics>)
pub fn warn(check: Result<(), Diagnostics>)
Print a check’s findings as warnings; the pass goes on.
Sourcepub fn warnings(diagnostics: &mut Vec<Diagnostic>) -> Self
pub fn warnings(diagnostics: &mut Vec<Diagnostic>) -> Self
Take the warnings out of diagnostics, leaving the errors for
finish.
Trait Implementations§
Source§impl Debug for Diagnostics
impl Debug for Diagnostics
Source§impl Display for Diagnostics
impl Display for Diagnostics
Source§impl Error for Diagnostics
impl Error for Diagnostics
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for Diagnostics
impl RefUnwindSafe for Diagnostics
impl Send for Diagnostics
impl Sync for Diagnostics
impl Unpin for Diagnostics
impl UnsafeUnpin for Diagnostics
impl UnwindSafe for Diagnostics
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.