Skip to content

Commit

Permalink
Ignore comma at the end of stream
Browse files Browse the repository at this point in the history
  • Loading branch information
ethe committed Jan 11, 2024
1 parent dafd1ce commit ce879f7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions futures-async-stream-macro/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ impl Parse for FnOrAsync {
attrs.append(&mut expr.attrs);
expr.attrs = attrs;

if input.peek(Token![,]) {
let _: Token![,] = input.parse()?;
}

Ok(Self::Async(expr, input.parse()?))
} else {
input.parse::<TokenStream>()?; // ignore all inputs
Expand Down
12 changes: 11 additions & 1 deletion tests/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
clippy::must_use_candidate,
clippy::needless_lifetimes,
clippy::no_effect_underscore_binding,
clippy::semicolon_if_nothing_returned
clippy::semicolon_if_nothing_returned,
clippy::unnecessary_wraps
)] // broken
#![feature(coroutines, proc_macro_hygiene, stmt_expr_attributes, gen_future)]

Expand Down Expand Up @@ -180,6 +181,15 @@ pub async fn array() {
yield [1, 2, 3, 4];
}

pub fn some_stream() -> Option<impl Stream> {
Some(
#[stream]
async {
yield 1;
},
)
}

#[allow(clippy::toplevel_ref_arg)]
pub mod arguments {
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/threads-safety.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ note: required because it appears within the type `Box<dyn Stream<Item = i32>>`
note: required because it appears within the type `Pin<Box<dyn Stream<Item = i32>>>`
--> $RUST/core/src/pin.rs
|
| pub struct Pin<Ptr> {
| pub struct Pin<P> {
| ^^^
note: required by a bound in `assert_send`
--> tests/ui/threads-safety.rs:7:19
Expand Down

0 comments on commit ce879f7

Please sign in to comment.