@@ -482,23 +482,21 @@ enum PathSource<'a> {
482482 TraitItem ( Namespace ) ,
483483 // Path in `pub(path)`
484484 Visibility ,
485- // Path in `use a::b::{...};`
486- ImportPrefix ,
487485}
488486
489487impl < ' a > PathSource < ' a > {
490488 fn namespace ( self ) -> Namespace {
491489 match self {
492490 PathSource :: Type | PathSource :: Trait ( _) | PathSource :: Struct |
493- PathSource :: Visibility | PathSource :: ImportPrefix => TypeNS ,
491+ PathSource :: Visibility => TypeNS ,
494492 PathSource :: Expr ( ..) | PathSource :: Pat | PathSource :: TupleStruct => ValueNS ,
495493 PathSource :: TraitItem ( ns) => ns,
496494 }
497495 }
498496
499497 fn global_by_default ( self ) -> bool {
500498 match self {
501- PathSource :: Visibility | PathSource :: ImportPrefix => true ,
499+ PathSource :: Visibility => true ,
502500 PathSource :: Type | PathSource :: Expr ( ..) | PathSource :: Pat |
503501 PathSource :: Struct | PathSource :: TupleStruct |
504502 PathSource :: Trait ( _) | PathSource :: TraitItem ( ..) => false ,
@@ -510,7 +508,7 @@ impl<'a> PathSource<'a> {
510508 PathSource :: Type | PathSource :: Expr ( ..) | PathSource :: Pat |
511509 PathSource :: Struct | PathSource :: TupleStruct => true ,
512510 PathSource :: Trait ( _) | PathSource :: TraitItem ( ..) |
513- PathSource :: Visibility | PathSource :: ImportPrefix => false ,
511+ PathSource :: Visibility => false ,
514512 }
515513 }
516514
@@ -522,7 +520,6 @@ impl<'a> PathSource<'a> {
522520 PathSource :: Struct => "struct, variant or union type" ,
523521 PathSource :: TupleStruct => "tuple struct/variant" ,
524522 PathSource :: Visibility => "module" ,
525- PathSource :: ImportPrefix => "module or enum" ,
526523 PathSource :: TraitItem ( ns) => match ns {
527524 TypeNS => "associated type" ,
528525 ValueNS => "method or associated constant" ,
@@ -587,10 +584,6 @@ impl<'a> PathSource<'a> {
587584 Def :: AssociatedTy ( ..) if ns == TypeNS => true ,
588585 _ => false ,
589586 } ,
590- PathSource :: ImportPrefix => match def {
591- Def :: Mod ( ..) | Def :: Enum ( ..) => true ,
592- _ => false ,
593- } ,
594587 PathSource :: Visibility => match def {
595588 Def :: Mod ( ..) => true ,
596589 _ => false ,
@@ -626,8 +619,8 @@ impl<'a> PathSource<'a> {
626619 ( PathSource :: Pat , false ) | ( PathSource :: TupleStruct , false ) => "E0531" ,
627620 ( PathSource :: TraitItem ( ..) , true ) => "E0575" ,
628621 ( 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" ,
631624 }
632625 }
633626}
@@ -2350,66 +2343,15 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
23502343 } ) ;
23512344 }
23522345
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 ( ..) => {
23632348 // do nothing, these are just around to be encoded
23642349 }
23652350
23662351 ItemKind :: Mac ( _) => panic ! ( "unexpanded macro in resolve!" ) ,
23672352 }
23682353 }
23692354
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-
24132355 fn with_type_parameter_rib < ' b , F > ( & ' b mut self , type_parameters : TypeParameters < ' a , ' b > , f : F )
24142356 where F : FnOnce ( & mut Resolver )
24152357 {
0 commit comments