Skip to main content

Preprocessed

Struct Preprocessed 

Source
pub struct Preprocessed {
    pub tokens: Vec<Token>,
    pub text: String,
    pub map: SourceMap,
    pub diagnostics: Vec<Diagnostic>,
}
Expand description

The expanded token stream and where it came from.

Fields§

§tokens: Vec<Token>

The tokens the parser will see.

§text: String

The text those tokens index into.

Concatenated from every file that contributed, so a token’s span still slices something. The map says which file a range belongs to.

§map: SourceMap

Where each token came from.

§diagnostics: Vec<Diagnostic>

Everything wrong with the directives.

Implementations§

Source§

impl Preprocessed

Source

pub fn provenance(&self, expanded: Span) -> Option<Provenance>

Where a range of the expanded text was written, for a node of the model rather than a diagnostic: the file’s path, the range in its text (SourceMap::original), and the macro expansions that produced the text at its start, outermost first, each with the path and range of its invocation. None before the first token.

Source

pub fn locate(&self, diagnostic: &mut Diagnostic)

Moves diagnostic out of the expanded text into the file it points at.

The parser and everything after it see only the expanded text, in which comments are gone, directives are gone, includes are inlined and every token stands one space from the next — so an offset into it is an offset into no file a reader has. Read against the unit, the first lines of comment were enough to put file.idl:3:7 where file.idl:6:10 was meant. This maps primary and every label through SourceMap::original, and sets Diagnostic::file when the place is an included file. A label in a file other than the primary’s names that file in its note.

For diagnostics raised on the expanded text only: the preprocessor’s own are in file offsets already.

Trait Implementations§

Source§

impl Clone for Preprocessed

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 Preprocessed

Source§

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

Formats the value using the given formatter. 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.