Skip to content

Add inline const expression and pattern #17

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

Merged
merged 1 commit into from
Dec 23, 2020

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Dec 15, 2020

To be able to address rust-lang/rust-analyzer#6848 in the (near) future. The name ConstBlockPattern was chosen since that's what the rfc calls it.

CodeGen with this breaks RA in one file https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_def/src/body/lower.rs#L825, that is if the "CONST_BLOCK_PAT" has been added to KINDS_SRC.

I figure adding this now is a good time as the rust.ungrammar is being changed for lifetimes and macros2.0 anyways.

Copy link
Contributor

@jonas-schievink jonas-schievink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good. Have you checked if rust-analyzer still builds with this change? I'd like to avoid having to fix any new breakage before other ungrammar changes can be incorporated.

@Veykril
Copy link
Member Author

Veykril commented Dec 15, 2020

It does stop RA from building, in one file due to exhaustive matching and another due to the required addition to the KINDS_SRC, basically boiling down to two required line changes:

@matklad
Copy link
Member

matklad commented Dec 16, 2020

The eternal monorepo vs polyrepo question....

At one point, I was considering adding a /libs folder to rust-analyzer top-level directory, to store things which are used as crates.io packages and moving rowan, smol_str, text_size and ungrammar there.

What stops me is the accidental complexity of CI. Sadly, rust-analyzer does quite a bit in .github/workflows, and I am not a fan of making that even more complicated...

@Veykril
Copy link
Member Author

Veykril commented Dec 16, 2020

I think having polyrepo here is fine, the only problem should be ungrammar shouldn't it, as adding to the rust ungrammar is always a breaking change for RA I think in regards to how its syntax generation works with the SRC_KINDS constant?

Copy link
Member

@matklad matklad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

Comment on lines 380 to +381
EffectExpr =
Attr* Label? ('try' | 'unsafe' | 'async') BlockExpr
Attr* Label? ('try' | 'unsafe' | 'async' | 'const') BlockExpr
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh, I am still unsure about this structure...

@bors
Copy link
Contributor

bors bot commented Dec 23, 2020

Build succeeded:

@bors bors bot merged commit 5670143 into rust-analyzer:master Dec 23, 2020
bors bot added a commit to rust-lang/rust-analyzer that referenced this pull request Dec 23, 2020
7010: Update ungrammar for const block patterns r=matklad a=Veykril

Fixes #6848

Adds const blocks and const block patterns to the AST and parses them.

Blocked on rust-analyzer/ungrammar#17, will merge that PR there once this one gets the OK so I can remove the local ungrammar dependency path and fix the Cargo.lock.

Co-authored-by: Lukas Wirth <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants