Skip to main content

Context

Struct Context 

Source
pub struct Context<'a> {
    pub interner: &'a mut Interner,
    pub sources: &'a mut SourceMap,
    pub fs: &'a dyn FileSystem,
    pub search: &'a SearchPath,
    pub lex: Options,
    pub max_include_depth: u32,
}
Expand description

Everything phase 4 needs from outside itself.

Grouped into one struct because #include needs all of it at once and threading five references through every directive handler is how a parameter list becomes unreadable. The lifetime is the compilation, and every field of it lives on the session.

Fields§

§interner: &'a mut Interner

The one interner.

§sources: &'a mut SourceMap

Where an included file is added, and what a span is resolved against.

§fs: &'a dyn FileSystem

Where a header is read from.

§search: &'a SearchPath

Where a header is looked for.

§lex: Options

The dialect knobs phase 1 cares about.

§max_include_depth: u32

How deep #include may nest before it is called a cycle.

A header that includes itself with no guard is the common way to reach this, and the alternative to a limit is a stack overflow with no diagnostic at all.

Implementations§

Source§

impl<'a> Context<'a>

Source

pub fn new( interner: &'a mut Interner, sources: &'a mut SourceMap, fs: &'a dyn FileSystem, search: &'a SearchPath, ) -> Context<'a>

A context with GCC’s include depth limit.

Trait Implementations§

Source§

impl Debug for Context<'_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Context<'a>

§

impl<'a> !UnwindSafe for Context<'a>

§

impl<'a> Freeze for Context<'a>

§

impl<'a> Send for Context<'a>

§

impl<'a> Sync for Context<'a>

§

impl<'a> Unpin for Context<'a>

§

impl<'a> UnsafeUnpin for Context<'a>

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> 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, 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, <T as TryFrom<U>>::Error>

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.