Skip to content

Commit c32af26

Browse files
committed
Refactor future_not_send
1 parent d409b5c commit c32af26

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

clippy_lints/src/future_not_send.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,11 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
6666
let ret_ty = return_ty(cx, cx.tcx.local_def_id_to_hir_id(fn_def_id).expect_owner());
6767
if let ty::Alias(ty::Opaque, AliasTy { def_id, args, .. }) = *ret_ty.kind() {
6868
let preds = cx.tcx.explicit_item_super_predicates(def_id);
69-
let mut is_future = false;
70-
for (p, _span) in preds.iter_instantiated_copied(cx.tcx, args) {
71-
if let Some(trait_pred) = p.as_trait_clause() {
72-
if Some(trait_pred.skip_binder().trait_ref.def_id) == cx.tcx.lang_items().future_trait() {
73-
is_future = true;
74-
break;
75-
}
76-
}
77-
}
69+
let is_future = preds.iter_instantiated_copied(cx.tcx, args).any(|(p, _)| {
70+
p.as_trait_clause().is_some_and(|trait_pred| {
71+
Some(trait_pred.skip_binder().trait_ref.def_id) == cx.tcx.lang_items().future_trait()
72+
})
73+
});
7874
if is_future {
7975
let send_trait = cx.tcx.get_diagnostic_item(sym::Send).unwrap();
8076
let span = decl.output.span();

0 commit comments

Comments
 (0)