pub struct Diagnostic { /* private fields */ }Expand description
A compiler diagnostic with source context for rich rendering.
Displays as a rustc-style diagnostic with the span highlighted in the original source text.
Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn new(message: String, span: Range<usize>, input: String) -> Self
pub fn new(message: String, span: Range<usize>, input: String) -> Self
Create an error with source text for rich snippet rendering.
Sourcepub fn at(
message: String,
span: Range<usize>,
filename: impl AsRef<Path>,
) -> Self
pub fn at( message: String, span: Range<usize>, filename: impl AsRef<Path>, ) -> Self
Create an error without source text (for a pass that has only the span).
Call resolve_source later to load source
from the file for rich rendering.
Sourcepub fn warn_at(
message: String,
span: Range<usize>,
filename: impl AsRef<Path>,
) -> Self
pub fn warn_at( message: String, span: Range<usize>, filename: impl AsRef<Path>, ) -> Self
Create a warning without source text.
Sourcepub fn as_warning(self) -> Self
pub fn as_warning(self) -> Self
The same finding, as a warning: printed, and the pass goes on.
Sourcepub fn from_parse(error: &ParseError<&str, ContextError>) -> Self
pub fn from_parse(error: &ParseError<&str, ContextError>) -> Self
Convert a winnow ParseError into an error.
Sourcepub fn with_filename(self, filename: impl Into<String>) -> Self
pub fn with_filename(self, filename: impl Into<String>) -> Self
Attach a filename for display in the snippet origin.
Sourcepub fn resolve_source(&mut self)
pub fn resolve_source(&mut self)
Load source text from the file on disk for rich snippet rendering.
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 (const: unstable) · 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 Error for Diagnostic
impl Error for Diagnostic
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 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§
§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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.