Lint on closure calls, suppress on callable constants calls
This commit is contained in:
parent
9d311b5c2b
commit
3629372723
@ -33,10 +33,10 @@ fn is_arg_ty_unified_in_fn<'tcx>(
|
|||||||
cx: &LateContext<'tcx>,
|
cx: &LateContext<'tcx>,
|
||||||
fn_id: DefId,
|
fn_id: DefId,
|
||||||
arg_id: HirId,
|
arg_id: HirId,
|
||||||
args: impl Iterator<Item = &'tcx Expr<'tcx>> + Clone,
|
args: impl IntoIterator<Item = &'tcx Expr<'tcx>>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let fn_sig = cx.tcx.fn_sig(fn_id).instantiate_identity();
|
let fn_sig = cx.tcx.fn_sig(fn_id).instantiate_identity();
|
||||||
let arg_id_in_args = args.clone().position(|e| e.hir_id == arg_id).unwrap();
|
let arg_id_in_args = args.into_iter().position(|e| e.hir_id == arg_id).unwrap();
|
||||||
let arg_ty_in_args = fn_sig.input(arg_id_in_args);
|
let arg_ty_in_args = fn_sig.input(arg_id_in_args);
|
||||||
|
|
||||||
cx.tcx.predicates_of(fn_id).predicates.iter().any(|(clause, _)| {
|
cx.tcx.predicates_of(fn_id).predicates.iter().any(|(clause, _)| {
|
||||||
@ -72,12 +72,11 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, method
|
|||||||
..
|
..
|
||||||
},
|
},
|
||||||
args,
|
args,
|
||||||
) => is_arg_ty_unified_in_fn(
|
) => {
|
||||||
cx,
|
cx.typeck_results().qpath_res(path, *hir_id).opt_def_id()
|
||||||
cx.typeck_results().qpath_res(path, *hir_id).def_id(),
|
.filter(|fn_id| cx.tcx.def_kind(fn_id).is_fn_like())
|
||||||
expr.hir_id,
|
.is_some_and(|fn_id| is_arg_ty_unified_in_fn(cx, fn_id, expr.hir_id, args))
|
||||||
args.iter(),
|
}
|
||||||
),
|
|
||||||
ExprKind::MethodCall(_name, recv, args, _span) => is_arg_ty_unified_in_fn(
|
ExprKind::MethodCall(_name, recv, args, _span) => is_arg_ty_unified_in_fn(
|
||||||
cx,
|
cx,
|
||||||
cx.typeck_results().type_dependent_def_id(parent.hir_id).unwrap(),
|
cx.typeck_results().type_dependent_def_id(parent.hir_id).unwrap(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user