fn create_def(
        &mut self,
        parent: LocalDefId,
        node_id: ast::NodeId,
        data: DefPathData,
        expn_id: ExpnId,
        span: Span,
    ) -> LocalDefId {
        assert!(
            !self.node_id_to_def_id.contains_key(&node_id),
            "adding a def'n for node-id {:?} and data {:?} but a previous def'n exists: {:?}",
            node_id,
            data,
            self.definitions.def_key(self.node_id_to_def_id[&node_id]),
        );

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

        let def_id = self.definitions.create_def(parent, data, expn_id, next_disambiguator);

        assert_eq!(self.def_id_to_span.push(span), def_id);

        // Some things for which we allocate `LocalDefId`s 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 `LocalDefId`.
        if node_id != ast::DUMMY_NODE_ID {
            debug!("create_def: def_id_to_node_id[{:?}] <-> {:?}", def_id, node_id);
            self.node_id_to_def_id.insert(node_id, def_id);
        }
        assert_eq!(self.def_id_to_node_id.push(node_id), def_id);

        def_id
    }
/// Adds a definition with a parent definition.
Adds a definition with a parent definition.
Adds a definition with a parent definition .
fn create_def(
        &mut self,
        parent: LocalDefId,
        node_id: ast::NodeId,
        data: DefPathData,
        expn_id: ExpnId,
        span: Span,
    ) -> LocalDefId {
        assert!(
            !self.node_id_to_def_id.contains_key(&node_id),
            "adding a def'n for node-id {:?} and data {:?} but a previous def'n exists: {:?}",
            node_id,
            data,
            self.definitions.def_key(self.node_id_to_def_id[&node_id]),
        );
        // Find the next free disambiguator for this key.
        let next_disambiguator = &mut self.next_disambiguator;
        let next_disambiguator = |parent, data| {
            let next_disamb = next_disambiguator.entry((parent, data)).or_insert(0);
            let disambiguator = *next_disamb;
            *next_disamb = next_disamb.checked_add(1).expect("disambiguator overflow");
            disambiguator
        };
        let def_id = self.definitions.create_def(parent, data, expn_id, next_disambiguator);
        assert_eq!(self.def_id_to_span.push(span), def_id);
        // Some things for which we allocate `LocalDefId`s 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 `LocalDefId`.
        if node_id != ast::DUMMY_NODE_ID {
            debug!("create_def: def_id_to_node_id[{:?}] <-> {:?}", def_id, node_id);
            self.node_id_to_def_id.insert(node_id, def_id);
        }
        assert_eq!(self.def_id_to_node_id.push(node_id), def_id);
        def_id
    }
fn create_def ( & mut self , parent : LocalDefId , node_id : ast :: NodeId , data : DefPathData , expn_id : ExpnId , span : Span , ) -> LocalDefId { assert ! ( self node_id_to_def_id contains_key ( node_id ) " " node_id data self definitions def_key ( self node_id_to_def_id [ node_id ] ) ) ; // Find the next free disambiguator for this key. let next_disambiguator = & mut self . next_disambiguator ; let next_disambiguator = | parent , data | { let next_disamb = next_disambiguator . entry ( ( parent , data ) ) . or_insert ( 0 ) ; let disambiguator = * next_disamb ; * next_disamb = next_disamb . checked_add ( 1 ) . expect ( " " ) ; disambiguator } ; let def_id = self . definitions . create_def ( parent , data , expn_id , next_disambiguator ) ; assert_eq ! ( self def_id_to_span push ( span ) def_id ) ; // Some things for which we allocate `LocalDefId`s 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 `LocalDefId`. if node_id != ast :: DUMMY_NODE_ID { debug ! ( " " def_id node_id ) ; self . node_id_to_def_id . insert ( node_id , def_id ) ; } assert_eq ! ( self def_id_to_node_id push ( node_id ) def_id ) ; def_id }
Adds a definition with a parent definition.
Adds a definition with a parent definition .
&mut self
parent
LocalDefId
node_id
ast::NodeId
data
DefPathData
expn_id
ExpnId
span
Span
&mut self
parent
LocalDefId
node_id
ast::NodeId
data
DefPathData
expn_id
ExpnId
span
Span