@@ -17,7 +17,7 @@ use rustc::hir::{self, PrimTy, Bool, Char, Float, Int, Uint, Str};
1717use rustc:: middle:: cstore:: CrateStore ;
1818use rustc:: session:: Session ;
1919use rustc:: lint;
20- use rustc:: hir:: def:: { self , DefKind , PartialRes , CtorOf , NonMacroAttrKind , ExportMap } ;
20+ use rustc:: hir:: def:: { self , DefKind , PartialRes , CtorKind , CtorOf , NonMacroAttrKind , ExportMap } ;
2121use rustc:: hir:: def:: Namespace :: * ;
2222use rustc:: hir:: def_id:: { CRATE_DEF_INDEX , LOCAL_CRATE , DefId } ;
2323use rustc:: hir:: { TraitMap , GlobMap } ;
@@ -37,7 +37,7 @@ use syntax::visit::{self, Visitor};
3737use syntax:: attr;
3838use syntax:: ast:: { CRATE_NODE_ID , Crate } ;
3939use syntax:: ast:: { ItemKind , Path } ;
40- use syntax:: { span_err , struct_span_err, unwrap_or} ;
40+ use syntax:: { struct_span_err, unwrap_or} ;
4141
4242use syntax_pos:: { Span , DUMMY_SP } ;
4343use errors:: { Applicability , DiagnosticBuilder } ;
@@ -110,10 +110,12 @@ enum Scope<'a> {
110110/// This enum is currently used only for early resolution (imports and macros),
111111/// but not for late resolution yet.
112112enum ScopeSet {
113- Import ( Namespace ) ,
113+ /// All scopes with the given namespace.
114+ All ( Namespace , /*is_import*/ bool ) ,
115+ /// Crate root, then extern prelude (used for mixed 2015-2018 mode in macros).
114116 AbsolutePath ( Namespace ) ,
117+ /// All scopes with macro namespace and the given macro kind restriction.
115118 Macro ( MacroKind ) ,
116- Module ,
117119}
118120
119121/// Everything you need to know about a name's location to resolve it.
@@ -1330,10 +1332,9 @@ impl<'a> Resolver<'a> {
13301332
13311333 let rust_2015 = ident. span . rust_2015 ( ) ;
13321334 let ( ns, is_absolute_path) = match scope_set {
1333- ScopeSet :: Import ( ns) => ( ns, false ) ,
1335+ ScopeSet :: All ( ns, _ ) => ( ns, false ) ,
13341336 ScopeSet :: AbsolutePath ( ns) => ( ns, true ) ,
13351337 ScopeSet :: Macro ( _) => ( MacroNS , false ) ,
1336- ScopeSet :: Module => ( TypeNS , false ) ,
13371338 } ;
13381339 let mut scope = match ns {
13391340 _ if is_absolute_path => Scope :: CrateRoot ,
@@ -1858,9 +1859,7 @@ impl<'a> Resolver<'a> {
18581859 module, ident, ns, parent_scope, record_used, path_span
18591860 )
18601861 } else if ribs. is_none ( ) || opt_ns. is_none ( ) || opt_ns == Some ( MacroNS ) {
1861- // FIXME: Decouple the import property from `ScopeSet`.
1862- let is_import = opt_ns. is_none ( ) || ns != TypeNS ;
1863- let scopes = if is_import { ScopeSet :: Import ( ns) } else { ScopeSet :: Module } ;
1862+ let scopes = ScopeSet :: All ( ns, opt_ns. is_none ( ) ) ;
18641863 self . early_resolve_ident_in_lexical_scope ( ident, scopes, parent_scope, record_used,
18651864 record_used, path_span)
18661865 } else {
0 commit comments