[Clippy] Swap waker_clone_wake
to use diagnostic item instead of path
This commit is contained in:
parent
5b55270225
commit
372f68b6a6
4 changed files with 4 additions and 3 deletions
|
@ -342,6 +342,7 @@ symbols! {
|
||||||
Upvars,
|
Upvars,
|
||||||
Vec,
|
Vec,
|
||||||
VecDeque,
|
VecDeque,
|
||||||
|
Waker,
|
||||||
Wrapper,
|
Wrapper,
|
||||||
Wrapping,
|
Wrapping,
|
||||||
Yield,
|
Yield,
|
||||||
|
|
|
@ -414,6 +414,7 @@ impl<'a> ContextBuilder<'a> {
|
||||||
/// [`Wake`]: ../../alloc/task/trait.Wake.html
|
/// [`Wake`]: ../../alloc/task/trait.Wake.html
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[stable(feature = "futures_api", since = "1.36.0")]
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
|
#[cfg_attr(not(test), rustc_diagnostic_item = "Waker")]
|
||||||
pub struct Waker {
|
pub struct Waker {
|
||||||
waker: RawWaker,
|
waker: RawWaker,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::source::snippet_with_applicability;
|
use clippy_utils::source::snippet_with_applicability;
|
||||||
use clippy_utils::{is_trait_method, match_def_path, paths};
|
use clippy_utils::is_trait_method;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{Expr, ExprKind};
|
use rustc_hir::{Expr, ExprKind};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
|
@ -12,7 +12,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, recv: &'
|
||||||
let ty = cx.typeck_results().expr_ty(recv);
|
let ty = cx.typeck_results().expr_ty(recv);
|
||||||
|
|
||||||
if let Some(did) = ty.ty_adt_def()
|
if let Some(did) = ty.ty_adt_def()
|
||||||
&& match_def_path(cx, did.did(), &paths::WAKER)
|
&& cx.tcx.is_diagnostic_item(sym::Waker, did.did())
|
||||||
&& let ExprKind::MethodCall(_, waker_ref, &[], _) = recv.kind
|
&& let ExprKind::MethodCall(_, waker_ref, &[], _) = recv.kind
|
||||||
&& is_trait_method(cx, recv, sym::Clone)
|
&& is_trait_method(cx, recv, sym::Clone)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,4 +73,3 @@ pub const TOKIO_IO_OPEN_OPTIONS: [&str; 4] = ["tokio", "fs", "open_options", "Op
|
||||||
#[expect(clippy::invalid_paths)] // internal lints do not know about all external crates
|
#[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 TOKIO_IO_OPEN_OPTIONS_NEW: [&str; 5] = ["tokio", "fs", "open_options", "OpenOptions", "new"];
|
||||||
pub const INSTANT_NOW: [&str; 4] = ["std", "time", "Instant", "now"];
|
pub const INSTANT_NOW: [&str; 4] = ["std", "time", "Instant", "now"];
|
||||||
pub const WAKER: [&str; 4] = ["core", "task", "wake", "Waker"];
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue