Skip to main content

SourceMap

Struct SourceMap 

Source
pub struct SourceMap { /* private fields */ }
Expand description

Where every token of the expanded stream came from.

Implementations§

Source§

impl SourceMap

Source

pub const ROOT: FileId

The file a unit is: the first one read.

Source

pub const fn new() -> Self

An empty map.

Source

pub fn add_file(&mut self, path: &str, text: &str) -> FileId

Record a file, returning its id.

Source

pub fn path(&self, file: FileId) -> Option<&str>

A file’s recorded path.

Source

pub fn text(&self, file: FileId) -> Option<&str>

A file’s text.

Source

pub fn origin(&self, index: usize) -> Option<&Origin>

Where the token at index in the expanded stream came from.

Source

pub fn len(&self) -> usize

How many tokens the map covers.

Source

pub fn is_empty(&self) -> bool

Whether the map covers nothing.

Source

pub fn original(&self, expanded: Span) -> Option<(FileId, Span)>

Where a range of the expanded text was written: the file and the range in that file’s own text.

A range that starts inside a token written as it stands maps octet for octet; one that starts inside a macro’s expansion maps to the invocation, which is the text a reader can find. A range over several tokens of one file runs from the first to the last; one that leaves its file — a declaration whose body an include supplied — keeps the file it starts in. None before the first token, which a diagnostic of an empty unit points at.

Source

pub fn origin_at(&self, at: u32) -> Option<&Origin>

The origin of the range of the expanded text that holds at: the file, where in it, and the macro expansions that made the text, outermost first. None before the first token.

Trait Implementations§

Source§

impl Clone for SourceMap

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SourceMap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SourceMap

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.