diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2024-06-11 14:22:03 -0400 |
|---|---|---|
| committer | Jason Newcomb <jsnewcomb@pm.me> | 2024-07-07 16:16:36 -0400 |
| commit | c32af26be02fb3c12d18c28e0c6f2b3c953fda3a (patch) | |
| tree | 41e58c3b505fa55623b62e020a95df41e4b3cfbd | |
| parent | d409b5c700e1789a5b2d0b1dd1bd996bfd8bb320 (diff) | |
| download | rust-c32af26be02fb3c12d18c28e0c6f2b3c953fda3a.tar.gz rust-c32af26be02fb3c12d18c28e0c6f2b3c953fda3a.zip | |
Refactor `future_not_send`
| -rw-r--r-- | clippy_lints/src/future_not_send.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/clippy_lints/src/future_not_send.rs b/clippy_lints/src/future_not_send.rs index cb1d0de1edf..9a43bc69764 100644 --- a/clippy_lints/src/future_not_send.rs +++ b/clippy_lints/src/future_not_send.rs @@ -66,15 +66,11 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend { let ret_ty = return_ty(cx, cx.tcx.local_def_id_to_hir_id(fn_def_id).expect_owner()); if let ty::Alias(ty::Opaque, AliasTy { def_id, args, .. }) = *ret_ty.kind() { let preds = cx.tcx.explicit_item_super_predicates(def_id); - let mut is_future = false; - for (p, _span) in preds.iter_instantiated_copied(cx.tcx, args) { - if let Some(trait_pred) = p.as_trait_clause() { - if Some(trait_pred.skip_binder().trait_ref.def_id) == cx.tcx.lang_items().future_trait() { - is_future = true; - break; - } - } - } + let is_future = preds.iter_instantiated_copied(cx.tcx, args).any(|(p, _)| { + p.as_trait_clause().is_some_and(|trait_pred| { + Some(trait_pred.skip_binder().trait_ref.def_id) == cx.tcx.lang_items().future_trait() + }) + }); if is_future { let send_trait = cx.tcx.get_diagnostic_item(sym::Send).unwrap(); let span = decl.output.span(); |
