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

Implement destructuring assignment for structs and slices #78836

Merged
merged 1 commit into from
Nov 13, 2020

Conversation

fanzier
Copy link
Contributor

@fanzier fanzier commented Nov 7, 2020

This is the second step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: #71126). This PR is the second part of #71156, which was split up to allow for easier review.

Note that the first PR (#78748) is not merged yet, so it is included as the first commit in this one. I thought this would allow the review to start earlier because I have some time this weekend to respond to reviews. If @petrochenkov prefers to wait until the first PR is merged, I totally understand, of course.

This PR implements destructuring assignment for (tuple) structs and slices. In order to do this, the following parser change was necessary: struct expressions are not required to have a base expression, i.e. Struct { a: 1, .. } becomes legal (in order to act like a struct pattern).

Unfortunately, this PR slightly regresses the diagnostics implemented in #77283. However, it is only a missing help message in src/test/ui/issues/issue-77218.rs. Other instances of this diagnostic are not affected. Since I don't exactly understand how this help message works and how to fix it yet, I was hoping it's OK to regress this temporarily and fix it in a follow-up PR.

Thanks to @varkor who helped with the implementation, particularly around the struct rest changes.

r? @petrochenkov

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 7, 2020
@fanzier fanzier force-pushed the struct-and-slice-destructuring branch from 0396638 to e562723 Compare November 7, 2020 16:39
compiler/rustc_ast/src/visit.rs Show resolved Hide resolved
compiler/rustc_parse/src/parser/expr.rs Outdated Show resolved Hide resolved
compiler/rustc_ast_lowering/src/expr.rs Outdated Show resolved Hide resolved
compiler/rustc_ast_lowering/src/expr.rs Outdated Show resolved Hide resolved
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 7, 2020
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 8, 2020
compiler/rustc_ast_lowering/src/expr.rs Outdated Show resolved Hide resolved
compiler/rustc_ast_lowering/src/expr.rs Outdated Show resolved Hide resolved
@petrochenkov
Copy link
Contributor

petrochenkov commented Nov 9, 2020

Also, #78748 has been merged, so this can be rebased.

(Some GitHub tools like marking files as reviewed don't really work on individual commits, only on whole PRs, so reviewing PRs based on other PRs is harder.)

@fanzier fanzier force-pushed the struct-and-slice-destructuring branch from fa3f32f to 547603f Compare November 11, 2020 00:16
@petrochenkov
Copy link
Contributor

r=me after addressing #78836 (comment), updating failing UI tests and squashing commits.

@fanzier
Copy link
Contributor Author

fanzier commented Nov 11, 2020

Great! I'll squash as soon as CI passes.

Co-authored-by: varkor <github@varkor.com>
@fanzier fanzier force-pushed the struct-and-slice-destructuring branch from 9c976a5 to de84ad9 Compare November 11, 2020 12:11
@fanzier
Copy link
Contributor Author

fanzier commented Nov 11, 2020

Just squashed, should be ready for approval.

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Nov 11, 2020

📌 Commit de84ad9 has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 11, 2020
@bors
Copy link
Contributor

bors commented Nov 12, 2020

⌛ Testing commit de84ad9 with merge 9ecbbfae550c6d172d4ea7c9306f0c7c7db0f7d2...

@bors
Copy link
Contributor

bors commented Nov 12, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 12, 2020
@kennytm
Copy link
Member

kennytm commented Nov 12, 2020

rust-lang/cargo#8517 cc @jyn514

@jyn514
Copy link
Member

jyn514 commented Nov 12, 2020

Not much I can do, sorry. See https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/pinging.20for.20zlib.20error for what's going on.

@kennytm
Copy link
Member

kennytm commented Nov 12, 2020

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 12, 2020
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Nov 12, 2020
…ing, r=petrochenkov

Implement destructuring assignment for structs and slices

This is the second step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: rust-lang#71126). This PR is the second part of rust-lang#71156, which was split up to allow for easier review.

Note that the first PR (rust-lang#78748) is not merged yet, so it is included as the first commit in this one. I thought this would allow the review to start earlier because I have some time this weekend to respond to reviews. If `@petrochenkov` prefers to wait until the first PR is merged, I totally understand, of course.

This PR implements destructuring assignment for (tuple) structs and slices. In order to do this, the following *parser change* was necessary: struct expressions are not required to have a base expression, i.e. `Struct { a: 1, .. }` becomes legal (in order to act like a struct pattern).

Unfortunately, this PR slightly regresses the diagnostics implemented in rust-lang#77283. However, it is only a missing help message in `src/test/ui/issues/issue-77218.rs`. Other instances of this diagnostic are not affected. Since I don't exactly understand how this help message works and how to fix it yet, I was hoping it's OK to regress this temporarily and fix it in a follow-up PR.

Thanks to `@varkor` who helped with the implementation, particularly around the struct rest changes.

r? `@petrochenkov`
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 12, 2020
Rollup of 7 pull requests

Successful merges:

 - rust-lang#76730 (Fix rustdoc rendering of by-value mutable arguments in async fn)
 - rust-lang#78836 (Implement destructuring assignment for structs and slices)
 - rust-lang#78857 (Improve BinaryHeap performance)
 - rust-lang#78950 (Add asm register information for SPIR-V)
 - rust-lang#78970 (update rustfmt to v1.4.25)
 - rust-lang#78972 (Update cargo)
 - rust-lang#78987 (extend min_const_generics param ty tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 755dd14 into rust-lang:master Nov 13, 2020
@rustbot rustbot added this to the 1.49.0 milestone Nov 13, 2020
@varkor varkor added the F-destructuring_assignment `#![feature(destructuring_assignment)]` label Nov 19, 2020
flip1995 pushed a commit to flip1995/rust that referenced this pull request Nov 20, 2020
…ing, r=petrochenkov

Implement destructuring assignment for structs and slices

This is the second step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: rust-lang#71126). This PR is the second part of rust-lang#71156, which was split up to allow for easier review.

Note that the first PR (rust-lang#78748) is not merged yet, so it is included as the first commit in this one. I thought this would allow the review to start earlier because I have some time this weekend to respond to reviews. If ``@petrochenkov`` prefers to wait until the first PR is merged, I totally understand, of course.

This PR implements destructuring assignment for (tuple) structs and slices. In order to do this, the following *parser change* was necessary: struct expressions are not required to have a base expression, i.e. `Struct { a: 1, .. }` becomes legal (in order to act like a struct pattern).

Unfortunately, this PR slightly regresses the diagnostics implemented in rust-lang#77283. However, it is only a missing help message in `src/test/ui/issues/issue-77218.rs`. Other instances of this diagnostic are not affected. Since I don't exactly understand how this help message works and how to fix it yet, I was hoping it's OK to regress this temporarily and fix it in a follow-up PR.

Thanks to ``@varkor`` who helped with the implementation, particularly around the struct rest changes.

r? ``@petrochenkov``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-destructuring_assignment `#![feature(destructuring_assignment)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants