@@ -10,8 +10,8 @@ use rustc_middle::ty::print::PrintTraitRefExt;
1010use  rustc_middle:: ty:: { 
1111    self ,  AliasTy ,  Binder ,  ClauseKind ,  PredicateKind ,  Ty ,  TyCtxt ,  TypeVisitable ,  TypeVisitableExt ,  TypeVisitor , 
1212} ; 
13- use  rustc_session:: declare_lint_pass ; 
14- use  rustc_span:: def_id:: LocalDefId ; 
13+ use  rustc_session:: impl_lint_pass ; 
14+ use  rustc_span:: def_id:: { DefId ,   LocalDefId } ; 
1515use  rustc_span:: { Span ,  sym} ; 
1616use  rustc_trait_selection:: error_reporting:: InferCtxtErrorExt ; 
1717use  rustc_trait_selection:: traits:: { self ,  FulfillmentError ,  ObligationCtxt } ; 
@@ -59,7 +59,21 @@ declare_clippy_lint! {
5959    "public Futures must be Send" 
6060} 
6161
62- declare_lint_pass ! ( FutureNotSend  => [ FUTURE_NOT_SEND ] ) ; 
62+ impl_lint_pass ! ( FutureNotSend  => [ FUTURE_NOT_SEND ] ) ; 
63+ 
64+ pub ( crate )  struct  FutureNotSend  { 
65+     future_trait :  Option < DefId > , 
66+     send_trait :  Option < DefId > , 
67+ } 
68+ 
69+ impl  FutureNotSend  { 
70+     pub ( crate )  fn  new ( tcx :  TyCtxt < ' _ > )  -> Self  { 
71+         Self  { 
72+             future_trait :  tcx. lang_items ( ) . future_trait ( ) , 
73+             send_trait :  tcx. get_diagnostic_item ( sym:: Send ) , 
74+         } 
75+     } 
76+ } 
6377
6478impl < ' tcx >  LateLintPass < ' tcx >  for  FutureNotSend  { 
6579    fn  check_fn ( 
@@ -76,8 +90,8 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
7690        } 
7791        let  ret_ty = return_ty ( cx,  cx. tcx . local_def_id_to_hir_id ( fn_def_id) . expect_owner ( ) ) ; 
7892        if  let  ty:: Alias ( ty:: Opaque ,  AliasTy  {  def_id,  args,  .. } )  = * ret_ty. kind ( ) 
79-             && let  Some ( future_trait)  = cx . tcx . lang_items ( ) . future_trait ( ) 
80-             && let  Some ( send_trait)  = cx . tcx . get_diagnostic_item ( sym :: Send ) 
93+             && let  Some ( future_trait)  = self . future_trait 
94+             && let  Some ( send_trait)  = self . send_trait 
8195        { 
8296            let  preds = cx. tcx . explicit_item_self_bounds ( def_id) ; 
8397            let  is_future = preds. iter_instantiated_copied ( cx. tcx ,  args) . any ( |( p,  _) | { 
0 commit comments