@@ -643,22 +643,24 @@ impl<'a> Resolver<'a> {
643643 let not_local_module = crate_name. name != kw:: Crate ;
644644 let mut worklist =
645645 vec ! [ ( start_module, Vec :: <ast:: PathSegment >:: new( ) , true , not_local_module) ] ;
646+ let mut worklist_via_import = vec ! [ ] ;
646647
647- while let Some ( ( in_module, path_segments, accessible, in_module_is_extern) ) = worklist. pop ( )
648+ while let Some ( ( in_module, path_segments, accessible, in_module_is_extern) ) =
649+ match worklist. pop ( ) {
650+ None => worklist_via_import. pop ( ) ,
651+ Some ( x) => Some ( x) ,
652+ }
648653 {
649654 // We have to visit module children in deterministic order to avoid
650655 // instabilities in reported imports (#43552).
651656 in_module. for_each_child ( self , |this, ident, ns, name_binding| {
652- // avoid imports entirely
653- if name_binding. is_import ( ) && !name_binding. is_extern_crate ( ) {
654- return ;
655- }
656-
657- // avoid non-importable candidates as well
657+ // avoid non-importable candidates
658658 if !name_binding. is_importable ( ) {
659659 return ;
660660 }
661661
662+ let via_import = name_binding. is_import ( ) && !name_binding. is_extern_crate ( ) ;
663+
662664 let child_accessible =
663665 accessible && this. is_accessible_from ( name_binding. vis , parent_scope. module ) ;
664666
@@ -667,6 +669,10 @@ impl<'a> Resolver<'a> {
667669 return ;
668670 }
669671
672+ if via_import && name_binding. is_possibly_imported_variant ( ) {
673+ return ;
674+ }
675+
670676 // collect results based on the filter function
671677 // avoid suggesting anything from the same module in which we are resolving
672678 if ident. name == lookup_ident. name
@@ -724,7 +730,8 @@ impl<'a> Resolver<'a> {
724730 let is_extern = in_module_is_extern || name_binding. is_extern_crate ( ) ;
725731 // add the module to the lookup
726732 if seen_modules. insert ( module. def_id ( ) . unwrap ( ) ) {
727- worklist. push ( ( module, path_segments, child_accessible, is_extern) ) ;
733+ if via_import { & mut worklist_via_import } else { & mut worklist }
734+ . push ( ( module, path_segments, child_accessible, is_extern) ) ;
728735 }
729736 }
730737 }
0 commit comments