@@ -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
}
@@ -2298,66 +2291,15 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
2298
2291
} ) ;
2299
2292
}
2300
2293
2301
- ItemKind :: Use ( ref use_tree) => {
2302
- // Imports are resolved as global by default, add starting root segment.
2303
- let path = Path {
2304
- segments : use_tree. prefix . make_root ( ) . into_iter ( ) . collect ( ) ,
2305
- span : use_tree. span ,
2306
- } ;
2307
- self . resolve_use_tree ( item. id , use_tree. span , item. id , use_tree, & path) ;
2308
- }
2309
-
2310
- ItemKind :: ExternCrate ( _) | ItemKind :: MacroDef ( ..) | ItemKind :: GlobalAsm ( _) => {
2294
+ ItemKind :: Use ( ..) | ItemKind :: ExternCrate ( ..) |
2295
+ ItemKind :: MacroDef ( ..) | ItemKind :: GlobalAsm ( ..) => {
2311
2296
// do nothing, these are just around to be encoded
2312
2297
}
2313
2298
2314
2299
ItemKind :: Mac ( _) => panic ! ( "unexpanded macro in resolve!" ) ,
2315
2300
}
2316
2301
}
2317
2302
2318
- /// For the most part, use trees are desugared into `ImportDirective` instances
2319
- /// when building the reduced graph (see `build_reduced_graph_for_use_tree`). But
2320
- /// there is one special case we handle here: an empty nested import like
2321
- /// `a::{b::{}}`, which desugares into...no import directives.
2322
- fn resolve_use_tree (
2323
- & mut self ,
2324
- root_id : NodeId ,
2325
- root_span : Span ,
2326
- id : NodeId ,
2327
- use_tree : & ast:: UseTree ,
2328
- prefix : & Path ,
2329
- ) {
2330
- match use_tree. kind {
2331
- ast:: UseTreeKind :: Nested ( ref items) => {
2332
- let path = Path {
2333
- segments : prefix. segments
2334
- . iter ( )
2335
- . chain ( use_tree. prefix . segments . iter ( ) )
2336
- . cloned ( )
2337
- . collect ( ) ,
2338
- span : prefix. span . to ( use_tree. prefix . span ) ,
2339
- } ;
2340
-
2341
- if items. is_empty ( ) {
2342
- // Resolve prefix of an import with empty braces (issue #28388).
2343
- self . smart_resolve_path_with_crate_lint (
2344
- id,
2345
- None ,
2346
- & path,
2347
- PathSource :: ImportPrefix ,
2348
- CrateLint :: UsePath { root_id, root_span } ,
2349
- ) ;
2350
- } else {
2351
- for & ( ref tree, nested_id) in items {
2352
- self . resolve_use_tree ( root_id, root_span, nested_id, tree, & path) ;
2353
- }
2354
- }
2355
- }
2356
- ast:: UseTreeKind :: Simple ( ..) => { } ,
2357
- ast:: UseTreeKind :: Glob => { } ,
2358
- }
2359
- }
2360
-
2361
2303
fn with_type_parameter_rib < ' b , F > ( & ' b mut self , type_parameters : TypeParameters < ' a , ' b > , f : F )
2362
2304
where F : FnOnce ( & mut Resolver )
2363
2305
{
0 commit comments