@@ -143,12 +143,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
143
143
& mut candidates,
144
144
) ;
145
145
}
146
- _ => {
147
- // FIXME: Put these into match arms above, since they're built-in.
148
- self . assemble_closure_candidates ( obligation, & mut candidates) ;
146
+ Some ( LangItem :: AsyncFn | LangItem :: AsyncFnMut | LangItem :: AsyncFnOnce ) => {
149
147
self . assemble_async_closure_candidates ( obligation, & mut candidates) ;
148
+ }
149
+ Some ( LangItem :: Fn | LangItem :: FnMut | LangItem :: FnOnce ) => {
150
+ self . assemble_closure_candidates ( obligation, & mut candidates) ;
150
151
self . assemble_fn_pointer_candidates ( obligation, & mut candidates) ;
151
152
}
153
+ _ => { }
152
154
}
153
155
154
156
self . assemble_candidates_from_impls ( obligation, & mut candidates) ;
@@ -384,9 +386,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
384
386
obligation : & PolyTraitObligation < ' tcx > ,
385
387
candidates : & mut SelectionCandidateSet < ' tcx > ,
386
388
) {
387
- let Some ( kind) = self . tcx ( ) . fn_trait_kind_from_def_id ( obligation. predicate . def_id ( ) ) else {
388
- return ;
389
- } ;
389
+ let kind = self . tcx ( ) . fn_trait_kind_from_def_id ( obligation. predicate . def_id ( ) ) . unwrap ( ) ;
390
390
391
391
// Okay to skip binder because the args on closure types never
392
392
// touch bound regions, they just capture the in-scope
@@ -448,11 +448,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
448
448
obligation : & PolyTraitObligation < ' tcx > ,
449
449
candidates : & mut SelectionCandidateSet < ' tcx > ,
450
450
) {
451
- let Some ( goal_kind) =
452
- self . tcx ( ) . async_fn_trait_kind_from_def_id ( obligation. predicate . def_id ( ) )
453
- else {
454
- return ;
455
- } ;
451
+ let goal_kind =
452
+ self . tcx ( ) . async_fn_trait_kind_from_def_id ( obligation. predicate . def_id ( ) ) . unwrap ( ) ;
456
453
457
454
match * obligation. self_ty ( ) . skip_binder ( ) . kind ( ) {
458
455
ty:: CoroutineClosure ( _, args) => {
@@ -525,11 +522,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
525
522
obligation : & PolyTraitObligation < ' tcx > ,
526
523
candidates : & mut SelectionCandidateSet < ' tcx > ,
527
524
) {
528
- // We provide impl of all fn traits for fn pointers.
529
- if !self . tcx ( ) . is_fn_trait ( obligation. predicate . def_id ( ) ) {
530
- return ;
531
- }
532
-
533
525
// Keep this function in sync with extract_tupled_inputs_and_output_from_callable
534
526
// until the old solver (and thus this function) is removed.
535
527
0 commit comments