@@ -184,7 +184,7 @@ impl<'a> NameResolution<'a> {
184
184
// the name, and (3) no public glob has defined the name, the resolution depends
185
185
// on whether more globs can define the name.
186
186
if !allow_private_imports && directive. vis != ty:: Visibility :: Public &&
187
- !self . binding . map ( NameBinding :: is_public ) . unwrap_or ( false ) {
187
+ !self . binding . map ( NameBinding :: is_pseudo_public ) . unwrap_or ( false ) {
188
188
return None ;
189
189
}
190
190
@@ -242,7 +242,8 @@ impl<'a> ::ModuleS<'a> {
242
242
if let Some ( result) = resolution. try_result ( ns, allow_private_imports) {
243
243
// If the resolution doesn't depend on glob definability, check privacy and return.
244
244
return result. and_then ( |binding| {
245
- let allowed = allow_private_imports || !binding. is_import ( ) || binding. is_public ( ) ;
245
+ let allowed = allow_private_imports || !binding. is_import ( ) ||
246
+ binding. is_pseudo_public ( ) ;
246
247
if allowed { Success ( binding) } else { Failed ( None ) }
247
248
} ) ;
248
249
}
@@ -336,7 +337,7 @@ impl<'a> ::ModuleS<'a> {
336
337
}
337
338
338
339
fn define_in_glob_importers ( & self , name : Name , ns : Namespace , binding : & ' a NameBinding < ' a > ) {
339
- if !binding. defined_with ( DefModifiers :: IMPORTABLE ) || !binding. is_public ( ) { return }
340
+ if !binding. defined_with ( DefModifiers :: IMPORTABLE ) || !binding. is_pseudo_public ( ) { return }
340
341
for & ( importer, directive) in self . glob_importers . borrow_mut ( ) . iter ( ) {
341
342
let _ = importer. try_define_child ( name, ns, directive. import ( binding, None ) ) ;
342
343
}
@@ -569,7 +570,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
569
570
570
571
let ast_map = self . resolver . ast_map ;
571
572
match ( & value_result, & type_result) {
572
- ( & Success ( binding) , _) if !binding. vis . is_at_least ( directive. vis , ast_map) &&
573
+ ( & Success ( binding) , _) if !binding. pseudo_vis ( ) . is_at_least ( directive. vis , ast_map) &&
573
574
self . resolver . is_accessible ( binding. vis ) => {
574
575
let msg = format ! ( "`{}` is private, and cannot be reexported" , source) ;
575
576
let note_msg = format ! ( "consider marking `{}` as `pub` in the imported module" ,
@@ -579,7 +580,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
579
580
. emit ( ) ;
580
581
}
581
582
582
- ( _, & Success ( binding) ) if !binding. vis . is_at_least ( directive. vis , ast_map) &&
583
+ ( _, & Success ( binding) ) if !binding. pseudo_vis ( ) . is_at_least ( directive. vis , ast_map) &&
583
584
self . resolver . is_accessible ( binding. vis ) => {
584
585
if binding. is_extern_crate ( ) {
585
586
let msg = format ! ( "extern crate `{}` is private, and cannot be reexported \
@@ -661,7 +662,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
661
662
resolution. borrow ( ) . binding ( ) . map ( |binding| ( * name, binding) )
662
663
} ) . collect :: < Vec < _ > > ( ) ;
663
664
for ( ( name, ns) , binding) in bindings {
664
- if binding. defined_with ( DefModifiers :: IMPORTABLE ) && binding. is_public ( ) {
665
+ if binding. defined_with ( DefModifiers :: IMPORTABLE ) && binding. is_pseudo_public ( ) {
665
666
let _ = module_. try_define_child ( name, ns, directive. import ( binding, None ) ) ;
666
667
}
667
668
}
@@ -697,15 +698,16 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
697
698
None => continue ,
698
699
} ;
699
700
700
- if binding. is_public ( ) && ( binding. is_import ( ) || binding. is_extern_crate ( ) ) {
701
+ if binding. vis == ty:: Visibility :: Public &&
702
+ ( binding. is_import ( ) || binding. is_extern_crate ( ) ) {
701
703
if let Some ( def) = binding. def ( ) {
702
704
reexports. push ( Export { name : name, def_id : def. def_id ( ) } ) ;
703
705
}
704
706
}
705
707
706
708
if let NameBindingKind :: Import { binding : orig_binding, id, .. } = binding. kind {
707
- if ns == TypeNS && binding . is_public ( ) &&
708
- orig_binding. defined_with ( DefModifiers :: PRIVATE_VARIANT ) {
709
+ if ns == TypeNS && orig_binding . is_variant ( ) &&
710
+ ! orig_binding. vis . is_at_least ( binding . vis , & self . resolver . ast_map ) {
709
711
let msg = format ! ( "variant `{}` is private, and cannot be reexported \
710
712
(error E0364), consider declaring its enum as `pub`",
711
713
name) ;
0 commit comments