rust-clippy/tests/ui/no_effect_async_fn.rs
taiga.watanabe aa8a82ec26 FIX: issue-12279
----
UPDATE: add async block into test.

FIX: no_effect

Fixed asynchronous function parameter names with underscores so that warnings are not displayed when underscores are added to parameter names

ADD: test case
2024-02-21 23:26:29 +09:00

50 lines
1.2 KiB
Rust

#![warn(clippy::no_effect_underscore_binding)]
#![no_main]
trait AsyncTrait {
async fn bar(i: u64);
}
struct Bar;
impl AsyncTrait for Bar {
// Shouldn't lint `binding to `_` prefixed variable with no side-effect`
async fn bar(_i: u64) {
let _a = 0;
//~^ ERROR: binding to `_` prefixed variable with no side-effect
// Shouldn't lint `binding to `_` prefixed variable with no side-effect`
let _b = num();
let _ = async {
let _c = 0;
//~^ ERROR: binding to `_` prefixed variable with no side-effect
// Shouldn't lint `binding to `_` prefixed variable with no side-effect`
let _d = num();
}
.await;
}
}
// Shouldn't lint `binding to `_` prefixed variable with no side-effect`
async fn foo(_i: u64) {
let _a = 0;
//~^ ERROR: binding to `_` prefixed variable with no side-effect
// Shouldn't lint `binding to `_` prefixed variable with no side-effect`
let _b = num();
let _ = async {
let _c = 0;
//~^ ERROR: binding to `_` prefixed variable with no side-effect
// Shouldn't lint `binding to `_` prefixed variable with no side-effect`
let _d = num();
}
.await;
}
fn num() -> usize {
0
}