Skip to content

Commit c9c49e3

Browse files
author
Alexis Langlet
committed
feat: add any_impl_has_lint_allowed
1 parent 0b6e7e2 commit c9c49e3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

clippy_utils/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,6 +1846,14 @@ pub fn is_lint_allowed(cx: &LateContext<'_>, lint: &'static Lint, id: HirId) ->
18461846
cx.tcx.lint_level_at_node(lint, id).0 == Level::Allow
18471847
}
18481848

1849+
/// Returns `true` if any of the `impl`s for the given `item` has the lint allowed
1850+
pub fn any_impl_has_lint_allowed(cx: &LateContext<'_>, lint: &'static Lint, id: DefId) -> bool {
1851+
cx.tcx
1852+
.inherent_impls(id)
1853+
.iter()
1854+
.any(|imp| is_lint_allowed(cx, lint, cx.tcx.hir().expect_item(imp.expect_local()).hir_id()))
1855+
}
1856+
18491857
pub fn strip_pat_refs<'hir>(mut pat: &'hir Pat<'hir>) -> &'hir Pat<'hir> {
18501858
while let PatKind::Ref(subpat, _) = pat.kind {
18511859
pat = subpat;

0 commit comments

Comments
 (0)