@@ -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}
@@ -2298,66 +2291,15 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
22982291 } ) ;
22992292 }
23002293
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 ( ..) => {
23112296 // do nothing, these are just around to be encoded
23122297 }
23132298
23142299 ItemKind :: Mac ( _) => panic ! ( "unexpanded macro in resolve!" ) ,
23152300 }
23162301 }
23172302
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-
23612303 fn with_type_parameter_rib < ' b , F > ( & ' b mut self , type_parameters : TypeParameters < ' a , ' b > , f : F )
23622304 where F : FnOnce ( & mut Resolver )
23632305 {
0 commit comments