@@ -41,6 +41,7 @@ pub enum ImportDirectiveSubclass<'a> {
41
41
target : Ident ,
42
42
source : Ident ,
43
43
result : PerNS < Cell < Result < & ' a NameBinding < ' a > , Determinacy > > > ,
44
+ type_ns_only : bool ,
44
45
} ,
45
46
GlobImport {
46
47
is_prelude : bool ,
@@ -503,8 +504,9 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
503
504
} ;
504
505
505
506
directive. imported_module . set ( Some ( module) ) ;
506
- let ( source, target, result) = match directive. subclass {
507
- SingleImport { source, target, ref result } => ( source, target, result) ,
507
+ let ( source, target, result, type_ns_only) = match directive. subclass {
508
+ SingleImport { source, target, ref result, type_ns_only } =>
509
+ ( source, target, result, type_ns_only) ,
508
510
GlobImport { .. } => {
509
511
self . resolve_glob_import ( directive) ;
510
512
return true ;
@@ -513,7 +515,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
513
515
} ;
514
516
515
517
let mut indeterminate = false ;
516
- self . per_ns ( |this, ns| {
518
+ self . per_ns ( |this, ns| if !type_ns_only || ns == TypeNS {
517
519
if let Err ( Undetermined ) = result[ ns] . get ( ) {
518
520
result[ ns] . set ( this. resolve_ident_in_module ( module, source, ns, false , None ) ) ;
519
521
} else {
@@ -573,8 +575,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
573
575
_ => return None ,
574
576
} ;
575
577
576
- let ( ident, result) = match directive. subclass {
577
- SingleImport { source, ref result, .. } => ( source, result) ,
578
+ let ( ident, result, type_ns_only ) = match directive. subclass {
579
+ SingleImport { source, ref result, type_ns_only , .. } => ( source, result, type_ns_only ) ,
578
580
GlobImport { .. } if module. def_id ( ) == directive. parent . def_id ( ) => {
579
581
// Importing a module into itself is not allowed.
580
582
return Some ( "Cannot glob-import a module into itself." . to_string ( ) ) ;
@@ -592,7 +594,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
592
594
} ;
593
595
594
596
let mut all_ns_err = true ;
595
- self . per_ns ( |this, ns| {
597
+ self . per_ns ( |this, ns| if !type_ns_only || ns == TypeNS {
596
598
if let Ok ( binding) = result[ ns] . get ( ) {
597
599
all_ns_err = false ;
598
600
if this. record_use ( ident, ns, binding, directive. span ) {
@@ -604,7 +606,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
604
606
605
607
if all_ns_err {
606
608
let mut all_ns_failed = true ;
607
- self . per_ns ( |this, ns| {
609
+ self . per_ns ( |this, ns| if !type_ns_only || ns == TypeNS {
608
610
match this. resolve_ident_in_module ( module, ident, ns, false , Some ( span) ) {
609
611
Ok ( _) => all_ns_failed = false ,
610
612
_ => { }
0 commit comments