@@ -454,28 +454,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
454
454
closure_kind : hir:: ClosureKind ,
455
455
projection : ty:: PolyProjectionPredicate < ' tcx > ,
456
456
) -> 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 ( ) ;
460
458
461
459
// For now, we only do signature deduction based off of the `Fn` and `AsyncFn` traits,
462
460
// for closures and async closures, respectively.
463
461
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 ) => {
467
463
self . extract_sig_from_projection ( cause_span, projection)
468
464
}
469
465
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 ) =>
471
467
{
472
468
self . extract_sig_from_projection ( cause_span, projection)
473
469
}
474
470
// It's possible we've passed the closure to a (somewhat out-of-fashion)
475
471
// `F: FnOnce() -> Fut, Fut: Future<Output = T>` style bound. Let's still
476
472
// guide inference here, since it's beneficial for the user.
477
473
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 ) =>
479
475
{
480
476
self . extract_sig_from_projection_and_future_bound ( cause_span, projection)
481
477
}
0 commit comments