mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-13 12:36:47 +00:00
Fix #[expect]
for async_yields_async
This commit is contained in:
parent
7e1730e16c
commit
8db734990b
@ -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| {
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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)]
|
||||
|
@ -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)]
|
||||
|
Loading…
Reference in New Issue
Block a user