@@ -18,6 +18,7 @@ use {names_to_string, module_to_string};
18
18
use { resolve_error, ResolutionError } ;
19
19
20
20
use rustc:: ty;
21
+ use rustc:: lint:: builtin:: PRIVATE_IN_PUBLIC ;
21
22
use rustc:: hir:: def_id:: DefId ;
22
23
use rustc:: hir:: def:: * ;
23
24
use rustc:: util:: nodemap:: FxHashMap ;
@@ -294,7 +295,8 @@ impl<'a> Resolver<'a> {
294
295
// return the corresponding binding defined by the import directive.
295
296
pub fn import ( & self , binding : & ' a NameBinding < ' a > , directive : & ' a ImportDirective < ' a > )
296
297
-> & ' 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`
298
300
directive. vis . get ( )
299
301
} else {
300
302
binding. pseudo_vis ( )
@@ -718,7 +720,13 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
718
720
719
721
// All namespaces must be re-exported with extra visibility for an error to occur.
720
722
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 {
722
730
struct_span_err ! ( self . session, directive. span, E0365 ,
723
731
"`{}` is private, and cannot be reexported" , ident)
724
732
. span_label ( directive. span , format ! ( "reexport of private `{}`" , ident) )
0 commit comments