Comments (2)
I added the two dbg to the following code:
futures-rs/futures-macro/src/select.rs
Lines 60 to 62 in 0fa6a1a
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
// `=> <expr>`
input.parse::<Token![=>]>()?;
+ dbg!(&input);
let expr = input.parse::<Expr>()?;
+ dbg!(&input);
// Commas after the expression are only optional if it's a `Block`
// or it is the last branch in the `match`.
And the output is:
[futures-macro/src/select.rs:62:13] &input = TokenStream [
Group {
delimiter: Brace,
stream: TokenStream [],
span: #0 bytes(10909..10911),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [],
span: #0 bytes(10924..10926),
},
Punct {
ch: '=',
spacing: Alone,
span: #0 bytes(10927..10928),
},
Ident {
ident: "pending",
span: #0 bytes(10929..10936),
},
Punct {
ch: ':',
spacing: Joint,
span: #0 bytes(10936..10937),
},
Punct {
ch: ':',
spacing: Joint,
span: #0 bytes(10937..10938),
},
Punct {
ch: '<',
spacing: Alone,
span: #0 bytes(10938..10939),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [],
span: #0 bytes(10939..10941),
},
Punct {
ch: '>',
spacing: Alone,
span: #0 bytes(10941..10942),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [],
span: #0 bytes(10942..10944),
},
Punct {
ch: '.',
spacing: Alone,
span: #0 bytes(10944..10945),
},
Ident {
ident: "fuse",
span: #0 bytes(10945..10949),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [],
span: #0 bytes(10949..10951),
},
Punct {
ch: '=',
spacing: Joint,
span: #0 bytes(10952..10953),
},
Punct {
ch: '>',
spacing: Alone,
span: #0 bytes(10953..10954),
},
Group {
delimiter: Brace,
stream: TokenStream [],
span: #0 bytes(10955..10957),
},
]
[futures-macro/src/select.rs:64:13] &input = TokenStream [
Punct {
ch: '=',
spacing: Joint,
span: #0 bytes(10952..10953),
},
Punct {
ch: '>',
spacing: Alone,
span: #0 bytes(10953..10954),
},
Group {
delimiter: Brace,
stream: TokenStream [],
span: #0 bytes(10955..10957),
},
]
error: expected `,`
--> futures/tests/async_await_macros.rs:402:41
|
402 | () = pending::<()>().fuse() => {}
| ^
It seems syn treats {} () = pending::<()>().fuse()
as a single expr.
cc @dtolnay
from futures-rs.
{} () = pending::<()>().fuse()
is a single expr.
macro_rules! expr {
($e:expr) => {};
}
expr!({} () = pending::<()>().fuse());
To parse this in a way that uses the expression termination rules of match arms, what you could do is: after parsing your =>
, collect all the rest of the tokens into a TokenStream prefixed with _ =>
, then parse syn::Arm
from that, and keep just the body
from that. Then repeat on whatever tokens are left.
from futures-rs.
Related Issues (20)
- Analogue of .last() method
- Error on OSX by futures-executir HOT 1
- Consider removing ArcWake, re-export std::task::Wake HOT 3
- Fine-tune the Ordering for num_senders
- Feature Request: make FuturesUnordered splitable.
- `FuturesUnordered` guaranties
- Unbounded memory use of `futures::channel::mpsc` with `SinkExt::feed`
- Question: futures-rs::channels implement Send trait HOT 1
- Non-send future produced by chaining `Stream` combinators HOT 1
- Behavior of any() / all() / try_any() / try_all() is not documented for empty stream
- Feature request: add `StreamExt::eq` like `Iterator::eq`
- Reusing `AbortRegistration`
- ConcurrentStream usage with tokio leads to ACCESS_VIOLATION HOT 3
- [Discussion] `Shared` seems to wake up the same waker that was polling it HOT 1
- Add `StreamExt::map_while`
- io: impl AsyncWrite for Empty
- Stream & Sink Error types could benefit from core::fmt::Debug bound HOT 1
- implement OwnedMappedMutexGuard
- `StreamExt::scan` lacks a non-Option version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from futures-rs.