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

box_syntax/pattern not supported #1412

Closed
csmoe opened this issue Jun 18, 2019 · 1 comment · Fixed by #1414
Closed

box_syntax/pattern not supported #1412

csmoe opened this issue Jun 18, 2019 · 1 comment · Fixed by #1414

Comments

@csmoe
Copy link
Member

csmoe commented Jun 18, 2019

let x: Box<i32> = box 1i32;
let box y = x;

cc rust-lang/rust#49733

csmoe added a commit to csmoe/rust-analyzer that referenced this issue Jun 18, 2019
Change-Id: I6e20e0163fa545de37226c1561b3b7103615626c
@csmoe csmoe changed the title box_syntax not supported box_syntax/pattern not supported Jun 18, 2019
bors bot added a commit that referenced this issue Jun 19, 2019
1414: fix: box_syntax/pattern r=matklad a=csmoe

Closes #1412 
r? @matklad 

Co-authored-by: csmoe <csmoe@msn.com>
@bors bors bot closed this as completed in #1414 Jun 19, 2019
@ecstatic-morse
Copy link
Contributor

ecstatic-morse commented Aug 22, 2019

@csmoe @matklad

As noted in #1722, the following code causes a parse error on the latest master. It seems like this is not fully resolved.

#![feature(box_patterns)]

let x = Some(Box::new(5));
if let Some(box i) = x { // SYNTAX_ERROR
    dbg!(i);
}

bors bot added a commit that referenced this issue Aug 22, 2019
1722: Parse `box` keyword in patterns below top-level r=matklad a=ecstatic-morse

This extends the parser to handle patterns like `if let Some(box x) = ...` where the `box` keyword is not at the top-level. The last line of the added test caused a `ParseError`. This is a variant of #1412 which was not fixed by #1414.

~~I'm not familiar with `rust-analyzer`, otherwise I would fix this as well 😄.~~

Co-authored-by: Dylan MacKenzie <ecstaticmorse@gmail.com>
bors bot added a commit that referenced this issue Aug 22, 2019
1722: Parse `box` keyword in patterns below top-level r=matklad a=ecstatic-morse

This extends the parser to handle patterns like `if let Some(box x) = ...` where the `box` keyword is not at the top-level. The last line of the added test caused a `ParseError`. This is a variant of #1412 which was not fixed by #1414.

~~I'm not familiar with `rust-analyzer`, otherwise I would fix this as well 😄.~~

Co-authored-by: Dylan MacKenzie <ecstaticmorse@gmail.com>
bors bot added a commit that referenced this issue Aug 25, 2019
1733: Parse arbitrarily complex `box` patterns. r=matklad a=ecstatic-morse

This fully resolves the pattern part of #1412 by enabling the parsing of complex `box` patterns such as:

```rust
let box Struct { box i, j: box Inner(box &x) } = todo!();
```

This introduces a new `ast::BoxPat` (in the mold of `ast::RefPat`) that gets translated to `hir::Pat::Missing`.

Co-authored-by: Dylan MacKenzie <ecstaticmorse@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants