fn process_legacy_macro_imports(&mut self, item: &Item, module: Module<'a>) -> bool {
        let mut import_all = None;
        let mut single_imports = Vec::new();
        for attr in &item.attrs {
            if attr.check_name(sym::macro_use) {
                if self.parent_scope.module.parent.is_some() {
                    span_err!(self.r.session, item.span, E0468,
                        "an `extern crate` loading macros must be at the crate root");
                }
                if let ItemKind::ExternCrate(Some(orig_name)) = item.kind {
                    if orig_name == kw::SelfLower {
                        self.r.session.span_err(attr.span,
                            "`macro_use` is not supported on `extern crate self`");
                    }
                }
                let ill_formed = |span| span_err!(self.r.session, span, E0466, "bad macro import");
                match attr.meta() {
                    Some(meta) => match meta.kind {
                        MetaItemKind::Word => {
                            import_all = Some(meta.span);
                            break;
                        }
                        MetaItemKind::List(nested_metas) => for nested_meta in nested_metas {
                            match nested_meta.ident() {
                                Some(ident) if nested_meta.is_word() => single_imports.push(ident),
                                _ => ill_formed(nested_meta.span()),
                            }
                        }
                        MetaItemKind::NameValue(..) => ill_formed(meta.span),
                    }
                    None => ill_formed(attr.span),
                }
            }
        }

        let macro_use_directive =
                |this: &Self, span| this.r.arenas.alloc_import_directive(ImportDirective {
            root_id: item.id,
            id: item.id,
            parent_scope: this.parent_scope,
            imported_module: Cell::new(Some(ModuleOrUniformRoot::Module(module))),
            subclass: ImportDirectiveSubclass::MacroUse,
            use_span_with_attributes: item.span_with_attributes(),
            has_attributes: !item.attrs.is_empty(),
            use_span: item.span,
            root_span: span,
            span,
            module_path: Vec::new(),
            vis: Cell::new(ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX))),
            used: Cell::new(false),
        });

        let allow_shadowing = self.parent_scope.expansion == ExpnId::root();
        if let Some(span) = import_all {
            let directive = macro_use_directive(self, span);
            self.r.potentially_unused_imports.push(directive);
            module.for_each_child(self, |this, ident, ns, binding| if ns == MacroNS {
                let imported_binding = this.r.import(binding, directive);
                this.legacy_import_macro(ident.name, imported_binding, span, allow_shadowing);
            });
        } else {
            for ident in single_imports.iter().cloned() {
                let result = self.r.resolve_ident_in_module(
                    ModuleOrUniformRoot::Module(module),
                    ident,
                    MacroNS,
                    &self.parent_scope,
                    false,
                    ident.span,
                );
                if let Ok(binding) = result {
                    let directive = macro_use_directive(self, ident.span);
                    self.r.potentially_unused_imports.push(directive);
                    let imported_binding = self.r.import(binding, directive);
                    self.legacy_import_macro(ident.name, imported_binding,
                                             ident.span, allow_shadowing);
                } else {
                    span_err!(self.r.session, ident.span, E0469, "imported macro not found");
                }
            }
        }
        import_all.is_some() || !single_imports.is_empty()
    }
/// Returns `true` if we should consider the underlying `extern crate` to be used.
Returns `true` if we should consider the underlying `extern crate` to be used.
Returns ` true ` if we should consider the underlying ` extern crate ` to be used .
fn process_legacy_macro_imports(&mut self, item: &Item, module: Module<'a>) -> bool {
        let mut import_all = None;
        let mut single_imports = Vec::new();
        for attr in &item.attrs {
            if attr.check_name(sym::macro_use) {
                if self.parent_scope.module.parent.is_some() {
                    span_err!(self.r.session, item.span, E0468,
                        "an `extern crate` loading macros must be at the crate root");
                }
                if let ItemKind::ExternCrate(Some(orig_name)) = item.kind {
                    if orig_name == kw::SelfLower {
                        self.r.session.span_err(attr.span,
                            "`macro_use` is not supported on `extern crate self`");
                    }
                }
                let ill_formed = |span| span_err!(self.r.session, span, E0466, "bad macro import");
                match attr.meta() {
                    Some(meta) => match meta.kind {
                        MetaItemKind::Word => {
                            import_all = Some(meta.span);
                            break;
                        }
                        MetaItemKind::List(nested_metas) => for nested_meta in nested_metas {
                            match nested_meta.ident() {
                                Some(ident) if nested_meta.is_word() => single_imports.push(ident),
                                _ => ill_formed(nested_meta.span()),
                            }
                        }
                        MetaItemKind::NameValue(..) => ill_formed(meta.span),
                    }
                    None => ill_formed(attr.span),
                }
            }
        }
        let macro_use_directive =
                |this: &Self, span| this.r.arenas.alloc_import_directive(ImportDirective {
            root_id: item.id,
            id: item.id,
            parent_scope: this.parent_scope,
            imported_module: Cell::new(Some(ModuleOrUniformRoot::Module(module))),
            subclass: ImportDirectiveSubclass::MacroUse,
            use_span_with_attributes: item.span_with_attributes(),
            has_attributes: !item.attrs.is_empty(),
            use_span: item.span,
            root_span: span,
            span,
            module_path: Vec::new(),
            vis: Cell::new(ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX))),
            used: Cell::new(false),
        });
        let allow_shadowing = self.parent_scope.expansion == ExpnId::root();
        if let Some(span) = import_all {
            let directive = macro_use_directive(self, span);
            self.r.potentially_unused_imports.push(directive);
            module.for_each_child(self, |this, ident, ns, binding| if ns == MacroNS {
                let imported_binding = this.r.import(binding, directive);
                this.legacy_import_macro(ident.name, imported_binding, span, allow_shadowing);
            });
        } else {
            for ident in single_imports.iter().cloned() {
                let result = self.r.resolve_ident_in_module(
                    ModuleOrUniformRoot::Module(module),
                    ident,
                    MacroNS,
                    &self.parent_scope,
                    false,
                    ident.span,
                );
                if let Ok(binding) = result {
                    let directive = macro_use_directive(self, ident.span);
                    self.r.potentially_unused_imports.push(directive);
                    let imported_binding = self.r.import(binding, directive);
                    self.legacy_import_macro(ident.name, imported_binding,
                                             ident.span, allow_shadowing);
                } else {
                    span_err!(self.r.session, ident.span, E0469, "imported macro not found");
                }
            }
        }
        import_all.is_some() || !single_imports.is_empty()
    }
fn process_legacy_macro_imports ( & mut self , item : & Item , module : Module < ' a > ) -> bool { let mut import_all = None ; let mut single_imports = Vec :: new ( ) ; for attr in & item . attrs { if attr . check_name ( sym :: macro_use ) { if self . parent_scope . module . parent . is_some ( ) { span_err ! ( self r session item span E0468 " " ) ; } if let ItemKind :: ExternCrate ( Some ( orig_name ) ) = item . kind { if orig_name == kw :: SelfLower { self . r . session . span_err ( attr . span , " " ) ; } } let ill_formed = | span | span_err ! ( self r session span E0466 " " ) ; match attr . meta ( ) { Some ( meta ) => match meta . kind { MetaItemKind :: Word => { import_all = Some ( meta . span ) ; break ; } MetaItemKind :: List ( nested_metas ) => for nested_meta in nested_metas { match nested_meta . ident ( ) { Some ( ident ) if nested_meta . is_word ( ) => single_imports . push ( ident ) , _ => ill_formed ( nested_meta . span ( ) ) , } } MetaItemKind :: NameValue ( .. ) => ill_formed ( meta . span ) , } None => ill_formed ( attr . span ) , } } } let macro_use_directive = | this : & Self , span | this . r . arenas . alloc_import_directive ( ImportDirective { root_id : item . id , id : item . id , parent_scope : this . parent_scope , imported_module : Cell :: new ( Some ( ModuleOrUniformRoot :: Module ( module ) ) ) , subclass : ImportDirectiveSubclass :: MacroUse , use_span_with_attributes : item . span_with_attributes ( ) , has_attributes : ! item . attrs . is_empty ( ) , use_span : item . span , root_span : span , span , module_path : Vec :: new ( ) , vis : Cell :: new ( ty :: Visibility :: Restricted ( DefId :: local ( CRATE_DEF_INDEX ) ) ) , used : Cell :: new ( false ) , } ) ; let allow_shadowing = self . parent_scope . expansion == ExpnId :: root ( ) ; if let Some ( span ) = import_all { let directive = macro_use_directive ( self , span ) ; self . r . potentially_unused_imports . push ( directive ) ; module . for_each_child ( self , | this , ident , ns , binding | if ns == MacroNS { let imported_binding = this . r . import ( binding , directive ) ; this . legacy_import_macro ( ident . name , imported_binding , span , allow_shadowing ) ; } ) ; } else { for ident in single_imports . iter ( ) . cloned ( ) { let result = self . r . resolve_ident_in_module ( ModuleOrUniformRoot :: Module ( module ) , ident , MacroNS , & self . parent_scope , false , ident . span , ) ; if let Ok ( binding ) = result { let directive = macro_use_directive ( self , ident . span ) ; self . r . potentially_unused_imports . push ( directive ) ; let imported_binding = self . r . import ( binding , directive ) ; self . legacy_import_macro ( ident . name , imported_binding , ident . span , allow_shadowing ) ; } else { span_err ! ( self r session ident span E0469 " " ) ; } } } import_all . is_some ( ) || ! single_imports . is_empty ( ) }
Returns `true` if we should consider the underlying `extern crate` to be used.
Returns ` true ` if we should consider the underlying ` extern crate ` to be used .
&mut self
item
&Item
module
Module<'a>