- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.F-coroutines`#![feature(coroutines)]``#![feature(coroutines)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
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)
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.F-coroutines`#![feature(coroutines)]``#![feature(coroutines)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.