@@ -41,6 +41,7 @@ pub enum ImportDirectiveSubclass<'a> {
4141 target : Ident ,
4242 source : Ident ,
4343 result : PerNS < Cell < Result < & ' a NameBinding < ' a > , Determinacy > > > ,
44+ type_ns_only : bool ,
4445 } ,
4546 GlobImport {
4647 is_prelude : bool ,
@@ -503,8 +504,9 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
503504 } ;
504505
505506 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) ,
508510 GlobImport { .. } => {
509511 self . resolve_glob_import ( directive) ;
510512 return true ;
@@ -513,7 +515,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
513515 } ;
514516
515517 let mut indeterminate = false ;
516- self . per_ns ( |this, ns| {
518+ self . per_ns ( |this, ns| if !type_ns_only || ns == TypeNS {
517519 if let Err ( Undetermined ) = result[ ns] . get ( ) {
518520 result[ ns] . set ( this. resolve_ident_in_module ( module, source, ns, false , None ) ) ;
519521 } else {
@@ -573,8 +575,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
573575 _ => return None ,
574576 } ;
575577
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 ) ,
578580 GlobImport { .. } if module. def_id ( ) == directive. parent . def_id ( ) => {
579581 // Importing a module into itself is not allowed.
580582 return Some ( "Cannot glob-import a module into itself." . to_string ( ) ) ;
@@ -592,7 +594,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
592594 } ;
593595
594596 let mut all_ns_err = true ;
595- self . per_ns ( |this, ns| {
597+ self . per_ns ( |this, ns| if !type_ns_only || ns == TypeNS {
596598 if let Ok ( binding) = result[ ns] . get ( ) {
597599 all_ns_err = false ;
598600 if this. record_use ( ident, ns, binding, directive. span ) {
@@ -604,7 +606,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
604606
605607 if all_ns_err {
606608 let mut all_ns_failed = true ;
607- self . per_ns ( |this, ns| {
609+ self . per_ns ( |this, ns| if !type_ns_only || ns == TypeNS {
608610 match this. resolve_ident_in_module ( module, ident, ns, false , Some ( span) ) {
609611 Ok ( _) => all_ns_failed = false ,
610612 _ => { }
0 commit comments