Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 45c1700

Browse files
committed
[Clippy] Swap filter_map_bool_then to use diagnostic item instead of path
1 parent b015290 commit 45c1700

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

clippy_lints/src/methods/filter_map_bool_then.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use super::FILTER_MAP_BOOL_THEN;
22
use clippy_utils::diagnostics::span_lint_and_sugg;
3-
use clippy_utils::paths::BOOL_THEN;
43
use clippy_utils::source::SpanRangeExt;
54
use clippy_utils::ty::is_copy;
6-
use clippy_utils::{is_from_proc_macro, is_trait_method, match_def_path, peel_blocks};
5+
use clippy_utils::{is_from_proc_macro, is_trait_method, peel_blocks};
76
use rustc_errors::Applicability;
87
use rustc_hir::{Expr, ExprKind};
98
use rustc_lint::{LateContext, LintContext};
@@ -35,7 +34,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, arg: &
3534
&& let ExprKind::Closure(then_closure) = then_arg.kind
3635
&& let then_body = peel_blocks(cx.tcx.hir().body(then_closure.body).value)
3736
&& let Some(def_id) = cx.typeck_results().type_dependent_def_id(value.hir_id)
38-
&& match_def_path(cx, def_id, &BOOL_THEN)
37+
&& cx.tcx.is_diagnostic_item(sym::bool_then, def_id)
3938
&& !is_from_proc_macro(cx, expr)
4039
// Count the number of derefs needed to get to the bool because we need those in the suggestion
4140
&& let needed_derefs = cx.typeck_results().expr_adjustments(recv)

clippy_utils/src/paths.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,3 @@ pub const TOKIO_IO_OPEN_OPTIONS: [&str; 4] = ["tokio", "fs", "open_options", "Op
7474
pub const TOKIO_IO_OPEN_OPTIONS_NEW: [&str; 5] = ["tokio", "fs", "open_options", "OpenOptions", "new"];
7575
pub const INSTANT_NOW: [&str; 4] = ["std", "time", "Instant", "now"];
7676
pub const WAKER: [&str; 4] = ["core", "task", "wake", "Waker"];
77-
pub const BOOL_THEN: [&str; 4] = ["core", "bool", "<impl bool>", "then"];

0 commit comments

Comments
 (0)