pub struct SourceSpan { /* private fields */ }Expand description
A range together with exact source provenance and an optional revision.
Implementations§
Source§impl SourceSpan
impl SourceSpan
Sourcepub const SYNTHETIC: Self
pub const SYNTHETIC: Self
A sentinel SourceSpan that indicates compiler-generated/synthetic code
This is used to distinguish between:
- UNKNOWN: debug info missing or failed to parse from DWARF
- SYNTHETIC: compiler-generated code that doesn’t correspond to any user source
Sourcepub const UNKNOWN: Self
pub const UNKNOWN: Self
A sentinel SourceSpan that indicates the span is unknown/invalid
pub const fn new( source: SourceKey, revision: Option<SourceRevision>, range: TextRange, ) -> Self
pub const fn session(id: SourceId, range: TextRange) -> Self
pub const fn attached(id: SourceId, range: TextRange) -> Self
Sourcepub fn at(
source: SourceKey,
revision: Option<SourceRevision>,
offset: u32,
) -> Self
pub fn at( source: SourceKey, revision: Option<SourceRevision>, offset: u32, ) -> Self
Creates a new SourceSpan for a specific offset.
pub const fn with_revision(self, revision: SourceRevision) -> Self
pub fn set_source_key(&mut self, source: SourceKey)
Sourcepub fn try_from_range(
source: SourceKey,
revision: Option<SourceRevision>,
range: Range<usize>,
) -> Result<Self, TextRangeError>
pub fn try_from_range( source: SourceKey, revision: Option<SourceRevision>, range: Range<usize>, ) -> Result<Self, TextRangeError>
Try to create a new SourceSpan from the given range with usize bounds.
Sourcepub const fn from_text_range(
source: SourceKey,
revision: Option<SourceRevision>,
range: TextRange,
) -> Self
pub const fn from_text_range( source: SourceKey, revision: Option<SourceRevision>, range: TextRange, ) -> Self
Try to create a new SourceSpan from the given TextRange
Sourcepub const fn is_unknown(&self) -> bool
pub const fn is_unknown(&self) -> bool
Returns true if this SourceSpan represents the unknown span
Sourcepub const fn is_synthetic(&self) -> bool
pub const fn is_synthetic(&self) -> bool
Returns true if this SourceSpan represents synthetic/compiler-generated code
pub const fn source(self) -> SourceKey
pub const fn revision(self) -> Option<SourceRevision>
pub const fn range(self) -> TextRange
Trait Implementations§
Source§impl Clone for SourceSpan
impl Clone for SourceSpan
impl Copy for SourceSpan
Source§impl Debug for SourceSpan
impl Debug for SourceSpan
Source§impl Default for SourceSpan
impl Default for SourceSpan
impl Eq for SourceSpan
Source§impl Hash for SourceSpan
impl Hash for SourceSpan
Source§impl PartialEq for SourceSpan
impl PartialEq for SourceSpan
Source§impl Spanned for SourceSpan
impl Spanned for SourceSpan
fn span(&self) -> SourceSpan
impl StructuralPartialEq for SourceSpan
Auto Trait Implementations§
impl Forget for SourceSpan
impl Freeze for SourceSpan
impl Move for SourceSpan
impl RefUnwindSafe for SourceSpan
impl Send for SourceSpan
impl Sync for SourceSpan
impl Unpin for SourceSpan
impl UnsafeUnpin for SourceSpan
impl UnwindSafe for SourceSpan
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