summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/clippy_lints/src/future_not_send.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:11:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:13:23 +0000
commit20431706a863f92cb37dc512fef6e48d192aaf2c (patch)
tree2867f13f5fd5437ba628c67d7f87309ccadcd286 /src/tools/clippy/clippy_lints/src/future_not_send.rs
parentReleasing progress-linux version 1.65.0+dfsg1-2~progress7.99u1. (diff)
downloadrustc-20431706a863f92cb37dc512fef6e48d192aaf2c.tar.xz
rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.zip
Merging upstream version 1.66.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/clippy_lints/src/future_not_send.rs')
-rw-r--r--src/tools/clippy/clippy_lints/src/future_not_send.rs32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/tools/clippy/clippy_lints/src/future_not_send.rs b/src/tools/clippy/clippy_lints/src/future_not_send.rs
index ef7d75aa8..0519f9ac2 100644
--- a/src/tools/clippy/clippy_lints/src/future_not_send.rs
+++ b/src/tools/clippy/clippy_lints/src/future_not_send.rs
@@ -4,11 +4,10 @@ use rustc_hir::intravisit::FnKind;
use rustc_hir::{Body, FnDecl, HirId};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_lint::{LateContext, LateLintPass};
-use rustc_middle::ty::subst::Subst;
use rustc_middle::ty::{EarlyBinder, Opaque, PredicateKind::Trait};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::{sym, Span};
-use rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt;
+use rustc_trait_selection::traits::error_reporting::suggestions::TypeErrCtxtExt;
use rustc_trait_selection::traits::{self, FulfillmentError};
declare_clippy_lint! {
@@ -78,10 +77,9 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
if is_future {
let send_trait = cx.tcx.get_diagnostic_item(sym::Send).unwrap();
let span = decl.output.span();
- let send_errors = cx.tcx.infer_ctxt().enter(|infcx| {
- let cause = traits::ObligationCause::misc(span, hir_id);
- traits::fully_solve_bound(&infcx, cause, cx.param_env, ret_ty, send_trait)
- });
+ let infcx = cx.tcx.infer_ctxt().build();
+ let cause = traits::ObligationCause::misc(span, hir_id);
+ let send_errors = traits::fully_solve_bound(&infcx, cause, cx.param_env, ret_ty, send_trait);
if !send_errors.is_empty() {
span_lint_and_then(
cx,
@@ -89,18 +87,18 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
span,
"future cannot be sent between threads safely",
|db| {
- cx.tcx.infer_ctxt().enter(|infcx| {
- for FulfillmentError { obligation, .. } in send_errors {
- infcx.maybe_note_obligation_cause_for_async_await(db, &obligation);
- if let Trait(trait_pred) = obligation.predicate.kind().skip_binder() {
- db.note(&format!(
- "`{}` doesn't implement `{}`",
- trait_pred.self_ty(),
- trait_pred.trait_ref.print_only_trait_path(),
- ));
- }
+ for FulfillmentError { obligation, .. } in send_errors {
+ infcx
+ .err_ctxt()
+ .maybe_note_obligation_cause_for_async_await(db, &obligation);
+ if let Trait(trait_pred) = obligation.predicate.kind().skip_binder() {
+ db.note(&format!(
+ "`{}` doesn't implement `{}`",
+ trait_pred.self_ty(),
+ trait_pred.trait_ref.print_only_trait_path(),
+ ));
}
- });
+ }
},
);
}