pub struct CompileUnit<'tcx> {
pub cc: &'tcx CompileCtxt<'tcx>,
pub index: usize,
}Fields§
§cc: &'tcx CompileCtxt<'tcx>§index: usizeImplementations§
Source§impl<'tcx> CompileUnit<'tcx>
impl<'tcx> CompileUnit<'tcx>
pub fn file(&self) -> &'tcx File
Sourcepub fn parse_tree(&self) -> Option<&dyn ParseTree>
pub fn parse_tree(&self) -> Option<&dyn ParseTree>
Get the generic parse tree for this compilation unit
Sourcepub fn interner(&self) -> &InternPool
pub fn interner(&self) -> &InternPool
Access the shared string interner.
Sourcepub fn intern_str<S>(&self, value: S) -> InternedStr
pub fn intern_str<S>(&self, value: S) -> InternedStr
Intern a string and return its symbol.
Sourcepub fn resolve_interned_owned(&self, symbol: InternedStr) -> Option<String>
pub fn resolve_interned_owned(&self, symbol: InternedStr) -> Option<String>
Resolve an interned symbol into an owned string.
Sourcepub fn resolve_name_or(&self, symbol: InternedStr, default: &str) -> String
pub fn resolve_name_or(&self, symbol: InternedStr, default: &str) -> String
Resolve an interned symbol to string reference with “
Sourcepub fn resolve_name(&self, symbol: InternedStr) -> String
pub fn resolve_name(&self, symbol: InternedStr) -> String
Resolve an interned symbol to string, using “
pub fn file_root_id(&self) -> Option<HirId>
pub fn file_path(&self) -> Option<&str>
Sourcepub fn unit_meta(&self) -> &UnitMeta
pub fn unit_meta(&self) -> &UnitMeta
Get the module metadata for this compilation unit. Contains package/module/file names and roots.
Sourcepub fn reserve_block_id(&self) -> BlockId
pub fn reserve_block_id(&self) -> BlockId
Reserve a new block ID
Sourcepub fn get_text(&self, start: usize, end: usize) -> String
pub fn get_text(&self, start: usize, end: usize) -> String
Get text from the file between start and end byte positions
Sourcepub fn ts_text(&self, node: Node<'tcx>) -> String
pub fn ts_text(&self, node: Node<'tcx>) -> String
Convenience: extract text for a Tree-sitter node.
Sourcepub fn hir_text(&self, node: &HirNode<'tcx>) -> String
pub fn hir_text(&self, node: &HirNode<'tcx>) -> String
Convenience: extract text for a HIR node.
Sourcepub fn opt_hir_node(self, id: HirId) -> Option<HirNode<'tcx>>
pub fn opt_hir_node(self, id: HirId) -> Option<HirNode<'tcx>>
Get a HIR node by ID, returning None if not found
Sourcepub fn opt_bb(self, id: BlockId) -> Option<BasicBlock<'tcx>>
pub fn opt_bb(self, id: BlockId) -> Option<BasicBlock<'tcx>>
Get a HIR node by ID, returning None if not found
Sourcepub fn bb(self, id: BlockId) -> BasicBlock<'tcx>
pub fn bb(self, id: BlockId) -> BasicBlock<'tcx>
Get a HIR node by ID, panicking if not found
Sourcepub fn root_block(self) -> Option<BasicBlock<'tcx>>
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.
Sourcepub fn parent_node(self, id: HirId) -> Option<HirId>
pub fn parent_node(self, id: HirId) -> Option<HirId>
Get the parent of a HIR node
Sourcepub fn opt_get_scope(self, scope_id: ScopeId) -> Option<&'tcx Scope<'tcx>>
pub fn opt_get_scope(self, scope_id: ScopeId) -> Option<&'tcx Scope<'tcx>>
Get an existing scope or None if it doesn’t exist
Sourcepub fn opt_get_symbol(self, owner: SymId) -> Option<&'tcx Symbol>
pub fn opt_get_symbol(self, owner: SymId) -> Option<&'tcx Symbol>
Get a symbol by ID, delegating to CompileCtxt
Sourcepub fn get_scope(self, scope_id: ScopeId) -> &'tcx Scope<'tcx>
pub fn get_scope(self, scope_id: ScopeId) -> &'tcx Scope<'tcx>
Get an existing scope or panics if it doesn’t exist
pub fn insert_block( &self, id: BlockId, block: BasicBlock<'tcx>, _parent: BlockId, )
Methods from Deref<Target = CompileCtxt<'tcx>>§
pub const GLOBAL_SCOPE_OWNER: HirId
Sourcepub fn compile_unit(&'tcx self, index: usize) -> CompileUnit<'tcx>
pub fn compile_unit(&'tcx self, index: usize) -> CompileUnit<'tcx>
Create a context that references this CompileCtxt for a specific file index
pub fn create_unit_globals(&'tcx self, owner: HirId) -> &'tcx Scope<'tcx>
pub fn create_globals(&'tcx self) -> &'tcx Scope<'tcx>
pub fn get_scope(&'tcx self, scope_id: ScopeId) -> &'tcx Scope<'tcx>
pub fn opt_get_scope(&'tcx self, scope_id: ScopeId) -> Option<&'tcx Scope<'tcx>>
pub fn opt_get_symbol(&'tcx self, owner: SymId) -> Option<&'tcx Symbol>
pub fn get_symbol(&'tcx self, owner: SymId) -> &'tcx Symbol
Sourcepub fn find_symbol_by_block_id(
&'tcx self,
block_id: BlockId,
) -> Option<&'tcx Symbol>
pub fn find_symbol_by_block_id( &'tcx self, block_id: BlockId, ) -> Option<&'tcx Symbol>
Find the primary symbol associated with a block ID
Sourcepub fn alloc_file_ident(
&'tcx self,
id: HirId,
name: &'tcx str,
symbol: &'tcx Symbol,
) -> &'tcx HirIdent<'tcx>
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
pub fn alloc_scope(&'tcx self, owner: HirId) -> &'tcx Scope<'tcx>
Sourcepub fn merge_two_scopes(
&'tcx self,
first: &'tcx Scope<'tcx>,
second: &'tcx Scope<'tcx>,
)
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.
pub fn set_file_root_id(&self, index: usize, start: HirId)
pub fn file_root_id(&self, index: usize) -> Option<HirId>
pub fn file_path(&self, index: usize) -> Option<&str>
Sourcepub fn get_parse_tree(&self, index: usize) -> Option<&dyn ParseTree>
pub fn get_parse_tree(&self, index: usize) -> Option<&dyn ParseTree>
Get the generic parse tree for a specific file
Sourcepub fn get_hir_node(&'tcx self, id: HirId) -> Option<HirNode<'tcx>>
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)
Sourcepub fn hir_node_exists(&self, id: HirId) -> bool
pub fn hir_node_exists(&self, id: HirId) -> bool
Check if a HIR node exists in the Arena (O(1) check)
Sourcepub fn hir_node_count(&self) -> usize
pub fn hir_node_count(&self) -> usize
Get the total count of HIR nodes in the Arena
Sourcepub fn all_hir_node_ids(&'tcx self) -> Vec<HirId>
pub fn all_hir_node_ids(&'tcx self) -> Vec<HirId>
Get all HIR node IDs from the Arena
Sourcepub fn find_blocks_by_name(
&self,
name: &'tcx str,
) -> Vec<(usize, BlockKind, BlockId)>
pub fn find_blocks_by_name( &self, name: &'tcx str, ) -> Vec<(usize, BlockKind, BlockId)>
Get all blocks by name
Sourcepub fn find_blocks_by_kind(
&self,
kind: BlockKind,
) -> Vec<(usize, Option<String>, BlockId)>
pub fn find_blocks_by_kind( &self, kind: BlockKind, ) -> Vec<(usize, Option<String>, BlockId)>
Get all blocks by kind
Sourcepub fn find_blocks_in_unit(
&self,
unit_index: usize,
) -> Vec<(Option<String>, BlockKind, BlockId)>
pub fn find_blocks_in_unit( &self, unit_index: usize, ) -> Vec<(Option<String>, BlockKind, BlockId)>
Get blocks in a specific unit
Sourcepub fn find_blocks_by_kind_in_unit(
&self,
kind: BlockKind,
unit_index: usize,
) -> Vec<BlockId>
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
Sourcepub fn get_block_info(
&self,
block_id: BlockId,
) -> Option<(usize, Option<String>, BlockKind)>
pub fn get_block_info( &self, block_id: BlockId, ) -> Option<(usize, Option<String>, BlockKind)>
Get block info by ID
Sourcepub fn get_all_blocks(&self) -> Vec<(BlockId, usize, Option<String>, BlockKind)>
pub fn get_all_blocks(&self) -> Vec<(BlockId, usize, Option<String>, BlockKind)>
Get all blocks with their metadata
Sourcepub fn get_all_symbols(&'tcx self) -> Vec<&'tcx Symbol>
pub fn get_all_symbols(&'tcx self) -> Vec<&'tcx Symbol>
Get all symbols from the symbol map
Sourcepub fn symbol_count(&self) -> usize
pub fn symbol_count(&self) -> usize
Get the count of registered symbols (excluding unresolved)
Sourcepub fn for_each_symbol<F>(&'tcx self, f: F)
pub fn for_each_symbol<F>(&'tcx self, f: F)
Iterate over all symbols and their IDs (excluding unresolved)
Trait Implementations§
Source§impl<'tcx> Clone for CompileUnit<'tcx>
impl<'tcx> Clone for CompileUnit<'tcx>
Source§fn clone(&self) -> CompileUnit<'tcx>
fn clone(&self) -> CompileUnit<'tcx>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'tcx> Debug for CompileUnit<'tcx>
impl<'tcx> Debug for CompileUnit<'tcx>
Source§impl<'tcx> Deref for CompileUnit<'tcx>
impl<'tcx> Deref for CompileUnit<'tcx>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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