-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
internal: Parse (nightly) const
and async
trait bounds
#16588
internal: Parse (nightly) const
and async
trait bounds
#16588
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you adjust the grammar file here?
rust-analyzer/crates/syntax/rust.ungram
Lines 615 to 617 in bb0f93a
TypeBound = | |
Lifetime | |
| ('?' | '~' 'const')? Type |
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
👍 |
@@ -614,7 +614,7 @@ TypeBoundList = | |||
|
|||
TypeBound = | |||
Lifetime | |||
| ('?' | '~' 'const')? Type | |||
| ('~' 'const' | 'const')? 'async'? '?'? Type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
const
trait bounds: Introduceconst Trait
(always-const trait bounds) rust#119099async
trait bounds: Introduce support forasync
bound modifier onFn*
traits rust#120392The latter will certainly will not do the right thing; namely,
async Fn
needs to be mapped to theAsyncFn
trait. 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?