@@ -297,6 +297,7 @@ impl<'a> Resolver<'a> {
297297 binding : binding,
298298 directive : directive,
299299 used : Cell :: new ( false ) ,
300+ legacy_self_import : false ,
300301 } ,
301302 span : directive. span ,
302303 vis : vis,
@@ -594,6 +595,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
594595 } ;
595596
596597 let mut all_ns_err = true ;
598+ let mut legacy_self_import = None ;
597599 self . per_ns ( |this, ns| if !type_ns_only || ns == TypeNS {
598600 if let Ok ( binding) = result[ ns] . get ( ) {
599601 all_ns_err = false ;
@@ -602,9 +604,25 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
602604 Some ( this. dummy_binding ) ;
603605 }
604606 }
607+ } else if let Ok ( binding) = this. resolve_ident_in_module ( module, ident, ns, false , None ) {
608+ legacy_self_import = Some ( directive) ;
609+ let binding = this. arenas . alloc_name_binding ( NameBinding {
610+ kind : NameBindingKind :: Import {
611+ binding : binding,
612+ directive : directive,
613+ used : Cell :: new ( false ) ,
614+ legacy_self_import : true ,
615+ } ,
616+ ..* binding
617+ } ) ;
618+ let _ = this. try_define ( directive. parent , ident, ns, binding) ;
605619 } ) ;
606620
607621 if all_ns_err {
622+ if let Some ( directive) = legacy_self_import {
623+ self . warn_legacy_self_import ( directive) ;
624+ return None ;
625+ }
608626 let mut all_ns_failed = true ;
609627 self . per_ns ( |this, ns| if !type_ns_only || ns == TypeNS {
610628 match this. resolve_ident_in_module ( module, ident, ns, false , Some ( span) ) {
0 commit comments