forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#12323 - not-elm:fix/issue-12279, r=y21
Fix: no_effect_underscore_binding fires on ignored parameters of async fns Fixes rust-lang#12279 changelog: Fix [`no_effect_underscore_binding`]) The warning is no longer displayed when an underscore is given in the parameter name of an asynchronous function.
- Loading branch information
Showing
3 changed files
with
82 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#![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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
error: binding to `_` prefixed variable with no side-effect | ||
--> tests/ui/no_effect_async_fn.rs:20:17 | ||
| | ||
LL | let _c = 0; | ||
| ^^ | ||
| | ||
= note: `-D clippy::no-effect-underscore-binding` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::no_effect_underscore_binding)]` | ||
|
||
error: binding to `_` prefixed variable with no side-effect | ||
--> tests/ui/no_effect_async_fn.rs:13:13 | ||
| | ||
LL | let _a = 0; | ||
| ^^ | ||
|
||
error: binding to `_` prefixed variable with no side-effect | ||
--> tests/ui/no_effect_async_fn.rs:39:13 | ||
| | ||
LL | let _c = 0; | ||
| ^^ | ||
|
||
error: binding to `_` prefixed variable with no side-effect | ||
--> tests/ui/no_effect_async_fn.rs:32:9 | ||
| | ||
LL | let _a = 0; | ||
| ^^ | ||
|
||
error: aborting due to 4 previous errors | ||
|