@@ -454,28 +454,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
454454 closure_kind : hir:: ClosureKind ,
455455 projection : ty:: PolyProjectionPredicate < ' tcx > ,
456456 ) -> Option < ExpectedSig < ' tcx > > {
457- let tcx = self . tcx ;
458-
459- let trait_def_id = projection. trait_def_id ( tcx) ;
457+ let def_id = projection. projection_def_id ( ) ;
460458
461459 // For now, we only do signature deduction based off of the `Fn` and `AsyncFn` traits,
462460 // for closures and async closures, respectively.
463461 match closure_kind {
464- hir:: ClosureKind :: Closure
465- if self . tcx . fn_trait_kind_from_def_id ( trait_def_id) . is_some ( ) =>
466- {
462+ hir:: ClosureKind :: Closure if self . tcx . is_lang_item ( def_id, LangItem :: FnOnceOutput ) => {
467463 self . extract_sig_from_projection ( cause_span, projection)
468464 }
469465 hir:: ClosureKind :: CoroutineClosure ( hir:: CoroutineDesugaring :: Async )
470- if self . tcx . async_fn_trait_kind_from_def_id ( trait_def_id ) . is_some ( ) =>
466+ if self . tcx . is_lang_item ( def_id , LangItem :: AsyncFnOnceOutput ) =>
471467 {
472468 self . extract_sig_from_projection ( cause_span, projection)
473469 }
474470 // It's possible we've passed the closure to a (somewhat out-of-fashion)
475471 // `F: FnOnce() -> Fut, Fut: Future<Output = T>` style bound. Let's still
476472 // guide inference here, since it's beneficial for the user.
477473 hir:: ClosureKind :: CoroutineClosure ( hir:: CoroutineDesugaring :: Async )
478- if self . tcx . fn_trait_kind_from_def_id ( trait_def_id ) . is_some ( ) =>
474+ if self . tcx . is_lang_item ( def_id , LangItem :: FnOnceOutput ) =>
479475 {
480476 self . extract_sig_from_projection_and_future_bound ( cause_span, projection)
481477 }
0 commit comments