@@ -150,12 +150,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
150150 & mut candidates,
151151 ) ;
152152 }
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 ) => {
156154 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) ;
157158 self . assemble_fn_pointer_candidates ( obligation, & mut candidates) ;
158159 }
160+ _ => { }
159161 }
160162
161163 self . assemble_candidates_from_impls ( obligation, & mut candidates) ;
@@ -391,9 +393,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
391393 obligation : & PolyTraitObligation < ' tcx > ,
392394 candidates : & mut SelectionCandidateSet < ' tcx > ,
393395 ) {
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 ( ) ;
397397
398398 // Okay to skip binder because the args on closure types never
399399 // touch bound regions, they just capture the in-scope
@@ -455,11 +455,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
455455 obligation : & PolyTraitObligation < ' tcx > ,
456456 candidates : & mut SelectionCandidateSet < ' tcx > ,
457457 ) {
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 ( ) ;
463460
464461 match * obligation. self_ty ( ) . skip_binder ( ) . kind ( ) {
465462 ty:: CoroutineClosure ( _, args) => {
@@ -532,11 +529,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
532529 obligation : & PolyTraitObligation < ' tcx > ,
533530 candidates : & mut SelectionCandidateSet < ' tcx > ,
534531 ) {
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-
540532 // Keep this function in sync with extract_tupled_inputs_and_output_from_callable
541533 // until the old solver (and thus this function) is removed.
542534
0 commit comments