pub struct SourceLocation {
pub file_path: PathBuf,
pub byte_start: usize,
pub byte_end: usize,
pub start_line: usize,
pub start_column: usize,
pub end_line: usize,
pub end_column: usize,
}Expand description
Source location for a CFG block or statement
Fields§
§file_path: PathBufFile path (relative to crate root or absolute)
byte_start: usizeByte offset of the start
byte_end: usizeByte offset of the end
start_line: usizeLine number (1-indexed)
start_column: usizeColumn number (1-indexed, in UTF-8 characters)
end_line: usizeEnd line number
end_column: usizeEnd column number
Implementations§
Source§impl SourceLocation
impl SourceLocation
Sourcepub fn new(
file_path: impl Into<PathBuf>,
byte_start: usize,
byte_end: usize,
start_line: usize,
start_column: usize,
end_line: usize,
end_column: usize,
) -> Self
pub fn new( file_path: impl Into<PathBuf>, byte_start: usize, byte_end: usize, start_line: usize, start_column: usize, end_line: usize, end_column: usize, ) -> Self
Create a new source location
Sourcepub fn from_bytes(
file_path: impl Into<PathBuf>,
source: &str,
byte_start: usize,
byte_end: usize,
) -> Self
pub fn from_bytes( file_path: impl Into<PathBuf>, source: &str, byte_start: usize, byte_end: usize, ) -> Self
Convert byte offsets to line/column
This is a simplified implementation. For production use, you’d want to cache line endings and handle edge cases.
Sourcepub fn overlaps(&self, other: &SourceLocation) -> bool
pub fn overlaps(&self, other: &SourceLocation) -> bool
Check if this location overlaps with another
Sourcepub fn from_bytes_with_source(
file_path: impl Into<PathBuf>,
source: Option<&str>,
byte_start: usize,
byte_end: usize,
) -> Self
pub fn from_bytes_with_source( file_path: impl Into<PathBuf>, source: Option<&str>, byte_start: usize, byte_end: usize, ) -> Self
Create a source location from byte ranges, with optional source for line/column.
If source is provided, computes line/column from byte offsets. If source is None, line/column fields are set to 0 (lazy computation).
This is useful when reconstructing SourceLocation from database where the source file may not be available.
Sourcepub fn display_or_bytes(&self) -> String
pub fn display_or_bytes(&self) -> String
Get a human-readable description (fallback to byte ranges if line/column unavailable)
Trait Implementations§
Source§impl Clone for SourceLocation
impl Clone for SourceLocation
Source§fn clone(&self) -> SourceLocation
fn clone(&self) -> SourceLocation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Hash for SourceLocation
impl Hash for SourceLocation
Source§impl PartialEq for SourceLocation
impl PartialEq for SourceLocation
Source§fn eq(&self, other: &SourceLocation) -> bool
fn eq(&self, other: &SourceLocation) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for SourceLocation
impl Serialize for SourceLocation
impl Eq for SourceLocation
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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