@@ -17,7 +17,7 @@ use rustc::hir::{self, PrimTy, Bool, Char, Float, Int, Uint, Str};
17
17
use rustc:: middle:: cstore:: CrateStore ;
18
18
use rustc:: session:: Session ;
19
19
use 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 } ;
21
21
use rustc:: hir:: def:: Namespace :: * ;
22
22
use rustc:: hir:: def_id:: { CRATE_DEF_INDEX , LOCAL_CRATE , DefId } ;
23
23
use rustc:: hir:: { TraitMap , GlobMap } ;
@@ -37,7 +37,7 @@ use syntax::visit::{self, Visitor};
37
37
use syntax:: attr;
38
38
use syntax:: ast:: { CRATE_NODE_ID , Crate } ;
39
39
use syntax:: ast:: { ItemKind , Path } ;
40
- use syntax:: { span_err , struct_span_err, unwrap_or} ;
40
+ use syntax:: { struct_span_err, unwrap_or} ;
41
41
42
42
use syntax_pos:: { Span , DUMMY_SP } ;
43
43
use errors:: { Applicability , DiagnosticBuilder } ;
@@ -110,10 +110,12 @@ enum Scope<'a> {
110
110
/// This enum is currently used only for early resolution (imports and macros),
111
111
/// but not for late resolution yet.
112
112
enum 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).
114
116
AbsolutePath ( Namespace ) ,
117
+ /// All scopes with macro namespace and the given macro kind restriction.
115
118
Macro ( MacroKind ) ,
116
- Module ,
117
119
}
118
120
119
121
/// Everything you need to know about a name's location to resolve it.
@@ -1330,10 +1332,9 @@ impl<'a> Resolver<'a> {
1330
1332
1331
1333
let rust_2015 = ident. span . rust_2015 ( ) ;
1332
1334
let ( ns, is_absolute_path) = match scope_set {
1333
- ScopeSet :: Import ( ns) => ( ns, false ) ,
1335
+ ScopeSet :: All ( ns, _ ) => ( ns, false ) ,
1334
1336
ScopeSet :: AbsolutePath ( ns) => ( ns, true ) ,
1335
1337
ScopeSet :: Macro ( _) => ( MacroNS , false ) ,
1336
- ScopeSet :: Module => ( TypeNS , false ) ,
1337
1338
} ;
1338
1339
let mut scope = match ns {
1339
1340
_ if is_absolute_path => Scope :: CrateRoot ,
@@ -1858,9 +1859,7 @@ impl<'a> Resolver<'a> {
1858
1859
module, ident, ns, parent_scope, record_used, path_span
1859
1860
)
1860
1861
} 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 ( ) ) ;
1864
1863
self . early_resolve_ident_in_lexical_scope ( ident, scopes, parent_scope, record_used,
1865
1864
record_used, path_span)
1866
1865
} else {
0 commit comments