pub fn create_def_with_parent(&mut self,
                                  parent: DefIndex,
                                  node_id: ast::NodeId,
                                  data: DefPathData,
                                  expn_id: ExpnId,
                                  span: Span)
                                  -> DefIndex {
        debug!("create_def_with_parent(parent={:?}, node_id={:?}, data={:?})",
               parent, node_id, data);

        assert!(!self.node_to_def_index.contains_key(&node_id),
                "adding a def'n for node-id {:?} and data {:?} but a previous def'n exists: {:?}",
                node_id,
                data,
                self.table.def_key(self.node_to_def_index[&node_id]));

        // The root node must be created with `create_root_def()`.
        assert!(data != DefPathData::CrateRoot);

        // Find the next free disambiguator for this key.
        let disambiguator = {
            let next_disamb = self.next_disambiguator.entry((parent, data)).or_insert(0);
            let disambiguator = *next_disamb;
            *next_disamb = next_disamb.checked_add(1).expect("disambiguator overflow");
            disambiguator
        };

        let key = DefKey {
            parent: Some(parent),
            disambiguated_data: DisambiguatedDefPathData {
                data, disambiguator
            }
        };

        let parent_hash = self.table.def_path_hash(parent);
        let def_path_hash = key.compute_stable_hash(parent_hash);

        debug!("create_def_with_parent: after disambiguation, key = {:?}", key);

        // Create the definition.
        let index = self.table.allocate(key, def_path_hash);
        assert_eq!(index.index(), self.def_index_to_node.len());
        self.def_index_to_node.push(node_id);

        // Some things for which we allocate `DefIndex`es don't correspond to
        // anything in the AST, so they don't have a `NodeId`. For these cases
        // we don't need a mapping from `NodeId` to `DefIndex`.
        if node_id != ast::DUMMY_NODE_ID {
            debug!("create_def_with_parent: def_index_to_node[{:?} <-> {:?}", index, node_id);
            self.node_to_def_index.insert(node_id, index);
        }

        if expn_id != ExpnId::root() {
            self.expansions_that_defined.insert(index, expn_id);
        }

        // The span is added if it isn't dummy.
        if !span.is_dummy() {
            self.def_index_to_span.insert(index, span);
        }

        index
    }
/// Adds a definition with a parent definition.
Adds a definition with a parent definition.
Adds a definition with a parent definition .
pub fn create_def_with_parent(&mut self,
                                  parent: DefIndex,
                                  node_id: ast::NodeId,
                                  data: DefPathData,
                                  expn_id: ExpnId,
                                  span: Span)
                                  -> DefIndex {
        debug!("create_def_with_parent(parent={:?}, node_id={:?}, data={:?})",
               parent, node_id, data);
        assert!(!self.node_to_def_index.contains_key(&node_id),
                "adding a def'n for node-id {:?} and data {:?} but a previous def'n exists: {:?}",
                node_id,
                data,
                self.table.def_key(self.node_to_def_index[&node_id]));
        // The root node must be created with `create_root_def()`.
        assert!(data != DefPathData::CrateRoot);
        // Find the next free disambiguator for this key.
        let disambiguator = {
            let next_disamb = self.next_disambiguator.entry((parent, data)).or_insert(0);
            let disambiguator = *next_disamb;
            *next_disamb = next_disamb.checked_add(1).expect("disambiguator overflow");
            disambiguator
        };
        let key = DefKey {
            parent: Some(parent),
            disambiguated_data: DisambiguatedDefPathData {
                data, disambiguator
            }
        };
        let parent_hash = self.table.def_path_hash(parent);
        let def_path_hash = key.compute_stable_hash(parent_hash);
        debug!("create_def_with_parent: after disambiguation, key = {:?}", key);
        // Create the definition.
        let index = self.table.allocate(key, def_path_hash);
        assert_eq!(index.index(), self.def_index_to_node.len());
        self.def_index_to_node.push(node_id);
        // Some things for which we allocate `DefIndex`es don't correspond to
        // anything in the AST, so they don't have a `NodeId`. For these cases
        // we don't need a mapping from `NodeId` to `DefIndex`.
        if node_id != ast::DUMMY_NODE_ID {
            debug!("create_def_with_parent: def_index_to_node[{:?} <-> {:?}", index, node_id);
            self.node_to_def_index.insert(node_id, index);
        }
        if expn_id != ExpnId::root() {
            self.expansions_that_defined.insert(index, expn_id);
        }
        // The span is added if it isn't dummy.
        if !span.is_dummy() {
            self.def_index_to_span.insert(index, span);
        }
        index
    }
pub fn create_def_with_parent ( & mut self , parent : DefIndex , node_id : ast :: NodeId , data : DefPathData , expn_id : ExpnId , span : Span ) -> DefIndex { debug ! ( " " parent node_id data ) ; assert ! ( self node_to_def_index contains_key ( node_id ) " " node_id data self table def_key ( self node_to_def_index [ node_id ] ) ) ; // The root node must be created with `create_root_def()`. assert ! ( data DefPathData CrateRoot ) ; // Find the next free disambiguator for this key. let disambiguator = { let next_disamb = self . next_disambiguator . entry ( ( parent , data ) ) . or_insert ( 0 ) ; let disambiguator = * next_disamb ; * next_disamb = next_disamb . checked_add ( 1 ) . expect ( " " ) ; disambiguator } ; let key = DefKey { parent : Some ( parent ) , disambiguated_data : DisambiguatedDefPathData { data , disambiguator } } ; let parent_hash = self . table . def_path_hash ( parent ) ; let def_path_hash = key . compute_stable_hash ( parent_hash ) ; debug ! ( " " key ) ; // Create the definition. let index = self . table . allocate ( key , def_path_hash ) ; assert_eq ! ( index index ( ) self def_index_to_node len ( ) ) ; self . def_index_to_node . push ( node_id ) ; // Some things for which we allocate `DefIndex`es don't correspond to // anything in the AST, so they don't have a `NodeId`. For these cases // we don't need a mapping from `NodeId` to `DefIndex`. if node_id != ast :: DUMMY_NODE_ID { debug ! ( " " index node_id ) ; self . node_to_def_index . insert ( node_id , index ) ; } if expn_id != ExpnId :: root ( ) { self . expansions_that_defined . insert ( index , expn_id ) ; } // The span is added if it isn't dummy. if ! span . is_dummy ( ) { self . def_index_to_span . insert ( index , span ) ; } index }
Adds a definition with a parent definition.
Adds a definition with a parent definition .
&mut self
parent
DefIndex
node_id
ast::NodeId
data
DefPathData
expn_id
ExpnId
span
Span
&mut self
parent
DefIndex
node_id
ast::NodeId
data
DefPathData
expn_id
ExpnId
span
Span