pub struct CompileCtxt<'tcx> {
pub arena: Arena<'tcx>,
pub interner: InternPool,
pub files: Vec<File>,
pub unit_metas: Vec<UnitMeta>,
pub parse_trees: Vec<Option<Box<dyn ParseTree>>>,
pub hir_root_ids: RwLock<Vec<Option<HirId>>>,
pub block_arena: BlockArena<'tcx>,
pub related_map: BlockRelationMap,
pub block_indexes: BlockIndexMaps,
pub build_metrics: BuildMetrics,
}Fields§
§arena: Arena<'tcx>§interner: InternPool§files: Vec<File>§unit_metas: Vec<UnitMeta>Per-file metadata: package/module/file names and roots.
parse_trees: Vec<Option<Box<dyn ParseTree>>>Generic parse trees from language-specific parsers
hir_root_ids: RwLock<Vec<Option<HirId>>>§block_arena: BlockArena<'tcx>§block_indexes: BlockIndexMapsIndex maps for efficient block lookups by name, kind, unit, and id Uses DashMap internally for concurrent access
build_metrics: BuildMetricsMetrics collected while building the compilation context
Implementations§
Source§impl<'tcx> CompileCtxt<'tcx>
impl<'tcx> CompileCtxt<'tcx>
Sourcepub const GLOBAL_SCOPE_OWNER: HirId
pub const GLOBAL_SCOPE_OWNER: HirId
Sentinel owner id reserved for the global scope so that file-level scopes
(whose HIR id often defaults to 0) do not reuse the same Scope instance.
Sourcepub fn from_sources<L: LanguageTrait>(sources: &[Vec<u8>]) -> Self
pub fn from_sources<L: LanguageTrait>(sources: &[Vec<u8>]) -> Self
Create a new CompileCtxt from source code
Sourcepub fn from_files<L: LanguageTrait>(paths: &[String]) -> Result<Self>
pub fn from_files<L: LanguageTrait>(paths: &[String]) -> Result<Self>
Create a new CompileCtxt from files with default (original) ordering.
Sourcepub fn from_files_with_order<L: LanguageTrait>(
paths: &[String],
order: FileOrder,
) -> Result<Self>
pub fn from_files_with_order<L: LanguageTrait>( paths: &[String], order: FileOrder, ) -> Result<Self>
Create a new CompileCtxt from files with specified ordering.
Sourcepub fn from_files_with_logical<L: LanguageTrait>(
paths: &[(String, String)],
) -> Result<Self>
pub fn from_files_with_logical<L: LanguageTrait>( paths: &[(String, String)], ) -> Result<Self>
Create a new CompileCtxt from files with separate physical and logical paths. Physical paths are used to read files from disk; logical paths are stored for display. Each element is (physical_path, logical_path).
Sourcepub fn from_files_with_logical_and_order<L: LanguageTrait>(
paths: &[(String, String)],
order: FileOrder,
) -> Result<Self>
pub fn from_files_with_logical_and_order<L: LanguageTrait>( paths: &[(String, String)], order: FileOrder, ) -> Result<Self>
Create a new CompileCtxt from files with separate physical and logical paths and specified ordering.
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> Debug for CompileCtxt<'tcx>
impl<'tcx> Debug for CompileCtxt<'tcx>
Source§impl<'tcx> Default for CompileCtxt<'tcx>
impl<'tcx> Default for CompileCtxt<'tcx>
Source§fn default() -> CompileCtxt<'tcx>
fn default() -> CompileCtxt<'tcx>
Auto Trait Implementations§
impl<'tcx> !Freeze for CompileCtxt<'tcx>
impl<'tcx> !RefUnwindSafe for CompileCtxt<'tcx>
impl<'tcx> Send for CompileCtxt<'tcx>
impl<'tcx> Sync for CompileCtxt<'tcx>
impl<'tcx> Unpin for CompileCtxt<'tcx>
impl<'tcx> !UnwindSafe for CompileCtxt<'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> 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