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

Commit 372f68b

Browse files
committed
[Clippy] Swap waker_clone_wake to use diagnostic item instead of path
1 parent 5b55270 commit 372f68b

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ symbols! {
342342
Upvars,
343343
Vec,
344344
VecDeque,
345+
Waker,
345346
Wrapper,
346347
Wrapping,
347348
Yield,

library/core/src/task/wake.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ impl<'a> ContextBuilder<'a> {
414414
/// [`Wake`]: ../../alloc/task/trait.Wake.html
415415
#[repr(transparent)]
416416
#[stable(feature = "futures_api", since = "1.36.0")]
417+
#[cfg_attr(not(test), rustc_diagnostic_item = "Waker")]
417418
pub struct Waker {
418419
waker: RawWaker,
419420
}

src/tools/clippy/clippy_lints/src/methods/waker_clone_wake.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
22
use clippy_utils::source::snippet_with_applicability;
3-
use clippy_utils::{is_trait_method, match_def_path, paths};
3+
use clippy_utils::is_trait_method;
44
use rustc_errors::Applicability;
55
use rustc_hir::{Expr, ExprKind};
66
use rustc_lint::LateContext;
@@ -12,7 +12,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, recv: &'
1212
let ty = cx.typeck_results().expr_ty(recv);
1313

1414
if let Some(did) = ty.ty_adt_def()
15-
&& match_def_path(cx, did.did(), &paths::WAKER)
15+
&& cx.tcx.is_diagnostic_item(sym::Waker, did.did())
1616
&& let ExprKind::MethodCall(_, waker_ref, &[], _) = recv.kind
1717
&& is_trait_method(cx, recv, sym::Clone)
1818
{

src/tools/clippy/clippy_utils/src/paths.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,3 @@ pub const TOKIO_IO_OPEN_OPTIONS: [&str; 4] = ["tokio", "fs", "open_options", "Op
7373
#[expect(clippy::invalid_paths)] // internal lints do not know about all external crates
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"];
76-
pub const WAKER: [&str; 4] = ["core", "task", "wake", "Waker"];

0 commit comments

Comments
 (0)