@@ -71,19 +71,6 @@ pub struct ImportDirective<'a> {
7171}
7272
7373impl < ' a > ImportDirective < ' a > {
74- // Given the binding to which this directive resolves in a particular namespace,
75- // this returns the binding for the name this directive defines in that namespace.
76- fn import ( & ' a self , binding : & ' a NameBinding < ' a > ) -> NameBinding < ' a > {
77- NameBinding {
78- kind : NameBindingKind :: Import {
79- binding : binding,
80- directive : self ,
81- } ,
82- span : self . span ,
83- vis : self . vis ,
84- }
85- }
86-
8774 pub fn is_glob ( & self ) -> bool {
8875 match self . subclass { ImportDirectiveSubclass :: GlobImport { .. } => true , _ => false }
8976 }
@@ -258,6 +245,20 @@ impl<'a> ::ModuleS<'a> {
258245}
259246
260247impl < ' a > Resolver < ' a > {
248+ // Given a binding and an import directive that resolves to it,
249+ // return the corresponding binding defined by the import directive.
250+ fn import ( & mut self , binding : & ' a NameBinding < ' a > , directive : & ' a ImportDirective < ' a > )
251+ -> NameBinding < ' a > {
252+ NameBinding {
253+ kind : NameBindingKind :: Import {
254+ binding : binding,
255+ directive : directive,
256+ } ,
257+ span : directive. span ,
258+ vis : directive. vis ,
259+ }
260+ }
261+
261262 // Define the name or return the existing binding if there is a collision.
262263 pub fn try_define < T > ( & mut self , module : Module < ' a > , name : Name , ns : Namespace , binding : T )
263264 -> Result < ( ) , & ' a NameBinding < ' a > >
@@ -305,7 +306,8 @@ impl<'a> Resolver<'a> {
305306 // Define `new_binding` in `module`s glob importers.
306307 if new_binding. is_importable ( ) && new_binding. is_pseudo_public ( ) {
307308 for & ( importer, directive) in module. glob_importers . borrow_mut ( ) . iter ( ) {
308- let _ = self . try_define ( importer, name, ns, directive. import ( new_binding) ) ;
309+ let imported_binding = self . import ( new_binding, directive) ;
310+ let _ = self . try_define ( importer, name, ns, imported_binding) ;
309311 }
310312 }
311313
@@ -408,7 +410,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
408410 span : DUMMY_SP ,
409411 vis : ty:: Visibility :: Public ,
410412 } ) ;
411- let dummy_binding = directive . import ( dummy_binding) ;
413+ let dummy_binding = self . import ( dummy_binding, directive ) ;
412414
413415 let _ = self . try_define ( source_module, target, ValueNS , dummy_binding. clone ( ) ) ;
414416 let _ = self . try_define ( source_module, target, TypeNS , dummy_binding) ;
@@ -512,10 +514,10 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
512514 Success ( binding) if !self . is_accessible ( binding. vis ) => { }
513515 Success ( binding) if !determined. get ( ) => {
514516 determined. set ( true ) ;
515- let imported_binding = directive . import ( binding) ;
517+ let imported_binding = self . import ( binding, directive ) ;
516518 let conflict = self . try_define ( module, target, ns, imported_binding) ;
517519 if let Err ( old_binding) = conflict {
518- let binding = & directive . import ( binding) ;
520+ let binding = & self . import ( binding, directive ) ;
519521 self . report_conflict ( module, target, ns, binding, old_binding) ;
520522 }
521523 privacy_error = false ;
@@ -556,7 +558,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
556558 for & ( ns, result) in & [ ( ValueNS , & value_result) , ( TypeNS , & type_result) ] {
557559 let binding = match * result { Success ( binding) => binding, _ => continue } ;
558560 self . privacy_errors . push ( PrivacyError ( directive. span , source, binding) ) ;
559- let _ = self . try_define ( module, target, ns, directive. import ( binding) ) ;
561+ let imported_binding = self . import ( binding, directive) ;
562+ let _ = self . try_define ( module, target, ns, imported_binding) ;
560563 }
561564 }
562565
@@ -638,7 +641,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
638641 } ) . collect :: < Vec < _ > > ( ) ;
639642 for ( ( name, ns) , binding) in bindings {
640643 if binding. is_importable ( ) && binding. is_pseudo_public ( ) {
641- let _ = self . try_define ( module, name, ns, directive. import ( binding) ) ;
644+ let imported_binding = self . import ( binding, directive) ;
645+ let _ = self . try_define ( module, name, ns, imported_binding) ;
642646 }
643647 }
644648
0 commit comments