@@ -7,7 +7,7 @@ use rustc_lint::{LateContext, LateLintPass};
77use rustc_middle:: ty:: { EarlyBinder , Opaque , PredicateKind :: Trait } ;
88use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
99use rustc_span:: { sym, Span } ;
10- use rustc_trait_selection:: traits:: error_reporting:: suggestions:: InferCtxtExt ;
10+ use rustc_trait_selection:: traits:: error_reporting:: suggestions:: TypeErrCtxtExt ;
1111use rustc_trait_selection:: traits:: { self , FulfillmentError } ;
1212
1313declare_clippy_lint ! {
@@ -77,29 +77,28 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
7777 if is_future {
7878 let send_trait = cx. tcx . get_diagnostic_item ( sym:: Send ) . unwrap ( ) ;
7979 let span = decl. output . span ( ) ;
80- let send_errors = cx. tcx . infer_ctxt ( ) . enter ( |infcx| {
81- let cause = traits:: ObligationCause :: misc ( span, hir_id) ;
82- traits:: fully_solve_bound ( & infcx, cause, cx. param_env , ret_ty, send_trait)
83- } ) ;
80+ let infcx = cx. tcx . infer_ctxt ( ) . build ( ) ;
81+ let cause = traits:: ObligationCause :: misc ( span, hir_id) ;
82+ let send_errors = traits:: fully_solve_bound ( & infcx, cause, cx. param_env , ret_ty, send_trait) ;
8483 if !send_errors. is_empty ( ) {
8584 span_lint_and_then (
8685 cx,
8786 FUTURE_NOT_SEND ,
8887 span,
8988 "future cannot be sent between threads safely" ,
9089 |db| {
91- cx . tcx . infer_ctxt ( ) . enter ( |infcx| {
92- 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 . kind ( ) . skip_binder ( ) {
95- db . note ( & format ! (
96- "`{}` doesn't implement `{}`" ,
97- trait_pred . self_ty ( ) ,
98- trait_pred. trait_ref . print_only_trait_path ( ) ,
99- ) ) ;
100- }
90+ for FulfillmentError { obligation , .. } in send_errors {
91+ infcx
92+ . err_ctxt ( )
93+ . maybe_note_obligation_cause_for_async_await ( db , & obligation) ;
94+ if let Trait ( trait_pred ) = obligation . predicate . kind ( ) . skip_binder ( ) {
95+ db . note ( & format ! (
96+ "`{}` doesn't implement `{}`" ,
97+ trait_pred. self_ty ( ) ,
98+ trait_pred . trait_ref . print_only_trait_path ( ) ,
99+ ) ) ;
101100 }
102- } ) ;
101+ }
103102 } ,
104103 ) ;
105104 }
0 commit comments