@@ -55,7 +55,6 @@ struct ProbeContext<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
55
55
inherent_candidates : Vec < Candidate < ' tcx > > ,
56
56
extension_candidates : Vec < Candidate < ' tcx > > ,
57
57
impl_dups : FxHashSet < DefId > ,
58
- import_id : Option < ast:: NodeId > ,
59
58
60
59
/// Collects near misses when the candidate functions are missing a `self` keyword and is only
61
60
/// used for error reporting
@@ -351,7 +350,6 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
351
350
inherent_candidates : Vec :: new ( ) ,
352
351
extension_candidates : Vec :: new ( ) ,
353
352
impl_dups : FxHashSet ( ) ,
354
- import_id : None ,
355
353
steps : Rc :: new ( steps) ,
356
354
opt_simplified_steps : opt_simplified_steps,
357
355
static_candidates : Vec :: new ( ) ,
@@ -530,7 +528,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
530
528
xform_self_ty : xform_self_ty,
531
529
item : item,
532
530
kind : InherentImplCandidate ( impl_substs, obligations) ,
533
- import_id : self . import_id ,
531
+ import_id : None ,
534
532
} ) ;
535
533
}
536
534
}
@@ -559,7 +557,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
559
557
xform_self_ty : xform_self_ty,
560
558
item : item,
561
559
kind : ObjectCandidate ,
562
- import_id : this . import_id ,
560
+ import_id : None ,
563
561
} ) ;
564
562
} ) ;
565
563
}
@@ -609,7 +607,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
609
607
xform_self_ty : xform_self_ty,
610
608
item : item,
611
609
kind : WhereClauseCandidate ( poly_trait_ref) ,
612
- import_id : this . import_id ,
610
+ import_id : None ,
613
611
} ) ;
614
612
} ) ;
615
613
}
@@ -644,9 +642,8 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
644
642
for trait_candidate in applicable_traits {
645
643
let trait_did = trait_candidate. def_id ;
646
644
if duplicates. insert ( trait_did) {
647
- self . import_id = trait_candidate. import_id ;
648
- let result = self . assemble_extension_candidates_for_trait ( trait_did) ;
649
- self . import_id = None ;
645
+ let import_id = trait_candidate. import_id ;
646
+ let result = self . assemble_extension_candidates_for_trait ( import_id, trait_did) ;
650
647
result?;
651
648
}
652
649
}
@@ -658,7 +655,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
658
655
let mut duplicates = FxHashSet ( ) ;
659
656
for trait_info in suggest:: all_traits ( self . ccx ) {
660
657
if duplicates. insert ( trait_info. def_id ) {
661
- self . assemble_extension_candidates_for_trait ( trait_info. def_id ) ?;
658
+ self . assemble_extension_candidates_for_trait ( None , trait_info. def_id ) ?;
662
659
}
663
660
}
664
661
Ok ( ( ) )
@@ -682,6 +679,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
682
679
}
683
680
684
681
fn assemble_extension_candidates_for_trait ( & mut self ,
682
+ import_id : Option < ast:: NodeId > ,
685
683
trait_def_id : DefId )
686
684
-> Result < ( ) , MethodError < ' tcx > > {
687
685
debug ! ( "assemble_extension_candidates_for_trait(trait_def_id={:?})" ,
@@ -695,19 +693,21 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
695
693
continue ;
696
694
}
697
695
698
- self . assemble_extension_candidates_for_trait_impls ( trait_def_id, item. clone ( ) ) ;
696
+ self . assemble_extension_candidates_for_trait_impls ( import_id, trait_def_id,
697
+ item. clone ( ) ) ;
699
698
700
- self . assemble_closure_candidates ( trait_def_id, item. clone ( ) ) ?;
699
+ self . assemble_closure_candidates ( import_id , trait_def_id, item. clone ( ) ) ?;
701
700
702
- self . assemble_projection_candidates ( trait_def_id, item. clone ( ) ) ;
701
+ self . assemble_projection_candidates ( import_id , trait_def_id, item. clone ( ) ) ;
703
702
704
- self . assemble_where_clause_candidates ( trait_def_id, item. clone ( ) ) ;
703
+ self . assemble_where_clause_candidates ( import_id , trait_def_id, item. clone ( ) ) ;
705
704
}
706
705
707
706
Ok ( ( ) )
708
707
}
709
708
710
709
fn assemble_extension_candidates_for_trait_impls ( & mut self ,
710
+ import_id : Option < ast:: NodeId > ,
711
711
trait_def_id : DefId ,
712
712
item : ty:: AssociatedItem ) {
713
713
let trait_def = self . tcx . lookup_trait_def ( trait_def_id) ;
@@ -751,7 +751,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
751
751
xform_self_ty : xform_self_ty,
752
752
item : item. clone ( ) ,
753
753
kind : ExtensionImplCandidate ( impl_def_id, impl_substs, obligations) ,
754
- import_id : self . import_id ,
754
+ import_id : import_id,
755
755
} ) ;
756
756
} ) ;
757
757
}
@@ -777,6 +777,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
777
777
}
778
778
779
779
fn assemble_closure_candidates ( & mut self ,
780
+ import_id : Option < ast:: NodeId > ,
780
781
trait_def_id : DefId ,
781
782
item : ty:: AssociatedItem )
782
783
-> Result < ( ) , MethodError < ' tcx > > {
@@ -840,14 +841,15 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
840
841
xform_self_ty : xform_self_ty,
841
842
item : item. clone ( ) ,
842
843
kind : TraitCandidate ,
843
- import_id : self . import_id ,
844
+ import_id : import_id,
844
845
} ) ;
845
846
}
846
847
847
848
Ok ( ( ) )
848
849
}
849
850
850
851
fn assemble_projection_candidates ( & mut self ,
852
+ import_id : Option < ast:: NodeId > ,
851
853
trait_def_id : DefId ,
852
854
item : ty:: AssociatedItem ) {
853
855
debug ! ( "assemble_projection_candidates(\
@@ -895,14 +897,15 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
895
897
xform_self_ty : xform_self_ty,
896
898
item : item. clone ( ) ,
897
899
kind : TraitCandidate ,
898
- import_id : self . import_id ,
900
+ import_id : import_id,
899
901
} ) ;
900
902
}
901
903
}
902
904
}
903
905
}
904
906
905
907
fn assemble_where_clause_candidates ( & mut self ,
908
+ import_id : Option < ast:: NodeId > ,
906
909
trait_def_id : DefId ,
907
910
item : ty:: AssociatedItem ) {
908
911
debug ! ( "assemble_where_clause_candidates(trait_def_id={:?})" ,
@@ -923,7 +926,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
923
926
xform_self_ty : xform_self_ty,
924
927
item : item. clone ( ) ,
925
928
kind : WhereClauseCandidate ( poly_bound) ,
926
- import_id : self . import_id ,
929
+ import_id : import_id,
927
930
} ) ;
928
931
}
929
932
}
0 commit comments