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 parse_tree(&self) -> Option<&dyn ParseTree>

Get the generic parse tree for this compilation unit

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 resolve_name_or(&self, symbol: InternedStr, default: &str) -> String

Resolve an interned symbol to string reference with “” as default. Useful for display purposes where you need a string that lives for ’static or is owned.

Source

pub fn resolve_name(&self, symbol: InternedStr) -> String

Resolve an interned symbol to string, using “” as default if not found.

Source

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

Source

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

Source

pub fn unit_meta(&self) -> &UnitMeta

Get the module metadata for this compilation unit. Contains package/module/file names and roots.

Source

pub fn reserve_block_id(&self) -> BlockId

Reserve a new block ID

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 ts_text(&self, node: Node<'tcx>) -> String

Convenience: extract text for a Tree-sitter node.

Source

pub fn hir_text(&self, node: &HirNode<'tcx>) -> String

Convenience: extract text for a HIR node.

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 root_block(self) -> Option<BasicBlock<'tcx>>

Get the Root block for this compile unit (file). Returns the first BlockKind::Root block belonging to this unit.

Source

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

Get the parent of a HIR node

Source

pub fn opt_get_scope(self, scope_id: ScopeId) -> 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>

Get a symbol by ID, delegating to CompileCtxt

Source

pub fn get_scope(self, scope_id: ScopeId) -> &'tcx Scope<'tcx>

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

Source

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

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

Source

pub const GLOBAL_SCOPE_OWNER: HirId

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_unit_globals(&'tcx self, owner: HirId) -> &'tcx Scope<'tcx>

Source

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

Source

pub fn get_scope(&'tcx self, scope_id: ScopeId) -> &'tcx Scope<'tcx>

Source

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

Source

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

Source

pub fn get_symbol(&'tcx self, owner: SymId) -> &'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 arena(&'tcx self) -> &'tcx Arena<'tcx>

Access the arena for allocations

Source

pub fn alloc_file_ident( &'tcx self, id: HirId, name: &'tcx str, symbol: &'tcx Symbol, ) -> &'tcx HirIdent<'tcx>

Allocate a new file identifier node with the given ID, name and symbol

Source

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

Source

pub fn merge_two_scopes( &'tcx self, first: &'tcx Scope<'tcx>, second: &'tcx Scope<'tcx>, )

Merge the second scope into the first.

This combines all symbols from the second scope into the first scope. Any future lookup of second’s scope ID will redirect to first.

Source

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

Source

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

Source

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

Source

pub fn get_parse_tree(&self, index: usize) -> Option<&dyn ParseTree>

Get the generic parse tree for a specific file

Source

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

Get all file paths from the compilation context

Source

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

Get a HIR node by ID from the Arena’s DashMap (O(1) concurrent lookup)

Source

pub fn hir_node_exists(&self, id: HirId) -> bool

Check if a HIR node exists in the Arena (O(1) check)

Source

pub fn hir_node_count(&self) -> usize

Get the total count of HIR nodes in the Arena

Source

pub fn all_hir_node_ids(&'tcx self) -> Vec<HirId>

Get all HIR node IDs from the Arena

Source

pub fn find_blocks_by_name( &self, name: &'tcx str, ) -> Vec<(usize, BlockKind, BlockId)>

Get all blocks by name

Source

pub fn find_blocks_by_kind( &self, kind: BlockKind, ) -> Vec<(usize, Option<String>, BlockId)>

Get all blocks by kind

Source

pub fn find_blocks_in_unit( &self, unit_index: usize, ) -> Vec<(Option<String>, BlockKind, BlockId)>

Get blocks in a specific unit

Source

pub fn find_blocks_by_kind_in_unit( &self, kind: BlockKind, unit_index: usize, ) -> Vec<BlockId>

Get blocks of a specific kind in a specific unit

Source

pub fn get_block_info( &self, block_id: BlockId, ) -> Option<(usize, Option<String>, BlockKind)>

Get block info by ID

Source

pub fn get_all_blocks(&self) -> Vec<(BlockId, usize, Option<String>, BlockKind)>

Get all blocks with their metadata

Source

pub fn get_all_symbols(&'tcx self) -> Vec<&'tcx Symbol>

Get all symbols from the symbol map

Source

pub fn symbol_count(&self) -> usize

Get the count of registered symbols (excluding unresolved)

Source

pub fn for_each_symbol<F>(&'tcx self, f: F)
where F: FnMut(SymId, &'tcx Symbol),

Iterate over all symbols and their IDs (excluding unresolved)

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