add excessive bools lints

This commit is contained in:
Areredify
2020-02-02 02:49:52 +03:00
committed by Mikhail Babenko
parent 8e28b2fdf1
commit 338fb7a3e9
19 changed files with 424 additions and 4 deletions

View File

@@ -1355,6 +1355,13 @@ pub fn is_no_std_crate(krate: &Crate<'_>) -> bool {
})
}
/// Check if parent of a hir node is a trait implementation block.
/// For example, `f` in
/// ```rust,ignore
/// impl Trait for S {
/// fn f() {}
/// }
/// ```
pub fn is_trait_impl_item(cx: &LateContext<'_, '_>, hir_id: HirId) -> bool {
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
matches!(item.kind, ItemKind::Impl{ of_trait: Some(_), .. })