Fix #[expect] for async_yields_async

This commit is contained in:
xFrednet 2022-06-06 14:03:11 +02:00
parent 7e1730e16c
commit 8db734990b
No known key found for this signature in database
GPG Key ID: F5C59D0E669E5302
6 changed files with 30 additions and 4 deletions

View File

@ -1,4 +1,4 @@
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::diagnostics::span_lint_hir_and_then;
use clippy_utils::source::snippet;
use clippy_utils::ty::implements_trait;
use rustc_errors::Applicability;
@ -63,9 +63,10 @@ impl<'tcx> LateLintPass<'tcx> for AsyncYieldsAsync {
_ => None,
};
if let Some(return_expr_span) = return_expr_span {
span_lint_and_then(
span_lint_hir_and_then(
cx,
ASYNC_YIELDS_ASYNC,
body.value.hir_id,
return_expr_span,
"an async construct yields a type which is itself awaitable",
|db| {

View File

@ -47,6 +47,7 @@ struct ExistingName {
}
impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
#[expect(clippy::too_many_lines)]
fn check_crate_post(&mut self, cx: &LateContext<'tcx>) {
let mut map = FxHashMap::<Res, ExistingName>::default();

View File

@ -1,5 +1,5 @@
// run-rustfix
#![feature(lint_reasons)]
#![feature(async_closure)]
#![warn(clippy::async_yields_async)]
@ -65,3 +65,14 @@ fn main() {
let _n = async || custom_future_type_ctor();
let _o = async || f();
}
#[rustfmt::skip]
#[allow(dead_code)]
fn check_expect_suppression() {
#[expect(clippy::async_yields_async)]
let _j = async || {
async {
3
}
};
}

View File

@ -1,5 +1,5 @@
// run-rustfix
#![feature(lint_reasons)]
#![feature(async_closure)]
#![warn(clippy::async_yields_async)]
@ -65,3 +65,14 @@ fn main() {
let _n = async || custom_future_type_ctor();
let _o = async || f();
}
#[rustfmt::skip]
#[allow(dead_code)]
fn check_expect_suppression() {
#[expect(clippy::async_yields_async)]
let _j = async || {
async {
3
}
};
}

View File

@ -99,6 +99,7 @@ impl<'a> Trait for &'a str {}
fn h(_: &dyn Trait) {}
#[allow(dead_code)]
fn check_expect_suppression() {
let a = 5;
#[expect(clippy::needless_borrow)]

View File

@ -99,6 +99,7 @@ impl<'a> Trait for &'a str {}
fn h(_: &dyn Trait) {}
#[allow(dead_code)]
fn check_expect_suppression() {
let a = 5;
#[expect(clippy::needless_borrow)]