@@ -110,7 +110,7 @@ pub(super) trait GoalKind<'tcx>:
110
110
ecx : & mut EvalCtxt < ' _ , ' tcx > ,
111
111
goal : Goal < ' tcx , Self > ,
112
112
impl_def_id : DefId ,
113
- ) -> QueryResult < ' tcx > ;
113
+ ) -> Result < Candidate < ' tcx > , NoSolution > ;
114
114
115
115
/// If the predicate contained an error, we want to avoid emitting unnecessary trait
116
116
/// errors but still want to emit errors for other trait goals. We have some special
@@ -263,7 +263,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
263
263
) -> Vec < Candidate < ' tcx > > {
264
264
debug_assert_eq ! ( goal, self . resolve_vars_if_possible( goal) ) ;
265
265
if let Some ( ambig) = self . assemble_self_ty_infer_ambiguity_response ( goal) {
266
- return ambig;
266
+ return vec ! [ ambig] ;
267
267
}
268
268
269
269
let mut candidates = self . assemble_candidates_via_self_ty ( goal, 0 ) ;
@@ -288,15 +288,20 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
288
288
fn assemble_self_ty_infer_ambiguity_response < G : GoalKind < ' tcx > > (
289
289
& mut self ,
290
290
goal : Goal < ' tcx , G > ,
291
- ) -> Option < Vec < Candidate < ' tcx > > > {
292
- goal. predicate . self_ty ( ) . is_ty_var ( ) . then ( || {
293
- vec ! [ Candidate {
294
- source: CandidateSource :: BuiltinImpl ( BuiltinImplSource :: Misc ) ,
295
- result: self
296
- . evaluate_added_goals_and_make_canonical_response( Certainty :: AMBIGUOUS )
297
- . unwrap( ) ,
298
- } ]
299
- } )
291
+ ) -> Option < Candidate < ' tcx > > {
292
+ if goal. predicate . self_ty ( ) . is_ty_var ( ) {
293
+ debug ! ( "adding self_ty_infer_ambiguity_response" ) ;
294
+ let source = CandidateSource :: BuiltinImpl ( BuiltinImplSource :: Misc ) ;
295
+ let result = self
296
+ . evaluate_added_goals_and_make_canonical_response ( Certainty :: AMBIGUOUS )
297
+ . unwrap ( ) ;
298
+ let mut dummy_probe = self . inspect . new_probe ( ) ;
299
+ dummy_probe. probe_kind ( ProbeKind :: TraitCandidate { source, result : Ok ( result) } ) ;
300
+ self . inspect . finish_probe ( dummy_probe) ;
301
+ Some ( Candidate { source, result } )
302
+ } else {
303
+ None
304
+ }
300
305
}
301
306
302
307
/// Assemble candidates which apply to the self type. This only looks at candidate which
@@ -310,7 +315,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
310
315
) -> Vec < Candidate < ' tcx > > {
311
316
debug_assert_eq ! ( goal, self . resolve_vars_if_possible( goal) ) ;
312
317
if let Some ( ambig) = self . assemble_self_ty_infer_ambiguity_response ( goal) {
313
- return ambig;
318
+ return vec ! [ ambig] ;
314
319
}
315
320
316
321
let mut candidates = Vec :: new ( ) ;
@@ -395,8 +400,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
395
400
if let Some ( impls_for_type) = trait_impls. non_blanket_impls ( ) . get ( & simp) {
396
401
for & impl_def_id in impls_for_type {
397
402
match G :: consider_impl_candidate ( self , goal, impl_def_id) {
398
- Ok ( result) => candidates
399
- . push ( Candidate { source : CandidateSource :: Impl ( impl_def_id) , result } ) ,
403
+ Ok ( candidate) => candidates. push ( candidate) ,
400
404
Err ( NoSolution ) => ( ) ,
401
405
}
402
406
}
@@ -514,8 +518,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
514
518
let trait_impls = tcx. trait_impls_of ( goal. predicate . trait_def_id ( tcx) ) ;
515
519
for & impl_def_id in trait_impls. blanket_impls ( ) {
516
520
match G :: consider_impl_candidate ( self , goal, impl_def_id) {
517
- Ok ( result) => candidates
518
- . push ( Candidate { source : CandidateSource :: Impl ( impl_def_id) , result } ) ,
521
+ Ok ( candidate) => candidates. push ( candidate) ,
519
522
Err ( NoSolution ) => ( ) ,
520
523
}
521
524
}
0 commit comments