@@ -50,7 +50,7 @@ pub struct InspectGoal<'a, 'tcx> {
50
50
/// not something we want to leak to users. We therefore
51
51
/// treat `NormalizesTo` goals as if they apply the expected
52
52
/// type at the end of each candidate.
53
- #[ derive( Copy , Clone ) ]
53
+ #[ derive( Copy , Clone , Debug ) ]
54
54
struct NormalizesToTermHack < ' tcx > {
55
55
term : ty:: Term < ' tcx > ,
56
56
unconstrained_term : ty:: Term < ' tcx > ,
@@ -197,6 +197,50 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
197
197
( goals, opt_impl_args)
198
198
}
199
199
200
+ /// Instantiate the args of an impl if this candidate came from a
201
+ /// `CandidateSource::Impl`. This function modifies the state of the
202
+ /// `infcx`.
203
+ #[ instrument(
204
+ level = "debug" ,
205
+ skip_all,
206
+ fields( goal = ?self . goal. goal, steps = ?self . steps)
207
+ ) ]
208
+ pub fn instantiate_opt_impl_args ( & self , span : Span ) -> Option < ty:: GenericArgsRef < ' tcx > > {
209
+ let infcx = self . goal . infcx ;
210
+ let param_env = self . goal . goal . param_env ;
211
+ let mut orig_values = self . goal . orig_values . to_vec ( ) ;
212
+
213
+ let mut opt_impl_args = None ;
214
+ for step in & self . steps {
215
+ match * * step {
216
+ inspect:: ProbeStep :: RecordImplArgs { impl_args } => {
217
+ opt_impl_args = Some ( instantiate_canonical_state (
218
+ infcx,
219
+ span,
220
+ param_env,
221
+ & mut orig_values,
222
+ impl_args,
223
+ ) ) ;
224
+ }
225
+ inspect:: ProbeStep :: AddGoal ( ..) => { }
226
+ inspect:: ProbeStep :: MakeCanonicalResponse { .. }
227
+ | inspect:: ProbeStep :: NestedProbe ( _) => unreachable ! ( ) ,
228
+ }
229
+ }
230
+
231
+ let ( ) =
232
+ instantiate_canonical_state ( infcx, span, param_env, & mut orig_values, self . final_state ) ;
233
+
234
+ if let Some ( term_hack) = self . goal . normalizes_to_term_hack {
235
+ // FIXME: We ignore the expected term of `NormalizesTo` goals
236
+ // when computing the result of its candidates. This is
237
+ // scuffed.
238
+ let _ = term_hack. constrain ( infcx, span, param_env) ;
239
+ }
240
+
241
+ opt_impl_args. map ( |impl_args| eager_resolve_vars ( infcx, impl_args) )
242
+ }
243
+
200
244
pub fn instantiate_proof_tree_for_nested_goal (
201
245
& self ,
202
246
source : GoalSource ,
0 commit comments