CompileUnit

Struct CompileUnit 

Source
pub struct CompileUnit<'tcx> {
    pub cc: &'tcx CompileCtxt<'tcx>,
    pub index: usize,
}

Fields§

§cc: &'tcx CompileCtxt<'tcx>§index: usize

Implementations§

Source§

impl<'tcx> CompileUnit<'tcx>

Source

pub fn file(&self) -> &'tcx File

Source

pub fn tree(&self) -> &'tcx Tree

Source

pub fn interner(&self) -> &InternPool

Access the shared string interner.

Source

pub fn intern_str<S>(&self, value: S) -> InternedStr
where S: AsRef<str>,

Intern a string and return its symbol.

Source

pub fn resolve_interned_owned(&self, symbol: InternedStr) -> Option<String>

Resolve an interned symbol into an owned string.

Source

pub fn reserve_hir_id(&self) -> HirId

Source

pub fn reserve_block_id(&self) -> BlockId

Source

pub fn register_file_start(&self) -> HirId

Source

pub fn file_start_hir_id(&self) -> Option<HirId>

Source

pub fn file_path(&self) -> Option<&str>

Source

pub fn get_text(&self, start: usize, end: usize) -> String

Get text from the file between start and end byte positions

Source

pub fn opt_hir_node(self, id: HirId) -> Option<HirNode<'tcx>>

Get a HIR node by ID, returning None if not found

Source

pub fn hir_node(self, id: HirId) -> HirNode<'tcx>

Get a HIR node by ID, panicking if not found

Source

pub fn opt_bb(self, id: BlockId) -> Option<BasicBlock<'tcx>>

Get a HIR node by ID, returning None if not found

Source

pub fn bb(self, id: BlockId) -> BasicBlock<'tcx>

Get a HIR node by ID, panicking if not found

Source

pub fn parent_node(self, id: HirId) -> Option<HirId>

Get the parent of a HIR node

Source

pub fn opt_get_scope(self, owner: HirId) -> Option<&'tcx Scope<'tcx>>

Get an existing scope or None if it doesn’t exist

Source

pub fn opt_get_symbol(self, owner: SymId) -> Option<&'tcx Symbol>

Source

pub fn get_scope(self, owner: HirId) -> &'tcx Scope<'tcx>

Get an existing scope or None if it doesn’t exist

Source

pub fn alloc_scope(self, owner: HirId) -> &'tcx Scope<'tcx>

Find an existing scope or create a new one

Source

pub fn insert_hir_node(self, id: HirId, node: HirNode<'tcx>)

Add a HIR node to the map

Source

pub fn children_of(self, parent: HirId) -> Vec<(HirId, HirNode<'tcx>)>

Get all child nodes of a given parent

Source

pub fn find_ancestor<F>(self, current: HirId, predicate: F) -> Option<HirId>
where F: Fn(&HirNode<'tcx>) -> bool,

Walk up the parent chain to find an ancestor of a specific type

Source

pub fn add_unresolved_symbol(&self, symbol: &'tcx Symbol)

Source

pub fn insert_block( &self, id: BlockId, block: BasicBlock<'tcx>, parent: BlockId, )

Methods from Deref<Target = CompileCtxt<'tcx>>§

Source

pub fn compile_unit(&'tcx self, index: usize) -> CompileUnit<'tcx>

Create a context that references this CompileCtxt for a specific file index

Source

pub fn create_globals(&'tcx self) -> &'tcx Scope<'tcx>

Source

pub fn get_scope(&'tcx self, owner: HirId) -> &'tcx Scope<'tcx>

Source

pub fn opt_get_symbol(&'tcx self, owner: SymId) -> Option<&'tcx Symbol>

Source

pub fn find_symbol_by_block_id( &'tcx self, block_id: BlockId, ) -> Option<&'tcx Symbol>

Find the primary symbol associated with a block ID

Source

pub fn alloc_scope(&'tcx self, owner: HirId) -> &'tcx Scope<'tcx>

Source

pub fn reserve_hir_id(&self) -> HirId

Source

pub fn reserve_block_id(&self) -> BlockId

Source

pub fn current_hir_id(&self) -> HirId

Source

pub fn set_file_start(&self, index: usize, start: HirId)

Source

pub fn file_start(&self, index: usize) -> Option<HirId>

Source

pub fn file_path(&self, index: usize) -> Option<&str>

Source

pub fn get_files(&self) -> Vec<String>

Get all file paths from the compilation context

Trait Implementations§

Source§

impl<'tcx> Clone for CompileUnit<'tcx>

Source§

fn clone(&self) -> CompileUnit<'tcx>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'tcx> Debug for CompileUnit<'tcx>

Source§

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

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

impl<'tcx> Deref for CompileUnit<'tcx>

Source§

type Target = CompileCtxt<'tcx>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'tcx> Copy for CompileUnit<'tcx>

Auto Trait Implementations§

§

impl<'tcx> Freeze for CompileUnit<'tcx>

§

impl<'tcx> !RefUnwindSafe for CompileUnit<'tcx>

§

impl<'tcx> !Send for CompileUnit<'tcx>

§

impl<'tcx> !Sync for CompileUnit<'tcx>

§

impl<'tcx> Unpin for CompileUnit<'tcx>

§

impl<'tcx> !UnwindSafe for CompileUnit<'tcx>

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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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 = 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.