@@ -133,45 +133,25 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
133
133
/// Instantiate the nested goals for the candidate without rolling back their
134
134
/// inference constraints. This function modifies the state of the `infcx`.
135
135
///
136
- /// See [`Self::instantiate_nested_goals_and_opt_impl_args`] if you need the impl args too.
137
- pub fn instantiate_nested_goals ( & self , span : Span ) -> Vec < InspectGoal < ' a , ' tcx > > {
138
- self . instantiate_nested_goals_and_opt_impl_args ( span) . 0
139
- }
140
-
141
- /// Instantiate the nested goals for the candidate without rolling back their
142
- /// inference constraints, and optionally the args of an impl if this candidate
143
- /// came from a `CandidateSource::Impl`. This function modifies the state of the
144
- /// `infcx`.
136
+ /// See [`Self::instantiate_impl_args`] if you need the impl args too.
145
137
#[ instrument(
146
138
level = "debug" ,
147
139
skip_all,
148
140
fields( goal = ?self . goal. goal, steps = ?self . steps)
149
141
) ]
150
- pub fn instantiate_nested_goals_and_opt_impl_args (
151
- & self ,
152
- span : Span ,
153
- ) -> ( Vec < InspectGoal < ' a , ' tcx > > , Option < ty:: GenericArgsRef < ' tcx > > ) {
142
+ pub fn instantiate_nested_goals ( & self , span : Span ) -> Vec < InspectGoal < ' a , ' tcx > > {
154
143
let infcx = self . goal . infcx ;
155
144
let param_env = self . goal . goal . param_env ;
156
145
let mut orig_values = self . goal . orig_values . to_vec ( ) ;
157
146
158
147
let mut instantiated_goals = vec ! [ ] ;
159
- let mut opt_impl_args = None ;
160
148
for step in & self . steps {
161
149
match * * step {
162
150
inspect:: ProbeStep :: AddGoal ( source, goal) => instantiated_goals. push ( (
163
151
source,
164
152
instantiate_canonical_state ( infcx, span, param_env, & mut orig_values, goal) ,
165
153
) ) ,
166
- inspect:: ProbeStep :: RecordImplArgs { impl_args } => {
167
- opt_impl_args = Some ( instantiate_canonical_state (
168
- infcx,
169
- span,
170
- param_env,
171
- & mut orig_values,
172
- impl_args,
173
- ) ) ;
174
- }
154
+ inspect:: ProbeStep :: RecordImplArgs { .. } => { }
175
155
inspect:: ProbeStep :: MakeCanonicalResponse { .. }
176
156
| inspect:: ProbeStep :: NestedProbe ( _) => unreachable ! ( ) ,
177
157
}
@@ -187,14 +167,59 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
187
167
let _ = term_hack. constrain ( infcx, span, param_env) ;
188
168
}
189
169
190
- let opt_impl_args = opt_impl_args. map ( |impl_args| eager_resolve_vars ( infcx, impl_args) ) ;
191
-
192
- let goals = instantiated_goals
170
+ instantiated_goals
193
171
. into_iter ( )
194
172
. map ( |( source, goal) | self . instantiate_proof_tree_for_nested_goal ( source, goal, span) )
195
- . collect ( ) ;
173
+ . collect ( )
174
+ }
175
+
176
+ /// Instantiate the args of an impl if this candidate came from a
177
+ /// `CandidateSource::Impl`. This function modifies the state of the
178
+ /// `infcx`.
179
+ #[ instrument(
180
+ level = "debug" ,
181
+ skip_all,
182
+ fields( goal = ?self . goal. goal, steps = ?self . steps)
183
+ ) ]
184
+ pub fn instantiate_impl_args ( & self , span : Span ) -> ty:: GenericArgsRef < ' tcx > {
185
+ let infcx = self . goal . infcx ;
186
+ let param_env = self . goal . goal . param_env ;
187
+ let mut orig_values = self . goal . orig_values . to_vec ( ) ;
188
+
189
+ for step in & self . steps {
190
+ match * * step {
191
+ inspect:: ProbeStep :: RecordImplArgs { impl_args } => {
192
+ let impl_args = instantiate_canonical_state (
193
+ infcx,
194
+ span,
195
+ param_env,
196
+ & mut orig_values,
197
+ impl_args,
198
+ ) ;
199
+
200
+ let ( ) = instantiate_canonical_state (
201
+ infcx,
202
+ span,
203
+ param_env,
204
+ & mut orig_values,
205
+ self . final_state ,
206
+ ) ;
207
+
208
+ // No reason we couldn't support this, but we don't need to for select.
209
+ assert ! (
210
+ self . goal. normalizes_to_term_hack. is_none( ) ,
211
+ "cannot use `instantiate_impl_args` with a `NormalizesTo` goal"
212
+ ) ;
213
+
214
+ return eager_resolve_vars ( infcx, impl_args) ;
215
+ }
216
+ inspect:: ProbeStep :: AddGoal ( ..) => { }
217
+ inspect:: ProbeStep :: MakeCanonicalResponse { .. }
218
+ | inspect:: ProbeStep :: NestedProbe ( _) => unreachable ! ( ) ,
219
+ }
220
+ }
196
221
197
- ( goals , opt_impl_args )
222
+ bug ! ( "expected impl args probe step for `instantiate_impl_args`" ) ;
198
223
}
199
224
200
225
pub fn instantiate_proof_tree_for_nested_goal (
0 commit comments