Closed
Description
I tried this code:
#![feature(generator_trait)]
#![feature(generators)]
use std::ops::Generator;
fn main() {
let mut x = |_| {
while let Some(val) = (yield) {
dbg!(val);
}
};
dbg!(std::pin::Pin::new(&mut x).resume(Some(5)));
dbg!(std::pin::Pin::new(&mut x).resume(Some(6)));
dbg!(std::pin::Pin::new(&mut x).resume(None));
}
I expected to see this happen: no warning
Instead, this happened:
warning: unnecessary parentheses around `let` scrutinee expression
--> src/main.rs:8:31
|
8 | while let Some(val) = (yield) {
| ^^^^^^^ help: remove these parentheses
|
= note: `#[warn(unused_parens)]` on by default
if I follow the suggestion, then compilation fails:
error: expected `{`, found `}`
--> src/main.rs:11:5
|
11 | };
| ^ expected `{`
(yield
takes an optional expression, not wrapping it in parentheses means the while let
block becomes that expression, and the while let
is then missing a block).
Meta
clippy 0.0.212 (2020-07-27 76e8333)
- `rustc 1.47.0-nightly (2020-07-27 76e8333)