Skip to content

Commit 8db7349

Browse files
committed
Fix #[expect] for async_yields_async
1 parent 7e1730e commit 8db7349

File tree

6 files changed

+30
-4
lines changed

6 files changed

+30
-4
lines changed

clippy_lints/src/async_yields_async.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use clippy_utils::diagnostics::span_lint_and_then;
1+
use clippy_utils::diagnostics::span_lint_hir_and_then;
22
use clippy_utils::source::snippet;
33
use clippy_utils::ty::implements_trait;
44
use rustc_errors::Applicability;
@@ -63,9 +63,10 @@ impl<'tcx> LateLintPass<'tcx> for AsyncYieldsAsync {
6363
_ => None,
6464
};
6565
if let Some(return_expr_span) = return_expr_span {
66-
span_lint_and_then(
66+
span_lint_hir_and_then(
6767
cx,
6868
ASYNC_YIELDS_ASYNC,
69+
body.value.hir_id,
6970
return_expr_span,
7071
"an async construct yields a type which is itself awaitable",
7172
|db| {

clippy_lints/src/same_name_method.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct ExistingName {
4747
}
4848

4949
impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
50+
#[expect(clippy::too_many_lines)]
5051
fn check_crate_post(&mut self, cx: &LateContext<'tcx>) {
5152
let mut map = FxHashMap::<Res, ExistingName>::default();
5253

tests/ui/async_yields_async.fixed

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-rustfix
2-
2+
#![feature(lint_reasons)]
33
#![feature(async_closure)]
44
#![warn(clippy::async_yields_async)]
55

@@ -65,3 +65,14 @@ fn main() {
6565
let _n = async || custom_future_type_ctor();
6666
let _o = async || f();
6767
}
68+
69+
#[rustfmt::skip]
70+
#[allow(dead_code)]
71+
fn check_expect_suppression() {
72+
#[expect(clippy::async_yields_async)]
73+
let _j = async || {
74+
async {
75+
3
76+
}
77+
};
78+
}

tests/ui/async_yields_async.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-rustfix
2-
2+
#![feature(lint_reasons)]
33
#![feature(async_closure)]
44
#![warn(clippy::async_yields_async)]
55

@@ -65,3 +65,14 @@ fn main() {
6565
let _n = async || custom_future_type_ctor();
6666
let _o = async || f();
6767
}
68+
69+
#[rustfmt::skip]
70+
#[allow(dead_code)]
71+
fn check_expect_suppression() {
72+
#[expect(clippy::async_yields_async)]
73+
let _j = async || {
74+
async {
75+
3
76+
}
77+
};
78+
}

tests/ui/needless_borrow.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ impl<'a> Trait for &'a str {}
9999

100100
fn h(_: &dyn Trait) {}
101101

102+
#[allow(dead_code)]
102103
fn check_expect_suppression() {
103104
let a = 5;
104105
#[expect(clippy::needless_borrow)]

tests/ui/needless_borrow.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ impl<'a> Trait for &'a str {}
9999

100100
fn h(_: &dyn Trait) {}
101101

102+
#[allow(dead_code)]
102103
fn check_expect_suppression() {
103104
let a = 5;
104105
#[expect(clippy::needless_borrow)]

0 commit comments

Comments
 (0)