Skip to content

Commit

Permalink
[Clippy] Swap instant_subtraction to use diagnostic item instead of…
Browse files Browse the repository at this point in the history
… path
  • Loading branch information
GnomedDev committed Sep 19, 2024
1 parent d63e35b commit 98dc68e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/instant_subtraction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl LateLintPass<'_> for InstantSubtraction {
fn is_instant_now_call(cx: &LateContext<'_>, expr_block: &'_ Expr<'_>) -> bool {
if let ExprKind::Call(fn_expr, []) = expr_block.kind
&& let Some(fn_id) = clippy_utils::path_def_id(cx, fn_expr)
&& clippy_utils::match_def_path(cx, fn_id, &clippy_utils::paths::INSTANT_NOW)
&& cx.tcx.is_diagnostic_item(sym::instant_now, fn_id)
{
true
} else {
Expand Down
1 change: 0 additions & 1 deletion clippy_utils/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,3 @@ pub const TOKIO_IO_ASYNCWRITEEXT: [&str; 5] = ["tokio", "io", "util", "async_wri
pub const TOKIO_IO_OPEN_OPTIONS: [&str; 4] = ["tokio", "fs", "open_options", "OpenOptions"];
#[expect(clippy::invalid_paths)] // internal lints do not know about all external crates
pub const TOKIO_IO_OPEN_OPTIONS_NEW: [&str; 5] = ["tokio", "fs", "open_options", "OpenOptions", "new"];
pub const INSTANT_NOW: [&str; 4] = ["std", "time", "Instant", "now"];

0 comments on commit 98dc68e

Please sign in to comment.