Skip to content
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

Support .await syntax #1558

Merged
merged 1 commit into from Jul 20, 2019

Conversation

@unrealhoang
Copy link
Contributor

commented Jul 20, 2019

Add await keyword to grammar, parser for await_expr

@unrealhoang

This comment has been minimized.

Copy link
Contributor Author

commented Jul 20, 2019

@matklad I'm not so familiar with syntax and parsing yet, so please help to commend if I'm doing things right.

@lnicola

This comment has been minimized.

Copy link
Contributor

commented Jul 20, 2019

We'll also want highlighting support for await, I think. During the syntax discussions, the postfix form was criticized for being harder to notice.

@matklad

This comment has been minimized.

Copy link
Collaborator

commented Jul 20, 2019

Yeah, this is the right first step!

I'll just bors r+ this, as it is self-contained and already useful.

bors r+

bors bot added a commit that referenced this pull request Jul 20, 2019

Merge #1558
1558: Support .await syntax r=matklad a=unrealhoang

- [x] Add `await` keyword to grammar, parser for await_expr
- [ ] Infer type for await_expr

Co-authored-by: Unreal Hoang <unrealhoang@gmail.com>
@matklad

This comment has been minimized.

Copy link
Collaborator

commented Jul 20, 2019

@lnicola I think highlighting should just work, because the kind is marked as a keyword

@lnicola

This comment has been minimized.

Copy link
Contributor

commented Jul 20, 2019

I was thinking of making it similar to the unsafe highlighting 😅. But it can be added in another PR, of course.

@matklad

This comment has been minimized.

Copy link
Collaborator

commented Jul 20, 2019

During the syntax discussions, the postfix form was criticized for being harder to notice.

I am willing to bet that it's an instance of Stroustrup rule :) Usual syntax highlighting will be enough for most people after a couple of releases with .await. I might be wrong of course, but it'll be easy to make more conspicuous highlighting if we deem that it is necessary, after the feature is stable for a couple of months.

@bors

This comment has been minimized.

Copy link
Contributor

commented Jul 20, 2019

@bors bors bot merged commit 3a7f07c into rust-analyzer:master Jul 20, 2019

2 checks passed

bors Build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@unrealhoang

This comment has been minimized.

Copy link
Contributor Author

commented Jul 20, 2019

@matklad next we need to add AwaitExpr to ast/Expr?

@matklad

This comment has been minimized.

Copy link
Collaborator

commented Jul 20, 2019

Yep, this should be done in ast secion of grammar.ron, here: https://github.com/unrealhoang/rust-analyzer/blob/e18f8495d6569f4fc0b7457b65a1d199cf7b5974/crates/ra_syntax/src/grammar.ron#L487-L519.

We only need to get reciver out of Await expr, so "AwaitExpr": (options: ["Expr"]), should work.

It makes sense to update hir::ExprCollector::collect_expr and hir::Expr along the way as well. At this stage, typechecking can be just stubbed out to return Ty::Unknown

@unrealhoang unrealhoang referenced this pull request Jul 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.