@@ -7,7 +7,7 @@ use rustc_lint::{LateContext, LateLintPass};
7
7
use rustc_middle:: ty:: { EarlyBinder , Opaque , PredicateKind :: Trait } ;
8
8
use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
9
9
use rustc_span:: { sym, Span } ;
10
- use rustc_trait_selection:: traits:: error_reporting:: suggestions:: InferCtxtExt ;
10
+ use rustc_trait_selection:: traits:: error_reporting:: suggestions:: TypeErrCtxtExt ;
11
11
use rustc_trait_selection:: traits:: { self , FulfillmentError } ;
12
12
13
13
declare_clippy_lint ! {
@@ -77,29 +77,28 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
77
77
if is_future {
78
78
let send_trait = cx. tcx . get_diagnostic_item ( sym:: Send ) . unwrap ( ) ;
79
79
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) ;
84
83
if !send_errors. is_empty ( ) {
85
84
span_lint_and_then (
86
85
cx,
87
86
FUTURE_NOT_SEND ,
88
87
span,
89
88
"future cannot be sent between threads safely" ,
90
89
|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
+ ) ) ;
101
100
}
102
- } ) ;
101
+ }
103
102
} ,
104
103
) ;
105
104
}
0 commit comments