@@ -482,23 +482,21 @@ enum PathSource<'a> {
482
482
TraitItem ( Namespace ) ,
483
483
// Path in `pub(path)`
484
484
Visibility ,
485
- // Path in `use a::b::{...};`
486
- ImportPrefix ,
487
485
}
488
486
489
487
impl < ' a > PathSource < ' a > {
490
488
fn namespace ( self ) -> Namespace {
491
489
match self {
492
490
PathSource :: Type | PathSource :: Trait ( _) | PathSource :: Struct |
493
- PathSource :: Visibility | PathSource :: ImportPrefix => TypeNS ,
491
+ PathSource :: Visibility => TypeNS ,
494
492
PathSource :: Expr ( ..) | PathSource :: Pat | PathSource :: TupleStruct => ValueNS ,
495
493
PathSource :: TraitItem ( ns) => ns,
496
494
}
497
495
}
498
496
499
497
fn global_by_default ( self ) -> bool {
500
498
match self {
501
- PathSource :: Visibility | PathSource :: ImportPrefix => true ,
499
+ PathSource :: Visibility => true ,
502
500
PathSource :: Type | PathSource :: Expr ( ..) | PathSource :: Pat |
503
501
PathSource :: Struct | PathSource :: TupleStruct |
504
502
PathSource :: Trait ( _) | PathSource :: TraitItem ( ..) => false ,
@@ -510,7 +508,7 @@ impl<'a> PathSource<'a> {
510
508
PathSource :: Type | PathSource :: Expr ( ..) | PathSource :: Pat |
511
509
PathSource :: Struct | PathSource :: TupleStruct => true ,
512
510
PathSource :: Trait ( _) | PathSource :: TraitItem ( ..) |
513
- PathSource :: Visibility | PathSource :: ImportPrefix => false ,
511
+ PathSource :: Visibility => false ,
514
512
}
515
513
}
516
514
@@ -522,7 +520,6 @@ impl<'a> PathSource<'a> {
522
520
PathSource :: Struct => "struct, variant or union type" ,
523
521
PathSource :: TupleStruct => "tuple struct/variant" ,
524
522
PathSource :: Visibility => "module" ,
525
- PathSource :: ImportPrefix => "module or enum" ,
526
523
PathSource :: TraitItem ( ns) => match ns {
527
524
TypeNS => "associated type" ,
528
525
ValueNS => "method or associated constant" ,
@@ -587,10 +584,6 @@ impl<'a> PathSource<'a> {
587
584
Def :: AssociatedTy ( ..) if ns == TypeNS => true ,
588
585
_ => false ,
589
586
} ,
590
- PathSource :: ImportPrefix => match def {
591
- Def :: Mod ( ..) | Def :: Enum ( ..) => true ,
592
- _ => false ,
593
- } ,
594
587
PathSource :: Visibility => match def {
595
588
Def :: Mod ( ..) => true ,
596
589
_ => false ,
@@ -626,8 +619,8 @@ impl<'a> PathSource<'a> {
626
619
( PathSource :: Pat , false ) | ( PathSource :: TupleStruct , false ) => "E0531" ,
627
620
( PathSource :: TraitItem ( ..) , true ) => "E0575" ,
628
621
( PathSource :: TraitItem ( ..) , false ) => "E0576" ,
629
- ( PathSource :: Visibility , true ) | ( PathSource :: ImportPrefix , true ) => "E0577" ,
630
- ( PathSource :: Visibility , false ) | ( PathSource :: ImportPrefix , false ) => "E0578" ,
622
+ ( PathSource :: Visibility , true ) => "E0577" ,
623
+ ( PathSource :: Visibility , false ) => "E0578" ,
631
624
}
632
625
}
633
626
}
@@ -2350,66 +2343,15 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
2350
2343
} ) ;
2351
2344
}
2352
2345
2353
- ItemKind :: Use ( ref use_tree) => {
2354
- // Imports are resolved as global by default, add starting root segment.
2355
- let path = Path {
2356
- segments : use_tree. prefix . make_root ( ) . into_iter ( ) . collect ( ) ,
2357
- span : use_tree. span ,
2358
- } ;
2359
- self . resolve_use_tree ( item. id , use_tree. span , item. id , use_tree, & path) ;
2360
- }
2361
-
2362
- ItemKind :: ExternCrate ( _) | ItemKind :: MacroDef ( ..) | ItemKind :: GlobalAsm ( _) => {
2346
+ ItemKind :: Use ( ..) | ItemKind :: ExternCrate ( ..) |
2347
+ ItemKind :: MacroDef ( ..) | ItemKind :: GlobalAsm ( ..) => {
2363
2348
// do nothing, these are just around to be encoded
2364
2349
}
2365
2350
2366
2351
ItemKind :: Mac ( _) => panic ! ( "unexpanded macro in resolve!" ) ,
2367
2352
}
2368
2353
}
2369
2354
2370
- /// For the most part, use trees are desugared into `ImportDirective` instances
2371
- /// when building the reduced graph (see `build_reduced_graph_for_use_tree`). But
2372
- /// there is one special case we handle here: an empty nested import like
2373
- /// `a::{b::{}}`, which desugares into...no import directives.
2374
- fn resolve_use_tree (
2375
- & mut self ,
2376
- root_id : NodeId ,
2377
- root_span : Span ,
2378
- id : NodeId ,
2379
- use_tree : & ast:: UseTree ,
2380
- prefix : & Path ,
2381
- ) {
2382
- match use_tree. kind {
2383
- ast:: UseTreeKind :: Nested ( ref items) => {
2384
- let path = Path {
2385
- segments : prefix. segments
2386
- . iter ( )
2387
- . chain ( use_tree. prefix . segments . iter ( ) )
2388
- . cloned ( )
2389
- . collect ( ) ,
2390
- span : prefix. span . to ( use_tree. prefix . span ) ,
2391
- } ;
2392
-
2393
- if items. is_empty ( ) {
2394
- // Resolve prefix of an import with empty braces (issue #28388).
2395
- self . smart_resolve_path_with_crate_lint (
2396
- id,
2397
- None ,
2398
- & path,
2399
- PathSource :: ImportPrefix ,
2400
- CrateLint :: UsePath { root_id, root_span } ,
2401
- ) ;
2402
- } else {
2403
- for & ( ref tree, nested_id) in items {
2404
- self . resolve_use_tree ( root_id, root_span, nested_id, tree, & path) ;
2405
- }
2406
- }
2407
- }
2408
- ast:: UseTreeKind :: Simple ( ..) => { } ,
2409
- ast:: UseTreeKind :: Glob => { } ,
2410
- }
2411
- }
2412
-
2413
2355
fn with_type_parameter_rib < ' b , F > ( & ' b mut self , type_parameters : TypeParameters < ' a , ' b > , f : F )
2414
2356
where F : FnOnce ( & mut Resolver )
2415
2357
{
0 commit comments