9
9
// except according to those terms.
10
10
11
11
use super :: MethodError ;
12
- use super :: NoMatchData ;
13
12
use super :: ItemIndex ;
14
- use super :: { CandidateSource , ImplSource , TraitSource } ;
13
+ use super :: { CandidateSource , ImplSource , TraitSource } ;
15
14
use super :: suggest;
16
15
17
16
use check;
@@ -20,7 +19,7 @@ use middle::fast_reject;
20
19
use middle:: subst;
21
20
use middle:: subst:: Subst ;
22
21
use middle:: traits;
23
- use middle:: ty:: { self , RegionEscape , Ty , ToPolyTraitRef , TraitRef } ;
22
+ use middle:: ty:: { self , RegionEscape , Ty , ToPolyTraitRef } ;
24
23
use middle:: ty_fold:: TypeFoldable ;
25
24
use middle:: infer;
26
25
use middle:: infer:: InferCtxt ;
@@ -43,14 +42,7 @@ struct ProbeContext<'a, 'tcx:'a> {
43
42
inherent_candidates : Vec < Candidate < ' tcx > > ,
44
43
extension_candidates : Vec < Candidate < ' tcx > > ,
45
44
impl_dups : HashSet < ast:: DefId > ,
46
-
47
- /// Collects near misses when the candidate functions are missing a `self` keyword and is only
48
- /// used for error reporting
49
45
static_candidates : Vec < CandidateSource > ,
50
-
51
- /// Collects near misses when trait bounds for type parameters are unsatisfied and is only used
52
- /// for error reporting
53
- unsatisfied_predicates : Vec < TraitRef < ' tcx > >
54
46
}
55
47
56
48
#[ derive( Debug ) ]
@@ -112,7 +104,7 @@ pub enum PickKind<'tcx> {
112
104
WhereClausePick ( /* Trait */ ty:: PolyTraitRef < ' tcx > , ItemIndex ) ,
113
105
}
114
106
115
- pub type PickResult < ' tcx > = Result < Pick < ' tcx > , MethodError < ' tcx > > ;
107
+ pub type PickResult < ' tcx > = Result < Pick < ' tcx > , MethodError > ;
116
108
117
109
#[ derive( PartialEq , Eq , Copy , Clone , Debug ) ]
118
110
pub enum Mode {
@@ -149,8 +141,7 @@ pub fn probe<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
149
141
let steps = if mode == Mode :: MethodCall {
150
142
match create_steps ( fcx, span, self_ty) {
151
143
Some ( steps) => steps,
152
- None =>return Err ( MethodError :: NoMatch ( NoMatchData :: new ( Vec :: new ( ) , Vec :: new ( ) ,
153
- Vec :: new ( ) , mode) ) ) ,
144
+ None => return Err ( MethodError :: NoMatch ( Vec :: new ( ) , Vec :: new ( ) , mode) ) ,
154
145
}
155
146
} else {
156
147
vec ! [ CandidateStep {
@@ -251,7 +242,6 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
251
242
steps : Rc :: new ( steps) ,
252
243
opt_simplified_steps : opt_simplified_steps,
253
244
static_candidates : Vec :: new ( ) ,
254
- unsatisfied_predicates : Vec :: new ( ) ,
255
245
}
256
246
}
257
247
@@ -573,7 +563,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
573
563
574
564
fn assemble_extension_candidates_for_traits_in_scope ( & mut self ,
575
565
expr_id : ast:: NodeId )
576
- -> Result < ( ) , MethodError < ' tcx > >
566
+ -> Result < ( ) , MethodError >
577
567
{
578
568
let mut duplicates = HashSet :: new ( ) ;
579
569
let opt_applicable_traits = self . fcx . ccx . trait_map . get ( & expr_id) ;
@@ -587,7 +577,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
587
577
Ok ( ( ) )
588
578
}
589
579
590
- fn assemble_extension_candidates_for_all_traits ( & mut self ) -> Result < ( ) , MethodError < ' tcx > > {
580
+ fn assemble_extension_candidates_for_all_traits ( & mut self ) -> Result < ( ) , MethodError > {
591
581
let mut duplicates = HashSet :: new ( ) ;
592
582
for trait_info in suggest:: all_traits ( self . fcx . ccx ) {
593
583
if duplicates. insert ( trait_info. def_id ) {
@@ -599,7 +589,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
599
589
600
590
fn assemble_extension_candidates_for_trait ( & mut self ,
601
591
trait_def_id : ast:: DefId )
602
- -> Result < ( ) , MethodError < ' tcx > >
592
+ -> Result < ( ) , MethodError >
603
593
{
604
594
debug ! ( "assemble_extension_candidates_for_trait(trait_def_id={:?})" ,
605
595
trait_def_id) ;
@@ -719,7 +709,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
719
709
trait_def_id : ast:: DefId ,
720
710
item : ty:: ImplOrTraitItem < ' tcx > ,
721
711
item_index : usize )
722
- -> Result < ( ) , MethodError < ' tcx > >
712
+ -> Result < ( ) , MethodError >
723
713
{
724
714
// Check if this is one of the Fn,FnMut,FnOnce traits.
725
715
let tcx = self . tcx ( ) ;
@@ -878,7 +868,6 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
878
868
}
879
869
880
870
let static_candidates = mem:: replace ( & mut self . static_candidates , vec ! [ ] ) ;
881
- let unsatisfied_predicates = mem:: replace ( & mut self . unsatisfied_predicates , vec ! [ ] ) ;
882
871
883
872
// things failed, so lets look at all traits, for diagnostic purposes now:
884
873
self . reset ( ) ;
@@ -903,7 +892,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
903
892
}
904
893
}
905
894
} ) . collect ( ) ,
906
- Some ( Err ( MethodError :: NoMatch ( NoMatchData { out_of_scope_traits : others, .. } ) ) ) => {
895
+ Some ( Err ( MethodError :: NoMatch ( _ , others, _ ) ) ) => {
907
896
assert ! ( others. is_empty( ) ) ;
908
897
vec ! [ ]
909
898
}
@@ -914,8 +903,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
914
903
None => vec ! [ ] ,
915
904
} ;
916
905
917
- Err ( MethodError :: NoMatch ( NoMatchData :: new ( static_candidates, unsatisfied_predicates,
918
- out_of_scope_traits, self . mode ) ) )
906
+ Err ( MethodError :: NoMatch ( static_candidates, out_of_scope_traits, self . mode ) )
919
907
}
920
908
921
909
fn pick_core ( & mut self ) -> Option < PickResult < ' tcx > > {
@@ -1003,35 +991,25 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
1003
991
fn pick_method ( & mut self , self_ty : Ty < ' tcx > ) -> Option < PickResult < ' tcx > > {
1004
992
debug ! ( "pick_method(self_ty={})" , self . infcx( ) . ty_to_string( self_ty) ) ;
1005
993
1006
- let mut possibly_unsatisfied_predicates = Vec :: new ( ) ;
1007
-
1008
994
debug ! ( "searching inherent candidates" ) ;
1009
- match self . consider_candidates ( self_ty, & self . inherent_candidates ,
1010
- & mut possibly_unsatisfied_predicates) {
995
+ match self . consider_candidates ( self_ty, & self . inherent_candidates ) {
1011
996
None => { }
1012
997
Some ( pick) => {
1013
998
return Some ( pick) ;
1014
999
}
1015
1000
}
1016
1001
1017
1002
debug ! ( "searching extension candidates" ) ;
1018
- let res = self . consider_candidates ( self_ty, & self . extension_candidates ,
1019
- & mut possibly_unsatisfied_predicates) ;
1020
- if let None = res {
1021
- self . unsatisfied_predicates . extend ( possibly_unsatisfied_predicates) ;
1022
- }
1023
- res
1003
+ self . consider_candidates ( self_ty, & self . extension_candidates )
1024
1004
}
1025
1005
1026
1006
fn consider_candidates ( & self ,
1027
1007
self_ty : Ty < ' tcx > ,
1028
- probes : & [ Candidate < ' tcx > ] ,
1029
- possibly_unsatisfied_predicates : & mut Vec < TraitRef < ' tcx > > )
1008
+ probes : & [ Candidate < ' tcx > ] )
1030
1009
-> Option < PickResult < ' tcx > > {
1031
1010
let mut applicable_candidates: Vec < _ > =
1032
1011
probes. iter ( )
1033
- . filter ( |& probe| self . consider_probe ( self_ty,
1034
- probe, possibly_unsatisfied_predicates) )
1012
+ . filter ( |& probe| self . consider_probe ( self_ty, probe) )
1035
1013
. collect ( ) ;
1036
1014
1037
1015
debug ! ( "applicable_candidates: {:?}" , applicable_candidates) ;
@@ -1054,8 +1032,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
1054
1032
} )
1055
1033
}
1056
1034
1057
- fn consider_probe ( & self , self_ty : Ty < ' tcx > , probe : & Candidate < ' tcx > ,
1058
- possibly_unsatisfied_predicates : & mut Vec < TraitRef < ' tcx > > ) -> bool {
1035
+ fn consider_probe ( & self , self_ty : Ty < ' tcx > , probe : & Candidate < ' tcx > ) -> bool {
1059
1036
debug ! ( "consider_probe: self_ty={:?} probe={:?}" ,
1060
1037
self_ty,
1061
1038
probe) ;
@@ -1094,18 +1071,10 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
1094
1071
debug ! ( "impl_obligations={:?}" , obligations) ;
1095
1072
1096
1073
// Evaluate those obligations to see if they might possibly hold.
1097
- let mut all_true = true ;
1098
- for o in obligations. iter ( )
1099
- . chain ( norm_obligations. iter ( ) )
1100
- . chain ( ref_obligations. iter ( ) ) {
1101
- if !selcx. evaluate_obligation ( o) {
1102
- all_true = false ;
1103
- if let & ty:: Predicate :: Trait ( ref pred) = & o. predicate {
1104
- possibly_unsatisfied_predicates. push ( pred. 0 . trait_ref ) ;
1105
- }
1106
- }
1107
- }
1108
- all_true
1074
+ obligations. iter ( )
1075
+ . chain ( norm_obligations. iter ( ) ) . chain ( ref_obligations. iter ( ) )
1076
+ . all ( |o| selcx. evaluate_obligation ( o) )
1077
+
1109
1078
}
1110
1079
1111
1080
ProjectionCandidate ( ..) |
0 commit comments