internal: Parse (nightly) const and async trait bounds#16588
internal: Parse (nightly) const and async trait bounds#16588bors merged 2 commits intorust-lang:masterfrom
const and async trait bounds#16588Conversation
Veykril
left a comment
There was a problem hiding this comment.
Can you adjust the grammar file here?
rust-analyzer/crates/syntax/rust.ungram
Lines 615 to 617 in bb0f93a
Something like the following should be fine (ungrammar is not an exact representation of the AST)
TypeBound =
Lifetime
| ('?' | '~')? ('const' | 'async')? Type
Then run the -p syntax tests to regenerate the AST.
Its fine to land the parser changes only, getting rid of the parser errors is the main concern here. The initial lowering of the bounds happen here rust-analyzer/crates/hir-def/src/hir/type_ref.rs Lines 345 to 380 in ead3691 |
Bounds are CONSTNESS ASYNCNESS POLARITY
|
👍 |
| TypeBound = | ||
| Lifetime | ||
| | ('?' | '~' 'const')? Type | ||
| | ('~' 'const' | 'const')? 'async'? '?'? Type |
There was a problem hiding this comment.
opted for this because it's a bit more accurate representation of the real grammar rustc parses. I can change it if desired, though. I understand the parser modification up in generic_params.rs doesn't reflect all of the combinations that this one does.
There was a problem hiding this comment.
No that's fine as long as the possible tokens are represented.
|
Thanks! |
const and async trait boundsconst and async trait bounds
|
☀️ Test successful - checks-actions |
Both of these bound modifiers were added recently:
consttrait bounds: Introduceconst Trait(always-const trait bounds) rust#119099asynctrait bounds: Introduce support forasyncbound modifier onFn*traits rust#120392The latter will certainly will not do the right thing; namely,
async Fnneeds to be mapped to theAsyncFntrait. IDK how to do that, so advice would be appreciated, though perhaps we could land this first so the parser isn't complaining about these bounds?