@@ -139,12 +139,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
139139 & mut candidates,
140140 ) ;
141141 }
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 ) => {
145143 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) ;
146147 self . assemble_fn_pointer_candidates ( obligation, & mut candidates) ;
147148 }
149+ _ => { }
148150 }
149151
150152 self . assemble_candidates_from_impls ( obligation, & mut candidates) ;
@@ -380,9 +382,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
380382 obligation : & PolyTraitObligation < ' tcx > ,
381383 candidates : & mut SelectionCandidateSet < ' tcx > ,
382384 ) {
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 ( ) ;
386386
387387 // Okay to skip binder because the args on closure types never
388388 // touch bound regions, they just capture the in-scope
@@ -444,11 +444,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
444444 obligation : & PolyTraitObligation < ' tcx > ,
445445 candidates : & mut SelectionCandidateSet < ' tcx > ,
446446 ) {
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 ( ) ;
452449
453450 match * obligation. self_ty ( ) . skip_binder ( ) . kind ( ) {
454451 ty:: CoroutineClosure ( _, args) => {
@@ -521,11 +518,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
521518 obligation : & PolyTraitObligation < ' tcx > ,
522519 candidates : & mut SelectionCandidateSet < ' tcx > ,
523520 ) {
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-
529521 // Keep this function in sync with extract_tupled_inputs_and_output_from_callable
530522 // until the old solver (and thus this function) is removed.
531523
0 commit comments