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

Rustup #6336

Merged
merged 3 commits into from
Nov 16, 2020
Merged

Rustup #6336

merged 3 commits into from
Nov 16, 2020

Conversation

giraffate
Copy link
Contributor

changelog: none

fanzier and others added 2 commits November 14, 2020 13:53
Make `_` an expression, to discard values in destructuring assignments

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

With this PR, an underscore `_` is parsed as an expression but is allowed *only* on the left-hand side of a destructuring assignment. There it simply discards a value, similarly to the wildcard `_` in patterns. For instance,
```rust
(a, _) = (1, 2)
```
will simply assign 1 to `a` and discard the 2. Note that for consistency,
```
_ = foo
```
is also allowed and equivalent to just `foo`.

Thanks to ````@varkor```` who helped with the implementation, particularly around pre-expansion gating.

r? ````@petrochenkov````
@rust-highfive
Copy link

r? @ebroto

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 16, 2020
because comments are checked and removed by rustfmt for some reason
@giraffate
Copy link
Contributor Author

A work around by 0e80341 addressed CI error https:/rust-lang/rust-clippy/pull/6336/checks?check_run_id=1404315427. There seems to be a difference in rustfmt v1.4.26.

@flip1995
Copy link
Member

@bors r+ p=1

Thanks!

@bors
Copy link
Collaborator

bors commented Nov 16, 2020

📌 Commit 0e80341 has been approved by flip1995

@bors
Copy link
Collaborator

bors commented Nov 16, 2020

⌛ Testing commit 0e80341 with merge df3bb58...

@bors
Copy link
Collaborator

bors commented Nov 16, 2020

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing df3bb58 to master...

@bors bors merged commit df3bb58 into rust-lang:master Nov 16, 2020
@giraffate giraffate deleted the sync-from-rust branch November 18, 2020 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants