@@ -25,7 +25,6 @@ use rustc_span::{Ident, Span, Symbol, kw, sym};
25
25
use smallvec:: SmallVec ;
26
26
use tracing:: debug;
27
27
28
- use crate :: Determinacy :: { self } ;
29
28
use crate :: Namespace :: * ;
30
29
use crate :: diagnostics:: { DiagMode , Suggestion , import_candidates} ;
31
30
use crate :: errors:: {
@@ -34,7 +33,7 @@ use crate::errors::{
34
33
ConsiderAddingMacroExport , ConsiderMarkingAsPub ,
35
34
} ;
36
35
use crate :: {
37
- AmbiguityError , AmbiguityKind , BindingKey , Finalize , ImportSuggestion , Module ,
36
+ AmbiguityError , AmbiguityKind , BindingKey , Determinacy , Finalize , ImportSuggestion , Module ,
38
37
ModuleOrUniformRoot , NameBinding , NameBindingData , NameBindingKind , ParentScope , PathResult ,
39
38
PerNS , ResolutionError , Resolver , ScopeSet , Segment , Used , module_to_string, names_to_string,
40
39
} ;
@@ -568,7 +567,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
568
567
if let ImportKind :: Single { source, ref bindings, .. } = import. kind
569
568
&& source. name == kw:: SelfLower
570
569
// Silence `unresolved import` error if E0429 is already emitted
571
- // `indings` here is "target_bindings", if it is "Err(Determined)" then `source_bindings` as well.
572
570
&& let Progress :: Ready ( None ) = bindings. value_ns . get ( )
573
571
{
574
572
continue ;
@@ -832,29 +830,22 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
832
830
let mut indeterminate_count = 0 ;
833
831
self . per_ns ( |this, ns| {
834
832
if !type_ns_only || ns == TypeNS {
835
- if let Progress :: Pending = bindings[ ns] . get ( ) {
836
- let binding_result = this. maybe_resolve_ident_in_module (
837
- module,
838
- source,
839
- ns,
840
- & import. parent_scope ,
841
- Some ( import) ,
842
- ) ;
843
- let binding = match binding_result {
844
- // We need the `target`, `source` can be extracted.
845
- Ok ( binding) => Poll :: Ready ( Some ( this. import ( binding, import) ) ) ,
846
- Err ( Determinacy :: Determined ) => Poll :: Ready ( None ) ,
847
- Err ( Determinacy :: Undetermined ) => Poll :: Pending ,
848
- } ;
849
- bindings[ ns] . set ( binding) ;
850
- } else {
833
+ let Progress :: Pending = bindings[ ns] . get ( ) else {
851
834
return ;
852
835
} ;
853
-
836
+ let binding_result = this. maybe_resolve_ident_in_module (
837
+ module,
838
+ source,
839
+ ns,
840
+ & import. parent_scope ,
841
+ Some ( import) ,
842
+ ) ;
854
843
let parent = import. parent_scope . module ;
855
- match bindings[ ns] . get ( ) {
856
- Progress :: Ready ( Some ( binding) ) => {
857
- if binding. is_assoc_item ( )
844
+ let binding = match binding_result {
845
+ Ok ( binding) => {
846
+ // We need the `target`, `source` can be extracted.
847
+ let imported_binding = this. import ( binding, import) ;
848
+ if imported_binding. is_assoc_item ( )
858
849
&& !this. tcx . features ( ) . import_trait_associated_functions ( )
859
850
{
860
851
feature_err (
@@ -865,19 +856,25 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
865
856
)
866
857
. emit ( ) ;
867
858
}
868
- this. define ( parent, target, ns, binding) ;
859
+ this. define ( parent, target, ns, imported_binding) ;
860
+ Poll :: Ready ( Some ( imported_binding) )
869
861
}
870
- Progress :: Ready ( None ) => {
862
+ Err ( Determinacy :: Determined ) => {
871
863
// Don't update the resolution for underscores, because it was never added.
872
864
if target. name != kw:: Underscore {
873
865
let key = BindingKey :: new ( target, ns) ;
874
866
this. update_resolution ( parent, key, false , |_, resolution| {
875
867
resolution. single_imports . swap_remove ( & import) ;
876
868
} ) ;
877
869
}
870
+ Poll :: Ready ( None )
878
871
}
879
- Progress :: Pending => indeterminate_count += 1 ,
880
- }
872
+ Err ( Determinacy :: Undetermined ) => {
873
+ indeterminate_count += 1 ;
874
+ Poll :: Pending
875
+ }
876
+ } ;
877
+ bindings[ ns] . set ( binding) ;
881
878
}
882
879
} ) ;
883
880
@@ -1101,7 +1098,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1101
1098
Ok ( binding) => {
1102
1099
// Consistency checks, analogous to `finalize_macro_resolutions`.
1103
1100
let initial_res = bindings[ ns] . get ( ) . map ( |maybe_binding| {
1104
- maybe_binding. and_then ( |binding| binding. maybe_source_binding ( ) ) . map (
1101
+ maybe_binding. map ( |binding| binding. import_source ( ) ) . map (
1105
1102
|initial_binding| {
1106
1103
all_ns_err = false ;
1107
1104
if let Progress :: Ready ( Some ( binding) ) = bindings[ ns] . get ( )
@@ -1272,7 +1269,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1272
1269
let mut crate_private_reexport = false ;
1273
1270
self . per_ns ( |this, ns| {
1274
1271
let binding = match bindings[ ns] . get ( ) {
1275
- Poll :: Ready ( Some ( binding) ) => binding. maybe_source_binding ( ) ,
1272
+ Poll :: Ready ( Some ( binding) ) => Some ( binding. import_source ( ) ) ,
1276
1273
_ => None ,
1277
1274
} ;
1278
1275
let Some ( binding) = binding else {
@@ -1346,7 +1343,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1346
1343
let mut full_path = import. module_path . clone ( ) ;
1347
1344
full_path. push ( Segment :: from_ident ( ident) ) ;
1348
1345
self . per_ns ( |this, ns| {
1349
- if let Progress :: Ready ( Some ( binding) ) = bindings[ ns] . get ( ) {
1346
+ let binding = match bindings[ ns] . get ( ) {
1347
+ Poll :: Ready ( Some ( binding) ) => Some ( binding. import_source ( ) ) ,
1348
+ _ => None ,
1349
+ } ;
1350
+ if let Some ( binding) = binding {
1350
1351
this. lint_if_path_starts_with_module ( Some ( finalize) , & full_path, Some ( binding) ) ;
1351
1352
}
1352
1353
} ) ;
@@ -1357,7 +1358,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1357
1358
// purposes it's good enough to just favor one over the other.
1358
1359
self . per_ns ( |this, ns| {
1359
1360
let binding = match bindings[ ns] . get ( ) {
1360
- Poll :: Ready ( Some ( binding) ) => binding. maybe_source_binding ( ) ,
1361
+ Poll :: Ready ( Some ( binding) ) => Some ( binding. import_source ( ) ) ,
1361
1362
_ => None ,
1362
1363
} ;
1363
1364
if let Some ( binding) = binding {
@@ -1399,7 +1400,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1399
1400
let mut redundant_span = PerNS { value_ns : None , type_ns : None , macro_ns : None } ;
1400
1401
self . per_ns ( |this, ns| {
1401
1402
let binding = match bindings[ ns] . get ( ) {
1402
- Poll :: Ready ( Some ( binding) ) => binding. maybe_source_binding ( ) ,
1403
+ Poll :: Ready ( Some ( binding) ) => Some ( binding. import_source ( ) ) ,
1403
1404
_ => None ,
1404
1405
} ;
1405
1406
if is_redundant && let Some ( binding) = binding {
0 commit comments