@@ -3,6 +3,7 @@ use rustc_hir::intravisit::FnKind;
33use rustc_hir:: { Body , FnDecl , HirId } ;
44use rustc_infer:: infer:: TyCtxtInferExt ;
55use rustc_lint:: { LateContext , LateLintPass } ;
6+ use rustc_middle:: ty:: subst:: Subst ;
67use rustc_middle:: ty:: { Opaque , PredicateAtom :: Trait } ;
78use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
89use rustc_span:: { sym, Span } ;
@@ -62,9 +63,10 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
6263 }
6364 let ret_ty = utils:: return_ty ( cx, hir_id) ;
6465 if let Opaque ( id, subst) = * ret_ty. kind ( ) {
65- let preds = cx. tcx . predicates_of ( id) . instantiate ( cx . tcx , subst ) ;
66+ let preds = cx. tcx . explicit_item_bounds ( id) ;
6667 let mut is_future = false ;
67- for p in preds. predicates {
68+ for & ( p, _span) in preds {
69+ let p = p. subst ( cx. tcx , subst) ;
6870 if let Some ( trait_ref) = p. to_opt_poly_trait_ref ( ) {
6971 if Some ( trait_ref. def_id ( ) ) == cx. tcx . lang_items ( ) . future_trait ( ) {
7072 is_future = true ;
@@ -90,8 +92,13 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
9092 |db| {
9193 cx. tcx . infer_ctxt ( ) . enter ( |infcx| {
9294 for FulfillmentError { obligation, .. } in send_errors {
93- infcx. maybe_note_obligation_cause_for_async_await ( db, & obligation) ;
94- if let Trait ( trait_pred, _) = obligation. predicate . skip_binders ( ) {
95+ infcx. maybe_note_obligation_cause_for_async_await (
96+ db,
97+ & obligation,
98+ ) ;
99+ if let Trait ( trait_pred, _) =
100+ obligation. predicate . skip_binders ( )
101+ {
95102 db. note ( & format ! (
96103 "`{}` doesn't implement `{}`" ,
97104 trait_pred. self_ty( ) ,
0 commit comments