@@ -3,6 +3,7 @@ use rustc_hir::intravisit::FnKind;
3
3
use rustc_hir:: { Body , FnDecl , HirId } ;
4
4
use rustc_infer:: infer:: TyCtxtInferExt ;
5
5
use rustc_lint:: { LateContext , LateLintPass } ;
6
+ use rustc_middle:: ty:: subst:: Subst ;
6
7
use rustc_middle:: ty:: { Opaque , PredicateAtom :: Trait } ;
7
8
use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
8
9
use rustc_span:: { sym, Span } ;
@@ -62,9 +63,10 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
62
63
}
63
64
let ret_ty = utils:: return_ty ( cx, hir_id) ;
64
65
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) ;
66
67
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) ;
68
70
if let Some ( trait_ref) = p. to_opt_poly_trait_ref ( ) {
69
71
if Some ( trait_ref. def_id ( ) ) == cx. tcx . lang_items ( ) . future_trait ( ) {
70
72
is_future = true ;
@@ -90,8 +92,13 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
90
92
|db| {
91
93
cx. tcx . infer_ctxt ( ) . enter ( |infcx| {
92
94
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
+ {
95
102
db. note ( & format ! (
96
103
"`{}` doesn't implement `{}`" ,
97
104
trait_pred. self_ty( ) ,
0 commit comments