@@ -150,12 +150,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
150
150
& mut candidates,
151
151
) ;
152
152
}
153
- _ => {
154
- // FIXME: Put these into match arms above, since they're built-in.
155
- self . assemble_closure_candidates ( obligation, & mut candidates) ;
153
+ Some ( LangItem :: AsyncFn | LangItem :: AsyncFnMut | LangItem :: AsyncFnOnce ) => {
156
154
self . assemble_async_closure_candidates ( obligation, & mut candidates) ;
155
+ }
156
+ Some ( LangItem :: Fn | LangItem :: FnMut | LangItem :: FnOnce ) => {
157
+ self . assemble_closure_candidates ( obligation, & mut candidates) ;
157
158
self . assemble_fn_pointer_candidates ( obligation, & mut candidates) ;
158
159
}
160
+ _ => { }
159
161
}
160
162
161
163
self . assemble_candidates_from_impls ( obligation, & mut candidates) ;
@@ -391,9 +393,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
391
393
obligation : & PolyTraitObligation < ' tcx > ,
392
394
candidates : & mut SelectionCandidateSet < ' tcx > ,
393
395
) {
394
- let Some ( kind) = self . tcx ( ) . fn_trait_kind_from_def_id ( obligation. predicate . def_id ( ) ) else {
395
- return ;
396
- } ;
396
+ let kind = self . tcx ( ) . fn_trait_kind_from_def_id ( obligation. predicate . def_id ( ) ) . unwrap ( ) ;
397
397
398
398
// Okay to skip binder because the args on closure types never
399
399
// touch bound regions, they just capture the in-scope
@@ -455,11 +455,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
455
455
obligation : & PolyTraitObligation < ' tcx > ,
456
456
candidates : & mut SelectionCandidateSet < ' tcx > ,
457
457
) {
458
- let Some ( goal_kind) =
459
- self . tcx ( ) . async_fn_trait_kind_from_def_id ( obligation. predicate . def_id ( ) )
460
- else {
461
- return ;
462
- } ;
458
+ let goal_kind =
459
+ self . tcx ( ) . async_fn_trait_kind_from_def_id ( obligation. predicate . def_id ( ) ) . unwrap ( ) ;
463
460
464
461
match * obligation. self_ty ( ) . skip_binder ( ) . kind ( ) {
465
462
ty:: CoroutineClosure ( _, args) => {
@@ -532,11 +529,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
532
529
obligation : & PolyTraitObligation < ' tcx > ,
533
530
candidates : & mut SelectionCandidateSet < ' tcx > ,
534
531
) {
535
- // We provide impl of all fn traits for fn pointers.
536
- if !self . tcx ( ) . is_fn_trait ( obligation. predicate . def_id ( ) ) {
537
- return ;
538
- }
539
-
540
532
// Keep this function in sync with extract_tupled_inputs_and_output_from_callable
541
533
// until the old solver (and thus this function) is removed.
542
534
0 commit comments