Symbol optimizations

This commit is contained in:
Cameron Steffen
2021-03-24 09:31:43 -05:00
parent 624e8aad32
commit 47f0c15f67
7 changed files with 66 additions and 81 deletions

View File

@@ -1203,16 +1203,9 @@ pub fn parent_node_is_if_expr(expr: &Expr<'_>, cx: &LateContext<'_>) -> bool {
)
}
// Finds the attribute with the given name, if any
pub fn attr_by_name<'a>(attrs: &'a [Attribute], name: &'_ str) -> Option<&'a Attribute> {
attrs
.iter()
.find(|attr| attr.ident().map_or(false, |ident| ident.as_str() == name))
}
// Finds the `#[must_use]` attribute, if any
pub fn must_use_attr(attrs: &[Attribute]) -> Option<&Attribute> {
attr_by_name(attrs, "must_use")
attrs.iter().find(|a| a.has_name(sym::must_use))
}
// check if expr is calling method or function with #[must_use] attribute