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