Skip to main content

rapx/check/opt/
check_utils.rs

1use rustc_hir::def_id::DefId;
2
3use crate::analysis::dataflow::{GraphNode, NodeOp};
4
5/// Returns true if the node represents a call to one of the given DefIds.
6pub fn node_matches_call(node: &GraphNode, def_ids: &[DefId]) -> bool {
7    for op in node.ops.iter() {
8        if let NodeOp::Call(def_id) = op {
9            if def_ids.contains(def_id) {
10                return true;
11            }
12        }
13    }
14    false
15}
16
17/// Returns true if the node represents a call matching any of the given DefIds.
18pub fn node_matches_any_call(node: &GraphNode, pred: impl Fn(DefId) -> bool) -> bool {
19    for op in node.ops.iter() {
20        if let NodeOp::Call(def_id) = op {
21            if pred(*def_id) {
22                return true;
23            }
24        }
25    }
26    false
27}