pub trait CrateStore: Debug {
    // Required methods
    fn as_any(&self) -> &dyn Any;
    fn untracked_as_any(&mut self) -> &mut dyn Any;
    fn def_key(&self, def: DefId) -> DefKey;
    fn def_path(&self, def: DefId) -> DefPath;
    fn def_path_hash(&self, def: DefId) -> DefPathHash;
    fn crate_name(&self, cnum: CrateNum) -> Symbol;
    fn stable_crate_id(&self, cnum: CrateNum) -> StableCrateId;
    fn stable_crate_id_to_crate_num(
        &self,
        stable_crate_id: StableCrateId
    ) -> CrateNum;
    fn def_path_hash_to_def_id(
        &self,
        cnum: CrateNum,
        hash: DefPathHash
    ) -> DefId;
    fn expn_hash_to_expn_id(
        &self,
        sess: &Session,
        cnum: CrateNum,
        index_guess: u32,
        hash: ExpnHash
    ) -> ExpnId;
    fn import_source_files(&self, sess: &Session, cnum: CrateNum);
}
Expand description

A store of Rust crates, through which their metadata can be accessed.

Note that this trait should probably not be expanding today. All new functionality should be driven through queries instead!

If you find a method on this trait named {name}_untracked it signifies that it’s not tracked for dependency information throughout compilation (it’d break incremental compilation) and should only be called pre-HIR (e.g. during resolve)

Required Methods§

source

fn as_any(&self) -> &dyn Any

source

fn untracked_as_any(&mut self) -> &mut dyn Any

source

fn def_key(&self, def: DefId) -> DefKey

source

fn def_path(&self, def: DefId) -> DefPath

source

fn def_path_hash(&self, def: DefId) -> DefPathHash

source

fn crate_name(&self, cnum: CrateNum) -> Symbol

source

fn stable_crate_id(&self, cnum: CrateNum) -> StableCrateId

source

fn stable_crate_id_to_crate_num( &self, stable_crate_id: StableCrateId ) -> CrateNum

source

fn def_path_hash_to_def_id(&self, cnum: CrateNum, hash: DefPathHash) -> DefId

Fetch a DefId from a DefPathHash for a foreign crate.

source

fn expn_hash_to_expn_id( &self, sess: &Session, cnum: CrateNum, index_guess: u32, hash: ExpnHash ) -> ExpnId

source

fn import_source_files(&self, sess: &Session, cnum: CrateNum)

Imports all SourceFiles from the given crate into the current session. This normally happens automatically when we decode a Span from that crate’s metadata - however, the incr comp cache needs to trigger this manually when decoding a foreign Span

Implementors§