pub mod eager_or_lazy;
pub mod higher;
mod hir_utils;
+pub mod msrvs;
pub mod numeric_literal;
pub mod paths;
pub mod ptr;
/// the function once on the given pattern.
pub fn recurse_or_patterns<'tcx, F: FnMut(&'tcx Pat<'tcx>)>(pat: &'tcx Pat<'tcx>, mut f: F) {
if let PatKind::Or(pats) = pat.kind {
- pats.iter().cloned().for_each(f)
+ pats.iter().copied().for_each(f)
} else {
f(pat)
}
let search_path = cx.get_def_path(did);
paths
.iter()
- .position(|p| p.iter().map(|x| Symbol::intern(x)).eq(search_path.iter().cloned()))
+ .position(|p| p.iter().map(|x| Symbol::intern(x)).eq(search_path.iter().copied()))
}
/// Checks if the given `DefId` matches the path.
pub fn match_def_path<'tcx>(cx: &LateContext<'tcx>, did: DefId, syms: &[&str]) -> bool {
// We should probably move to Symbols in Clippy as well rather than interning every time.
let path = cx.get_def_path(did);
- syms.iter().map(|x| Symbol::intern(x)).eq(path.iter().cloned())
+ syms.iter().map(|x| Symbol::intern(x)).eq(path.iter().copied())
}
pub fn match_panic_call(cx: &LateContext<'_>, expr: &'tcx Expr<'_>) -> Option<&'tcx Expr<'tcx>> {
(conds, blocks)
}
-/// This function returns true if the given expression is the `else` or `if else` part of an if
-/// statement
-pub fn parent_node_is_if_expr(expr: &Expr<'_>, cx: &LateContext<'_>) -> bool {
- let map = cx.tcx.hir();
- let parent_id = map.get_parent_node(expr.hir_id);
- let parent_node = map.get(parent_id);
- matches!(
- parent_node,
- Node::Expr(Expr {
- kind: ExprKind::If(_, _, _),
- ..
- })
- )
-}
-
// Finds the `#[must_use]` attribute, if any
pub fn must_use_attr(attrs: &[Attribute]) -> Option<&Attribute> {
attrs.iter().find(|a| a.has_name(sym::must_use))