@@ -18,11 +18,10 @@ use rustc_errors::{pluralize, struct_span_err, Applicability};
1818use rustc_hir:: def:: { self , PartialRes } ;
1919use rustc_hir:: def_id:: DefId ;
2020use rustc_middle:: hir:: exports:: Export ;
21+ use rustc_middle:: span_bug;
2122use rustc_middle:: ty;
22- use rustc_middle:: { bug, span_bug} ;
2323use rustc_session:: lint:: builtin:: { PUB_USE_OF_PRIVATE_EXTERN_CRATE , UNUSED_IMPORTS } ;
2424use rustc_session:: lint:: BuiltinLintDiagnostics ;
25- use rustc_session:: DiagnosticMessageId ;
2625use rustc_span:: hygiene:: ExpnId ;
2726use rustc_span:: lev_distance:: find_best_match_for_name;
2827use rustc_span:: symbol:: { kw, Ident , Symbol } ;
@@ -456,13 +455,13 @@ impl<'a> Resolver<'a> {
456455 binding : & ' a NameBinding < ' a > ,
457456 import : & ' a Import < ' a > ,
458457 ) -> & ' a NameBinding < ' a > {
459- let vis = if binding. pseudo_vis ( ) . is_at_least ( import. vis . get ( ) , self ) ||
458+ let vis = if binding. vis . is_at_least ( import. vis . get ( ) , self ) ||
460459 // cf. `PUB_USE_OF_PRIVATE_EXTERN_CRATE`
461460 !import. is_glob ( ) && binding. is_extern_crate ( )
462461 {
463462 import. vis . get ( )
464463 } else {
465- binding. pseudo_vis ( )
464+ binding. vis
466465 } ;
467466
468467 if let ImportKind :: Glob { ref max_vis, .. } = import. kind {
@@ -1178,7 +1177,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
11781177 self . r . per_ns ( |this, ns| {
11791178 if let Ok ( binding) = source_bindings[ ns] . get ( ) {
11801179 let vis = import. vis . get ( ) ;
1181- if !binding. pseudo_vis ( ) . is_at_least ( vis, & * this) {
1180+ if !binding. vis . is_at_least ( vis, & * this) {
11821181 reexport_error = Some ( ( ns, binding) ) ;
11831182 } else {
11841183 any_successful_reexport = true ;
@@ -1362,7 +1361,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
13621361 Some ( None ) => import. parent_scope . module ,
13631362 None => continue ,
13641363 } ;
1365- if self . r . is_accessible_from ( binding. pseudo_vis ( ) , scope) {
1364+ if self . r . is_accessible_from ( binding. vis , scope) {
13661365 let imported_binding = self . r . import ( binding, import) ;
13671366 let _ = self . r . try_define ( import. parent_scope . module , key, imported_binding) ;
13681367 }
@@ -1380,9 +1379,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
13801379
13811380 let mut reexports = Vec :: new ( ) ;
13821381
1383- module. for_each_child ( self . r , |this, ident, ns, binding| {
1384- // Filter away ambiguous imports and anything that has def-site
1385- // hygiene.
1382+ module. for_each_child ( self . r , |this, ident, _, binding| {
1383+ // Filter away ambiguous imports and anything that has def-site hygiene.
13861384 // FIXME: Implement actual cross-crate hygiene.
13871385 let is_good_import =
13881386 binding. is_import ( ) && !binding. is_ambiguity ( ) && !ident. span . from_expansion ( ) ;
@@ -1392,71 +1390,6 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
13921390 reexports. push ( Export { ident, res, span : binding. span , vis : binding. vis } ) ;
13931391 }
13941392 }
1395-
1396- if let NameBindingKind :: Import { binding : orig_binding, import, .. } = binding. kind {
1397- if ns == TypeNS
1398- && orig_binding. is_variant ( )
1399- && !orig_binding. vis . is_at_least ( binding. vis , & * this)
1400- {
1401- let msg = match import. kind {
1402- ImportKind :: Single { .. } => {
1403- format ! ( "variant `{}` is private and cannot be re-exported" , ident)
1404- }
1405- ImportKind :: Glob { .. } => {
1406- let msg = "enum is private and its variants \
1407- cannot be re-exported"
1408- . to_owned ( ) ;
1409- let error_id = (
1410- DiagnosticMessageId :: ErrorId ( 0 ) , // no code?!
1411- Some ( binding. span ) ,
1412- msg. clone ( ) ,
1413- ) ;
1414- let fresh =
1415- this. session . one_time_diagnostics . borrow_mut ( ) . insert ( error_id) ;
1416- if !fresh {
1417- return ;
1418- }
1419- msg
1420- }
1421- ref s => bug ! ( "unexpected import kind {:?}" , s) ,
1422- } ;
1423- let mut err = this. session . struct_span_err ( binding. span , & msg) ;
1424-
1425- let imported_module = match import. imported_module . get ( ) {
1426- Some ( ModuleOrUniformRoot :: Module ( module) ) => module,
1427- _ => bug ! ( "module should exist" ) ,
1428- } ;
1429- let parent_module = imported_module. parent . expect ( "parent should exist" ) ;
1430- let resolutions = this. resolutions ( parent_module) . borrow ( ) ;
1431- let enum_path_segment_index = import. module_path . len ( ) - 1 ;
1432- let enum_ident = import. module_path [ enum_path_segment_index] . ident ;
1433-
1434- let key = this. new_key ( enum_ident, TypeNS ) ;
1435- let enum_resolution = resolutions. get ( & key) . expect ( "resolution should exist" ) ;
1436- let enum_span =
1437- enum_resolution. borrow ( ) . binding . expect ( "binding should exist" ) . span ;
1438- let enum_def_span = this. session . source_map ( ) . guess_head_span ( enum_span) ;
1439- let enum_def_snippet = this
1440- . session
1441- . source_map ( )
1442- . span_to_snippet ( enum_def_span)
1443- . expect ( "snippet should exist" ) ;
1444- // potentially need to strip extant `crate`/`pub(path)` for suggestion
1445- let after_vis_index = enum_def_snippet
1446- . find ( "enum" )
1447- . expect ( "`enum` keyword should exist in snippet" ) ;
1448- let suggestion = format ! ( "pub {}" , & enum_def_snippet[ after_vis_index..] ) ;
1449-
1450- this. session . diag_span_suggestion_once (
1451- & mut err,
1452- DiagnosticMessageId :: ErrorId ( 0 ) ,
1453- enum_def_span,
1454- "consider making the enum public" ,
1455- suggestion,
1456- ) ;
1457- err. emit ( ) ;
1458- }
1459- }
14601393 } ) ;
14611394
14621395 if !reexports. is_empty ( ) {
0 commit comments