]> git.lizzy.rs Git - rust.git/commitdiff
extract helper fn
authorDouglas Campos <qmx@qmx.me>
Thu, 9 Aug 2018 22:56:02 +0000 (22:56 +0000)
committerDouglas Campos <qmx@qmx.me>
Thu, 16 Aug 2018 19:20:37 +0000 (19:20 +0000)
src/librustc_resolve/lib.rs

index 1dee385b26a68b9688276382cf272ce4181b316a..c33c4ca454bd8fa80eab1daa726cf26bd899f6c7 100644 (file)
@@ -1964,9 +1964,7 @@ fn resolve_ident_in_lexical_scope(&mut self,
                                 "access to extern crates through prelude is experimental").emit();
                 }
 
-                let crate_id = self.crate_loader.process_path_extern(ident.name, ident.span);
-                let crate_root = self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX });
-                self.populate_module_if_necessary(crate_root);
+                let crate_root = self.load_extern_prelude_crate_if_needed(ident);
 
                 let binding = (crate_root, ty::Visibility::Public,
                                ident.span, Mark::root()).to_name_binding(self.arenas);
@@ -1994,6 +1992,13 @@ fn resolve_ident_in_lexical_scope(&mut self,
         None
     }
 
+    fn load_extern_prelude_crate_if_needed(&mut self, ident: Ident) -> Module<'a> {
+                let crate_id = self.crate_loader.process_path_extern(ident.name, ident.span);
+                let crate_root = self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX });
+                self.populate_module_if_necessary(&crate_root);
+                crate_root
+    }
+
     fn hygienic_lexical_parent(&mut self, module: Module<'a>, span: &mut Span)
                                -> Option<Module<'a>> {
         if !module.expansion.is_descendant_of(span.ctxt().outer()) {