@@ -41,46 +41,51 @@ impl<'tcx> InferCtxtSelectExt<'tcx> for InferCtxt<'tcx> {
41
41
self . instantiate_binder_with_placeholders ( obligation. predicate ) ,
42
42
) ;
43
43
44
- let ( result, _) = EvalCtxt :: enter_root ( self , GenerateProofTree :: Never , |ecx| {
45
- let goal = Goal :: new ( ecx. tcx ( ) , trait_goal. param_env , trait_goal. predicate ) ;
46
- let ( orig_values, canonical_goal) = ecx. canonicalize_goal ( goal) ;
47
- let mut candidates = ecx. compute_canonical_trait_candidates ( canonical_goal) ;
48
-
49
- // pseudo-winnow
50
- if candidates. len ( ) == 0 {
51
- return Err ( SelectionError :: Unimplemented ) ;
52
- } else if candidates. len ( ) > 1 {
53
- let mut i = 0 ;
54
- while i < candidates. len ( ) {
55
- let should_drop_i = ( 0 ..candidates. len ( ) ) . filter ( |& j| i != j) . any ( |j| {
56
- candidate_should_be_dropped_in_favor_of (
57
- ecx. tcx ( ) ,
58
- & candidates[ i] ,
59
- & candidates[ j] ,
60
- )
61
- } ) ;
62
- if should_drop_i {
63
- candidates. swap_remove ( i) ;
64
- } else {
65
- i += 1 ;
66
- if i > 1 {
67
- return Ok ( None ) ;
44
+ let ( result, _) = EvalCtxt :: enter_root (
45
+ self ,
46
+ GenerateProofTree :: Never ,
47
+ || unreachable ! ( "proof trees cannot be generated for selection" ) ,
48
+ |ecx| {
49
+ let goal = Goal :: new ( ecx. tcx ( ) , trait_goal. param_env , trait_goal. predicate ) ;
50
+ let ( orig_values, canonical_goal) = ecx. canonicalize_goal ( goal) ;
51
+ let mut candidates = ecx. compute_canonical_trait_candidates ( canonical_goal) ;
52
+
53
+ // pseudo-winnow
54
+ if candidates. len ( ) == 0 {
55
+ return Err ( SelectionError :: Unimplemented ) ;
56
+ } else if candidates. len ( ) > 1 {
57
+ let mut i = 0 ;
58
+ while i < candidates. len ( ) {
59
+ let should_drop_i = ( 0 ..candidates. len ( ) ) . filter ( |& j| i != j) . any ( |j| {
60
+ candidate_should_be_dropped_in_favor_of (
61
+ ecx. tcx ( ) ,
62
+ & candidates[ i] ,
63
+ & candidates[ j] ,
64
+ )
65
+ } ) ;
66
+ if should_drop_i {
67
+ candidates. swap_remove ( i) ;
68
+ } else {
69
+ i += 1 ;
70
+ if i > 1 {
71
+ return Ok ( None ) ;
72
+ }
68
73
}
69
74
}
70
75
}
71
- }
72
76
73
- let candidate = candidates. pop ( ) . unwrap ( ) ;
74
- let ( certainty, nested_goals) = ecx
75
- . instantiate_and_apply_query_response (
76
- trait_goal. param_env ,
77
- orig_values,
78
- candidate. result ,
79
- )
80
- . map_err ( |_| SelectionError :: Unimplemented ) ?;
77
+ let candidate = candidates. pop ( ) . unwrap ( ) ;
78
+ let ( certainty, nested_goals) = ecx
79
+ . instantiate_and_apply_query_response (
80
+ trait_goal. param_env ,
81
+ orig_values,
82
+ candidate. result ,
83
+ )
84
+ . map_err ( |_| SelectionError :: Unimplemented ) ?;
81
85
82
- Ok ( Some ( ( candidate, certainty, nested_goals) ) )
83
- } ) ;
86
+ Ok ( Some ( ( candidate, certainty, nested_goals) ) )
87
+ } ,
88
+ ) ;
84
89
85
90
let ( candidate, certainty, nested_goals) = match result {
86
91
Ok ( Some ( ( candidate, certainty, nested_goals) ) ) => ( candidate, certainty, nested_goals) ,
0 commit comments