Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion futures-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions futures-macro/src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl Parse for Select {

// `=> <expr>`
input.parse::<Token![=>]>()?;
let expr = input.parse::<Expr>()?;
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`.
Expand Down Expand Up @@ -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,
}
},
);
Expand Down
12 changes: 12 additions & 0 deletions futures/tests/async_await_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<i32>();
Expand Down