@@ -71,19 +71,6 @@ pub struct ImportDirective<'a> {
71
71
}
72
72
73
73
impl < ' 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
-
87
74
pub fn is_glob ( & self ) -> bool {
88
75
match self . subclass { ImportDirectiveSubclass :: GlobImport { .. } => true , _ => false }
89
76
}
@@ -258,6 +245,20 @@ impl<'a> ::ModuleS<'a> {
258
245
}
259
246
260
247
impl < ' 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
+
261
262
// Define the name or return the existing binding if there is a collision.
262
263
pub fn try_define < T > ( & mut self , module : Module < ' a > , name : Name , ns : Namespace , binding : T )
263
264
-> Result < ( ) , & ' a NameBinding < ' a > >
@@ -305,7 +306,8 @@ impl<'a> Resolver<'a> {
305
306
// Define `new_binding` in `module`s glob importers.
306
307
if new_binding. is_importable ( ) && new_binding. is_pseudo_public ( ) {
307
308
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) ;
309
311
}
310
312
}
311
313
@@ -408,7 +410,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
408
410
span : DUMMY_SP ,
409
411
vis : ty:: Visibility :: Public ,
410
412
} ) ;
411
- let dummy_binding = directive . import ( dummy_binding) ;
413
+ let dummy_binding = self . import ( dummy_binding, directive ) ;
412
414
413
415
let _ = self . try_define ( source_module, target, ValueNS , dummy_binding. clone ( ) ) ;
414
416
let _ = self . try_define ( source_module, target, TypeNS , dummy_binding) ;
@@ -512,10 +514,10 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
512
514
Success ( binding) if !self . is_accessible ( binding. vis ) => { }
513
515
Success ( binding) if !determined. get ( ) => {
514
516
determined. set ( true ) ;
515
- let imported_binding = directive . import ( binding) ;
517
+ let imported_binding = self . import ( binding, directive ) ;
516
518
let conflict = self . try_define ( module, target, ns, imported_binding) ;
517
519
if let Err ( old_binding) = conflict {
518
- let binding = & directive . import ( binding) ;
520
+ let binding = & self . import ( binding, directive ) ;
519
521
self . report_conflict ( module, target, ns, binding, old_binding) ;
520
522
}
521
523
privacy_error = false ;
@@ -556,7 +558,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
556
558
for & ( ns, result) in & [ ( ValueNS , & value_result) , ( TypeNS , & type_result) ] {
557
559
let binding = match * result { Success ( binding) => binding, _ => continue } ;
558
560
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) ;
560
563
}
561
564
}
562
565
@@ -638,7 +641,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
638
641
} ) . collect :: < Vec < _ > > ( ) ;
639
642
for ( ( name, ns) , binding) in bindings {
640
643
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) ;
642
646
}
643
647
}
644
648
0 commit comments