2023-10-19 16:46:28 -05:00
|
|
|
#![feature(coroutine_trait)]
|
|
|
|
#![feature(coroutines)]
|
2020-08-01 17:20:28 -05:00
|
|
|
#![deny(unused_braces, unused_parens)]
|
|
|
|
|
2023-10-19 11:06:43 -05:00
|
|
|
use std::ops::Coroutine;
|
2020-08-01 17:20:28 -05:00
|
|
|
use std::pin::Pin;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut x = |_| {
|
|
|
|
while let Some(_) = (yield) {}
|
|
|
|
while let Some(_) = {yield} {}
|
2020-08-02 11:31:21 -05:00
|
|
|
|
2020-08-01 17:20:28 -05:00
|
|
|
// Only warn these cases
|
|
|
|
while let Some(_) = ({yield}) {} //~ ERROR: unnecessary parentheses
|
2020-08-02 11:31:21 -05:00
|
|
|
while let Some(_) = ((yield)) {} //~ ERROR: unnecessary parentheses
|
|
|
|
{{yield}}; //~ ERROR: unnecessary braces
|
|
|
|
{( yield )}; //~ ERROR: unnecessary parentheses
|
2020-08-02 22:18:10 -05:00
|
|
|
while let Some(_) = {(yield)} {} //~ ERROR: unnecessary parentheses
|
|
|
|
while let Some(_) = {{yield}} {} //~ ERROR: unnecessary braces
|
2020-08-02 11:31:21 -05:00
|
|
|
|
|
|
|
// FIXME: It'd be great if we could also warn them.
|
|
|
|
((yield));
|
|
|
|
({ yield });
|
2020-08-01 17:20:28 -05:00
|
|
|
};
|
|
|
|
let _ = Pin::new(&mut x).resume(Some(5));
|
|
|
|
}
|