/// Add a definition with a parent definition.
Add a definition with a parent definition.
Add a definition with a parent definition .
pub fn create_root_def(&mut self,
                           crate_name: &str,
                           crate_disambiguator: CrateDisambiguator)
                           -> DefIndex {
        let key = DefKey {
            parent: None,
            disambiguated_data: DisambiguatedDefPathData {
                data: DefPathData::CrateRoot,
                disambiguator: 0
            }
        };
        let parent_hash = DefKey::root_parent_stable_hash(crate_name,
                                                          crate_disambiguator);
        let def_path_hash = key.compute_stable_hash(parent_hash);
        // Create the definition.
        let address_space = super::ITEM_LIKE_SPACE;
        let root_index = self.table.allocate(key, def_path_hash, address_space);
        assert_eq!(root_index, CRATE_DEF_INDEX);
        assert!(self.def_index_to_node[address_space.index()].is_empty());
        self.def_index_to_node[address_space.index()].push(ast::CRATE_NODE_ID);
        self.node_to_def_index.insert(ast::CRATE_NODE_ID, root_index);
        // Allocate some other DefIndices that always must exist.
        GlobalMetaDataKind::allocate_def_indices(self);
        root_index
    }
pub fn create_root_def ( & mut self , crate_name : & str , crate_disambiguator : CrateDisambiguator ) -> DefIndex { let key = DefKey { parent : None , disambiguated_data : DisambiguatedDefPathData { data : DefPathData :: CrateRoot , disambiguator : 0 } } ; let parent_hash = DefKey :: root_parent_stable_hash ( crate_name , crate_disambiguator ) ; let def_path_hash = key . compute_stable_hash ( parent_hash ) ; // Create the definition. let address_space = super :: ITEM_LIKE_SPACE ; let root_index = self . table . allocate ( key , def_path_hash , address_space ) ; assert_eq ! ( root_index CRATE_DEF_INDEX ) ; assert ! ( self def_index_to_node [ address_space index ( ) ] is_empty ( ) ) ; self . def_index_to_node [ address_space . index ( ) ] . push ( ast :: CRATE_NODE_ID ) ; self . node_to_def_index . insert ( ast :: CRATE_NODE_ID , root_index ) ; // Allocate some other DefIndices that always must exist. GlobalMetaDataKind :: allocate_def_indices ( self ) ; root_index }
Add a definition with a parent definition.
Add a definition with a parent definition .
&mut self
crate_name
&str
crate_disambiguator
CrateDisambiguator