@@ -643,22 +643,24 @@ impl<'a> Resolver<'a> {
643
643
let not_local_module = crate_name. name != kw:: Crate ;
644
644
let mut worklist =
645
645
vec ! [ ( start_module, Vec :: <ast:: PathSegment >:: new( ) , true , not_local_module) ] ;
646
+ let mut worklist_via_import = vec ! [ ] ;
646
647
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
+ }
648
653
{
649
654
// We have to visit module children in deterministic order to avoid
650
655
// instabilities in reported imports (#43552).
651
656
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
658
658
if !name_binding. is_importable ( ) {
659
659
return ;
660
660
}
661
661
662
+ let via_import = name_binding. is_import ( ) && !name_binding. is_extern_crate ( ) ;
663
+
662
664
let child_accessible =
663
665
accessible && this. is_accessible_from ( name_binding. vis , parent_scope. module ) ;
664
666
@@ -667,6 +669,10 @@ impl<'a> Resolver<'a> {
667
669
return ;
668
670
}
669
671
672
+ if via_import && name_binding. is_possibly_imported_variant ( ) {
673
+ return ;
674
+ }
675
+
670
676
// collect results based on the filter function
671
677
// avoid suggesting anything from the same module in which we are resolving
672
678
if ident. name == lookup_ident. name
@@ -724,7 +730,8 @@ impl<'a> Resolver<'a> {
724
730
let is_extern = in_module_is_extern || name_binding. is_extern_crate ( ) ;
725
731
// add the module to the lookup
726
732
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) ) ;
728
735
}
729
736
}
730
737
}
0 commit comments