blob: 8064c3a88d1d98c1ff2d84d1b71b1cd64c1a4600 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#![feature(generator_trait)]
#![feature(generators)]
#![deny(unused_braces, unused_parens)]
use std::ops::Generator;
use std::pin::Pin;
fn main() {
let mut x = |_| {
while let Some(_) = (yield) {}
while let Some(_) = {yield} {}
// Only warn these cases
while let Some(_) = ({yield}) {} //~ ERROR: unnecessary parentheses
while let Some(_) = ((yield)) {} //~ ERROR: unnecessary parentheses
{{yield}}; //~ ERROR: unnecessary braces
{( yield )}; //~ ERROR: unnecessary parentheses
while let Some(_) = {(yield)} {} //~ ERROR: unnecessary parentheses
while let Some(_) = {{yield}} {} //~ ERROR: unnecessary braces
// FIXME: It'd be great if we could also warn them.
((yield));
({ yield });
};
let _ = Pin::new(&mut x).resume(Some(5));
}
|