diff --git a/futures-macro/Cargo.toml b/futures-macro/Cargo.toml index ddd740aa7..c6fe91cd1 100644 --- a/futures-macro/Cargo.toml +++ b/futures-macro/Cargo.toml @@ -18,7 +18,7 @@ proc-macro = true [dependencies] proc-macro2 = "1.0.60" quote = "1.0" -syn = { version = "2.0.8", features = ["full"] } +syn = { version = "2.0.52", features = ["full"] } [lints] workspace = true diff --git a/futures-macro/src/select.rs b/futures-macro/src/select.rs index 4cd8c7bc6..57bb74a84 100644 --- a/futures-macro/src/select.rs +++ b/futures-macro/src/select.rs @@ -59,7 +59,7 @@ impl Parse for Select { // `=> ` input.parse::]>()?; - let expr = input.parse::()?; + let expr = Expr::parse_with_earlier_boundary_rule(input)?; // Commas after the expression are only optional if it's a `Block` // or it is the last branch in the `match`. @@ -229,7 +229,7 @@ fn select_inner(input: TokenStream, random: bool) -> TokenStream { let branches = parsed.normal_fut_handlers.into_iter().zip(variant_names.iter()).map( |((pat, expr), variant_name)| { quote! { - #enum_ident::#variant_name(#pat) => { #expr }, + #enum_ident::#variant_name(#pat) => #expr, } }, ); diff --git a/futures/tests/async_await_macros.rs b/futures/tests/async_await_macros.rs index e87a5bf05..dbddf686a 100644 --- a/futures/tests/async_await_macros.rs +++ b/futures/tests/async_await_macros.rs @@ -57,6 +57,18 @@ fn select() { assert!(ran); } +#[test] +fn select_grammar() { + // Parsing after `=>` using Expr::parse would parse `{}() = future::ready(())` + // as one expression. + block_on(async { + select! { + () = future::pending::<()>() => {} + () = future::ready(()) => {} + } + }); +} + #[test] fn select_biased() { let (tx1, rx1) = oneshot::channel::();