Refactor future_not_send
This commit is contained in:
parent
d409b5c700
commit
c32af26be0
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user