fn add_import_directive(
        &mut self,
        module_path: Vec<Segment>,
        subclass: ImportDirectiveSubclass<'a>,
        span: Span,
        id: NodeId,
        item: &ast::Item,
        root_span: Span,
        root_id: NodeId,
        vis: ty::Visibility,
    ) {
        let current_module = self.parent_scope.module;
        let directive = self.r.arenas.alloc_import_directive(ImportDirective {
            parent_scope: self.parent_scope,
            module_path,
            imported_module: Cell::new(None),
            subclass,
            span,
            id,
            use_span: item.span,
            use_span_with_attributes: item.span_with_attributes(),
            has_attributes: !item.attrs.is_empty(),
            root_span,
            root_id,
            vis: Cell::new(vis),
            used: Cell::new(false),
        });

        debug!("add_import_directive({:?})", directive);

        self.r.indeterminate_imports.push(directive);
        match directive.subclass {
            // Don't add unresolved underscore imports to modules
            SingleImport { target: Ident { name: kw::Underscore, .. }, .. } => {}
            SingleImport { target, type_ns_only, .. } => {
                self.r.per_ns(|this, ns| if !type_ns_only || ns == TypeNS {
                    let key = this.new_key(target, ns);
                    let mut resolution = this.resolution(current_module, key).borrow_mut();
                    resolution.add_single_import(directive);
                });
            }
            // We don't add prelude imports to the globs since they only affect lexical scopes,
            // which are not relevant to import resolution.
            GlobImport { is_prelude: true, .. } => {}
            GlobImport { .. } => current_module.globs.borrow_mut().push(directive),
            _ => unreachable!(),
        }
    }
// Add an import directive to the current module.
Add an import directive to the current module.
Add an import directive to the current module .
fn add_import_directive(
        &mut self,
        module_path: Vec<Segment>,
        subclass: ImportDirectiveSubclass<'a>,
        span: Span,
        id: NodeId,
        item: &ast::Item,
        root_span: Span,
        root_id: NodeId,
        vis: ty::Visibility,
    ) {
        let current_module = self.parent_scope.module;
        let directive = self.r.arenas.alloc_import_directive(ImportDirective {
            parent_scope: self.parent_scope,
            module_path,
            imported_module: Cell::new(None),
            subclass,
            span,
            id,
            use_span: item.span,
            use_span_with_attributes: item.span_with_attributes(),
            has_attributes: !item.attrs.is_empty(),
            root_span,
            root_id,
            vis: Cell::new(vis),
            used: Cell::new(false),
        });
        debug!("add_import_directive({:?})", directive);
        self.r.indeterminate_imports.push(directive);
        match directive.subclass {
            // Don't add unresolved underscore imports to modules
            SingleImport { target: Ident { name: kw::Underscore, .. }, .. } => {}
            SingleImport { target, type_ns_only, .. } => {
                self.r.per_ns(|this, ns| if !type_ns_only || ns == TypeNS {
                    let key = this.new_key(target, ns);
                    let mut resolution = this.resolution(current_module, key).borrow_mut();
                    resolution.add_single_import(directive);
                });
            }
            // We don't add prelude imports to the globs since they only affect lexical scopes,
            // which are not relevant to import resolution.
            GlobImport { is_prelude: true, .. } => {}
            GlobImport { .. } => current_module.globs.borrow_mut().push(directive),
            _ => unreachable!(),
        }
    }
fn add_import_directive ( & mut self , module_path : Vec < Segment > , subclass : ImportDirectiveSubclass < ' a > , span : Span , id : NodeId , item : & ast :: Item , root_span : Span , root_id : NodeId , vis : ty :: Visibility , ) { let current_module = self . parent_scope . module ; let directive = self . r . arenas . alloc_import_directive ( ImportDirective { parent_scope : self . parent_scope , module_path , imported_module : Cell :: new ( None ) , subclass , span , id , use_span : item . span , use_span_with_attributes : item . span_with_attributes ( ) , has_attributes : ! item . attrs . is_empty ( ) , root_span , root_id , vis : Cell :: new ( vis ) , used : Cell :: new ( false ) , } ) ; debug ! ( " " directive ) ; self . r . indeterminate_imports . push ( directive ) ; match directive . subclass { // Don't add unresolved underscore imports to modules SingleImport { target : Ident { name : kw :: Underscore , .. } , .. } => { } SingleImport { target , type_ns_only , .. } => { self . r . per_ns ( | this , ns | if ! type_ns_only || ns == TypeNS { let key = this . new_key ( target , ns ) ; let mut resolution = this . resolution ( current_module , key ) . borrow_mut ( ) ; resolution . add_single_import ( directive ) ; } ) ; } // We don't add prelude imports to the globs since they only affect lexical scopes, // which are not relevant to import resolution. GlobImport { is_prelude : true , .. } => { } GlobImport { .. } => current_module . globs . borrow_mut ( ) . push ( directive ) , _ => unreachable ! ( ) , } }
Add an import directive to the current module.
Add an import directive to the current module .
&mut self
module_path
Vec<Segment>
subclass
ImportDirectiveSubclass<'a>
span
Span
id
NodeId
item
&ast::Item
root_span
Span
root_id
NodeId
vis
ty::Visibility