@@ -18,6 +18,7 @@ use {names_to_string, module_to_string};
1818use { resolve_error, ResolutionError } ;
1919
2020use rustc:: ty;
21+ use rustc:: lint:: builtin:: PRIVATE_IN_PUBLIC ;
2122use rustc:: hir:: def_id:: DefId ;
2223use rustc:: hir:: def:: * ;
2324use rustc:: util:: nodemap:: FxHashMap ;
@@ -294,7 +295,8 @@ impl<'a> Resolver<'a> {
294295 // return the corresponding binding defined by the import directive.
295296 pub fn import ( & self , binding : & ' a NameBinding < ' a > , directive : & ' a ImportDirective < ' a > )
296297 -> & ' a NameBinding < ' a > {
297- let vis = if binding. pseudo_vis ( ) . is_at_least ( directive. vis . get ( ) , self ) {
298+ let vis = if binding. pseudo_vis ( ) . is_at_least ( directive. vis . get ( ) , self ) ||
299+ !directive. is_glob ( ) && binding. is_extern_crate ( ) { // c.f. `PRIVATE_IN_PUBLIC`
298300 directive. vis . get ( )
299301 } else {
300302 binding. pseudo_vis ( )
@@ -718,7 +720,13 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
718720
719721 // All namespaces must be re-exported with extra visibility for an error to occur.
720722 if !any_successful_reexport {
721- if reexport_error. unwrap ( ) . 0 == TypeNS {
723+ let ( ns, binding) = reexport_error. unwrap ( ) ;
724+ if ns == TypeNS && binding. is_extern_crate ( ) {
725+ let msg = format ! ( "extern crate `{}` is private, and cannot be reexported \
726+ (error E0365), consider declaring with `pub`",
727+ ident) ;
728+ self . session . add_lint ( PRIVATE_IN_PUBLIC , directive. id , directive. span , msg) ;
729+ } else if ns == TypeNS {
722730 struct_span_err ! ( self . session, directive. span, E0365 ,
723731 "`{}` is private, and cannot be reexported" , ident)
724732 . span_label ( directive. span , format ! ( "reexport of private `{}`" , ident) )
0 commit comments