@@ -18,11 +18,10 @@ use rustc_errors::{pluralize, struct_span_err, Applicability};
18
18
use rustc_hir:: def:: { self , PartialRes } ;
19
19
use rustc_hir:: def_id:: DefId ;
20
20
use rustc_middle:: hir:: exports:: Export ;
21
+ use rustc_middle:: span_bug;
21
22
use rustc_middle:: ty;
22
- use rustc_middle:: { bug, span_bug} ;
23
23
use rustc_session:: lint:: builtin:: { PUB_USE_OF_PRIVATE_EXTERN_CRATE , UNUSED_IMPORTS } ;
24
24
use rustc_session:: lint:: BuiltinLintDiagnostics ;
25
- use rustc_session:: DiagnosticMessageId ;
26
25
use rustc_span:: hygiene:: ExpnId ;
27
26
use rustc_span:: lev_distance:: find_best_match_for_name;
28
27
use rustc_span:: symbol:: { kw, Ident , Symbol } ;
@@ -456,13 +455,13 @@ impl<'a> Resolver<'a> {
456
455
binding : & ' a NameBinding < ' a > ,
457
456
import : & ' a Import < ' a > ,
458
457
) -> & ' 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 ) ||
460
459
// cf. `PUB_USE_OF_PRIVATE_EXTERN_CRATE`
461
460
!import. is_glob ( ) && binding. is_extern_crate ( )
462
461
{
463
462
import. vis . get ( )
464
463
} else {
465
- binding. pseudo_vis ( )
464
+ binding. vis
466
465
} ;
467
466
468
467
if let ImportKind :: Glob { ref max_vis, .. } = import. kind {
@@ -1178,7 +1177,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
1178
1177
self . r . per_ns ( |this, ns| {
1179
1178
if let Ok ( binding) = source_bindings[ ns] . get ( ) {
1180
1179
let vis = import. vis . get ( ) ;
1181
- if !binding. pseudo_vis ( ) . is_at_least ( vis, & * this) {
1180
+ if !binding. vis . is_at_least ( vis, & * this) {
1182
1181
reexport_error = Some ( ( ns, binding) ) ;
1183
1182
} else {
1184
1183
any_successful_reexport = true ;
@@ -1362,7 +1361,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
1362
1361
Some ( None ) => import. parent_scope . module ,
1363
1362
None => continue ,
1364
1363
} ;
1365
- if self . r . is_accessible_from ( binding. pseudo_vis ( ) , scope) {
1364
+ if self . r . is_accessible_from ( binding. vis , scope) {
1366
1365
let imported_binding = self . r . import ( binding, import) ;
1367
1366
let _ = self . r . try_define ( import. parent_scope . module , key, imported_binding) ;
1368
1367
}
@@ -1380,9 +1379,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
1380
1379
1381
1380
let mut reexports = Vec :: new ( ) ;
1382
1381
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.
1386
1384
// FIXME: Implement actual cross-crate hygiene.
1387
1385
let is_good_import =
1388
1386
binding. is_import ( ) && !binding. is_ambiguity ( ) && !ident. span . from_expansion ( ) ;
@@ -1392,71 +1390,6 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
1392
1390
reexports. push ( Export { ident, res, span : binding. span , vis : binding. vis } ) ;
1393
1391
}
1394
1392
}
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
- }
1460
1393
} ) ;
1461
1394
1462
1395
if !reexports. is_empty ( ) {
0 commit comments