ParsingContext

Struct ParsingContext 

Source
pub struct ParsingContext<'gcx> {
    pub sess: &'gcx Session,
    pub file_resolver: FileResolver<'gcx>,
    /* private fields */
}
Expand description

Builder for parsing sources into a Compiler.

Created from CompilerRef::parse.

§Examples

compiler.enter_mut(|compiler| {
    let mut pcx = compiler.parse();
    pcx.set_resolve_imports(false);
    pcx.load_stdin();
    pcx.parse();
});

Fields§

§sess: &'gcx Session

The compiler session.

§file_resolver: FileResolver<'gcx>

The file resolver.

Implementations§

Source§

impl<'gcx> ParsingContext<'gcx>

Source

pub fn dcx(&self) -> &'gcx DiagCtxt

Returns the diagnostics context.

Source

pub fn set_resolve_imports(&mut self, resolve_imports: bool)

Sets whether to recursively resolve and parse imports.

Default: !sess.opts.unstable.no_resolve_imports, true.

Source

pub fn resolve_file( &self, path: impl AsRef<Path>, ) -> Result<Arc<SourceFile>, ErrorGuaranteed>

Resolves a file.

Source

pub fn resolve_files( &self, paths: impl IntoIterator<Item = impl AsRef<Path>>, ) -> impl Iterator<Item = Result<Arc<SourceFile>, ErrorGuaranteed>>

Resolves a list of files.

Source

pub fn par_resolve_files( &self, paths: impl IntoParallelIterator<Item = impl AsRef<Path>>, ) -> impl ParallelIterator<Item = Result<Arc<SourceFile>, ErrorGuaranteed>>

Resolves a list of files in parallel.

Source

pub fn load_stdin(&mut self) -> Result<(), ErrorGuaranteed>

Loads stdin into the context.

Source

pub fn load_files( &mut self, paths: impl IntoIterator<Item = impl AsRef<Path>>, ) -> Result<(), ErrorGuaranteed>

Loads files into the context.

Source

pub fn par_load_files( &mut self, paths: impl IntoParallelIterator<Item = impl AsRef<Path>>, ) -> Result<(), ErrorGuaranteed>

Loads files into the context in parallel.

Source

pub fn load_file(&mut self, path: &Path) -> Result<(), ErrorGuaranteed>

Loads a file into the context.

Source

pub fn add_files(&mut self, files: impl IntoIterator<Item = Arc<SourceFile>>)

Adds a preloaded file to the resolver.

Source

pub fn add_file(&mut self, file: Arc<SourceFile>)

Adds a preloaded file to the resolver.

Source

pub fn force_resolve_all_imports(self)

Resolves all the imports of all the loaded sources.

Source

pub fn parse(self)

Parses all the loaded sources, recursing into imports if specified.

Sources are not guaranteed to be in any particular order, as they may be parsed in parallel.

Trait Implementations§

Source§

impl Drop for ParsingContext<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'gcx> !Freeze for ParsingContext<'gcx>

§

impl<'gcx> !RefUnwindSafe for ParsingContext<'gcx>

§

impl<'gcx> Send for ParsingContext<'gcx>

§

impl<'gcx> Sync for ParsingContext<'gcx>

§

impl<'gcx> Unpin for ParsingContext<'gcx>

§

impl<'gcx> !UnwindSafe for ParsingContext<'gcx>

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, R> CollectAndApply<T, R> for T

Source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

Source§

type Output = R

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = Infallible

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more