@@ -72,7 +72,7 @@ impl<'a> ImportDirective<'a> {
72
72
// this returns the binding for the name this directive defines in that namespace.
73
73
fn import ( & self , binding : & ' a NameBinding < ' a > , privacy_error : Option < Box < PrivacyError < ' a > > > )
74
74
-> NameBinding < ' a > {
75
- let mut modifiers = match self . is_public {
75
+ let mut modifiers = match self . is_public && binding . is_public ( ) {
76
76
true => DefModifiers :: PUBLIC | DefModifiers :: IMPORTABLE ,
77
77
false => DefModifiers :: empty ( ) ,
78
78
} ;
@@ -334,9 +334,11 @@ impl<'a> ::ModuleS<'a> {
334
334
}
335
335
336
336
fn define_in_glob_importers ( & self , name : Name , ns : Namespace , binding : & ' a NameBinding < ' a > ) {
337
- if !binding. defined_with ( DefModifiers :: PUBLIC | DefModifiers :: IMPORTABLE ) { return }
337
+ if !binding. defined_with ( DefModifiers :: IMPORTABLE ) { return }
338
338
for & ( importer, directive) in self . glob_importers . borrow_mut ( ) . iter ( ) {
339
- let _ = importer. try_define_child ( name, ns, directive. import ( binding, None ) ) ;
339
+ if binding. is_public ( ) || self . is_ancestor_of ( importer) {
340
+ let _ = importer. try_define_child ( name, ns, directive. import ( binding, None ) ) ;
341
+ }
340
342
}
341
343
}
342
344
}
@@ -658,8 +660,10 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
658
660
let bindings = target_module. resolutions . borrow ( ) . iter ( ) . filter_map ( |( name, resolution) | {
659
661
resolution. borrow ( ) . binding ( ) . map ( |binding| ( * name, binding) )
660
662
} ) . collect :: < Vec < _ > > ( ) ;
663
+ let allow_private_names = target_module. is_ancestor_of ( module_) ;
661
664
for ( ( name, ns) , binding) in bindings {
662
- if binding. defined_with ( DefModifiers :: IMPORTABLE | DefModifiers :: PUBLIC ) {
665
+ if !binding. defined_with ( DefModifiers :: IMPORTABLE ) { continue }
666
+ if allow_private_names || binding. is_public ( ) {
663
667
let _ = module_. try_define_child ( name, ns, directive. import ( binding, None ) ) ;
664
668
}
665
669
}
0 commit comments