pub struct Span { /* private fields */ }Expand description
A span represents the source of a diagnostic.
It consists of a File and an optional range into that file. When the
range isn’t present, it semantically implies that the diagnostic refers to
the entire file. For example, when the file should be executable but isn’t.
Implementations§
Source§impl Span
impl Span
Sourcepub fn file(&self) -> &UnifiedFile
pub fn file(&self) -> &UnifiedFile
Returns the UnifiedFile attached to this Span.
Sourcepub fn range(&self) -> Option<TextRange>
pub fn range(&self) -> Option<TextRange>
Returns the range, if available, attached to this Span.
When there is no range, it is convention to assume that this Span
refers to the corresponding File as a whole. In some cases, consumers
of this API may use the range 0..0 to represent this case.
Sourcepub fn with_range(self, range: TextRange) -> Span
pub fn with_range(self, range: TextRange) -> Span
Returns a new Span with the given range attached to it.
Sourcepub fn with_optional_range(self, range: Option<TextRange>) -> Span
pub fn with_optional_range(self, range: Option<TextRange>) -> Span
Returns a new Span with the given optional range attached to it.
Sourcepub fn expect_ty_file(&self) -> File
pub fn expect_ty_file(&self) -> File
Returns the File attached to this Span.
Panics if the file is a UnifiedFile::Ruff instead of a UnifiedFile::Ty.
Sourcepub fn as_ruff_file(&self) -> Option<&SourceFile>
pub fn as_ruff_file(&self) -> Option<&SourceFile>
Returns the SourceFile attached to this Span.
Trait Implementations§
impl Eq for Span
Source§impl From<SourceFile> for Span
impl From<SourceFile> for Span
Source§fn from(file: SourceFile) -> Self
fn from(file: SourceFile) -> Self
Source§impl GetSize for Span
impl GetSize for Span
Source§fn get_heap_size(&self) -> usize
fn get_heap_size(&self) -> usize
Source§fn get_heap_size_with_tracker<TRACKER: GetSizeTracker>(
&self,
tracker: TRACKER,
) -> (usize, TRACKER)
fn get_heap_size_with_tracker<TRACKER: GetSizeTracker>( &self, tracker: TRACKER, ) -> (usize, TRACKER)
tracker. Read moreSource§fn get_stack_size() -> usize
fn get_stack_size() -> usize
Source§fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
tracker. Read moreimpl StructuralPartialEq for Span
Auto Trait Implementations§
impl Freeze for Span
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin for Span
impl UnsafeUnpin for Span
impl UnwindSafe for Span
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§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> HashEqLike<&T> for T
impl<T> HashEqLike<&T> for T
Source§impl<T> HashEqLike<Cow<'_, T>> for T
impl<T> HashEqLike<Cow<'_, T>> for T
Source§impl<T> HashEqLike<T> for T
impl<T> HashEqLike<T> for T
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