@@ -117,6 +117,8 @@ where
117
117
) -> Result < Candidate < I > , NoSolution > {
118
118
Self :: fast_reject_assumption ( ecx, goal, assumption) ?;
119
119
120
+ // Dealing with `ParamEnv` candidates is a bit of a mess as we need to lazily
121
+ // check whether the candidate is global.
120
122
ecx. probe ( |candidate : & Result < Candidate < I > , NoSolution > | match candidate {
121
123
Ok ( candidate) => inspect:: ProbeKind :: TraitCandidate {
122
124
source : candidate. source ,
@@ -128,12 +130,12 @@ where
128
130
} ,
129
131
} )
130
132
. enter ( |ecx| {
131
- Self :: match_assumption ( ecx , goal , assumption ) ? ;
132
- let source = ecx . characterize_param_env_assumption ( goal. param_env , assumption) ? ;
133
- Ok ( Candidate {
134
- source ,
135
- result : ecx . evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes ) ? ,
136
- } )
133
+ let mut source = CandidateSource :: ParamEnv ( ParamEnvSource :: Global ) ;
134
+ let result = Self :: match_assumption ( ecx , goal, assumption, |ecx| {
135
+ source = ecx . characterize_param_env_assumption ( goal . param_env , assumption ) ? ;
136
+ ecx . evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes )
137
+ } ) ? ;
138
+ Ok ( Candidate { source , result } )
137
139
} )
138
140
}
139
141
@@ -150,10 +152,8 @@ where
150
152
) -> Result < Candidate < I > , NoSolution > {
151
153
Self :: fast_reject_assumption ( ecx, goal, assumption) ?;
152
154
153
- ecx. probe_trait_candidate ( source) . enter ( |ecx| {
154
- Self :: match_assumption ( ecx, goal, assumption) ?;
155
- then ( ecx)
156
- } )
155
+ ecx. probe_trait_candidate ( source)
156
+ . enter ( |ecx| Self :: match_assumption ( ecx, goal, assumption, then) )
157
157
}
158
158
159
159
/// Try to reject the assumption based off of simple heuristics, such as [`ty::ClauseKind`]
@@ -169,7 +169,8 @@ where
169
169
ecx : & mut EvalCtxt < ' _ , D > ,
170
170
goal : Goal < I , Self > ,
171
171
assumption : I :: Clause ,
172
- ) -> Result < ( ) , NoSolution > ;
172
+ then : impl FnOnce ( & mut EvalCtxt < ' _ , D > ) -> QueryResult < I > ,
173
+ ) -> QueryResult < I > ;
173
174
174
175
fn consider_impl_candidate (
175
176
ecx : & mut EvalCtxt < ' _ , D > ,
0 commit comments