pub struct SourceLocation {
pub file: Option<String>,
pub line: usize,
pub column: usize,
pub length: Option<usize>,
pub source_line: Option<String>,
pub hints: Vec<String>,
pub notes: Vec<ErrorNote>,
pub is_synthetic: bool,
}Expand description
Source location information for error reporting
Fields§
§file: Option<String>§line: usize§column: usize§length: Option<usize>§source_line: Option<String>§hints: Vec<String>§notes: Vec<ErrorNote>§is_synthetic: boolImplementations§
Source§impl SourceLocation
impl SourceLocation
Sourcepub fn with_hint(self, hint: impl Into<String>) -> SourceLocation
pub fn with_hint(self, hint: impl Into<String>) -> SourceLocation
Add a hint/suggestion (e.g., “did you mean foo?”)
Sourcepub fn with_hints(
self,
hints: impl IntoIterator<Item = impl Into<String>>,
) -> SourceLocation
pub fn with_hints( self, hints: impl IntoIterator<Item = impl Into<String>>, ) -> SourceLocation
Add multiple hints
Sourcepub fn with_note(self, note: ErrorNote) -> SourceLocation
pub fn with_note(self, note: ErrorNote) -> SourceLocation
Add a note showing related location (e.g., “first defined here:”)
Sourcepub fn with_notes(
self,
notes: impl IntoIterator<Item = ErrorNote>,
) -> SourceLocation
pub fn with_notes( self, notes: impl IntoIterator<Item = ErrorNote>, ) -> SourceLocation
Add multiple notes
Source§impl SourceLocation
impl SourceLocation
pub fn new(line: usize, column: usize) -> SourceLocation
pub fn with_file(self, file: String) -> SourceLocation
pub fn with_length(self, length: usize) -> SourceLocation
pub fn with_source_line(self, line: String) -> SourceLocation
Trait Implementations§
Source§impl Clone for SourceLocation
impl Clone for SourceLocation
Source§fn clone(&self) -> SourceLocation
fn clone(&self) -> SourceLocation
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 SourceLocation
impl Debug for SourceLocation
Source§impl<'de> Deserialize<'de> for SourceLocation
impl<'de> Deserialize<'de> for SourceLocation
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SourceLocation, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SourceLocation, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<ErrorLocation> for SourceLocation
impl From<ErrorLocation> for SourceLocation
Source§fn from(loc: ErrorLocation) -> SourceLocation
fn from(loc: ErrorLocation) -> SourceLocation
Widen an ErrorLocation (VM) into a SourceLocation (AST).
Extended fields (length, hints, notes, is_synthetic) are
filled with defaults. This direction is less common — mainly useful
when VM errors need to be reported through the AST error renderer.
Source§impl PartialEq for SourceLocation
impl PartialEq for SourceLocation
Source§impl Serialize for SourceLocation
impl Serialize for SourceLocation
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for SourceLocation
Auto Trait Implementations§
impl Freeze for SourceLocation
impl RefUnwindSafe for SourceLocation
impl Send for SourceLocation
impl Sync for SourceLocation
impl Unpin for SourceLocation
impl UnsafeUnpin for SourceLocation
impl UnwindSafe for SourceLocation
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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