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

Document destructuring assignment #1116

Merged
merged 4 commits into from
Jan 17, 2022

Conversation

varkor
Copy link
Member

@varkor varkor commented Dec 11, 2021

Adds documentation for the destructuring_assignment feature (rust-lang/rust#71126), which is accepted for stabilisation (rust-lang/rust#90521). The documentation is based on the RFC text.

@ehuss ehuss added the S-waiting-on-stabilization Waiting for a stabilization PR to be merged in the main Rust repository label Dec 11, 2021
Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

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

TYVM for the PR!

src/SUMMARY.md Outdated Show resolved Hide resolved
src/expressions/operator-expr.md Outdated Show resolved Hide resolved
src/expressions/operator-expr.md Outdated Show resolved Hide resolved
src/expressions/operator-expr.md Outdated Show resolved Hide resolved
src/expressions/operator-expr.md Outdated Show resolved Hide resolved
src/expressions/underscore-expr.md Outdated Show resolved Hide resolved
src/expressions/underscore-expr.md Outdated Show resolved Hide resolved
src/expressions/underscore-expr.md Outdated Show resolved Hide resolved
@ehuss
Copy link
Contributor

ehuss commented Dec 13, 2021

I'm a bit confused about the interaction of the underscore expression and macro_rules. The following doesn't seem to work for me:

#![feature(destructuring_assignment)]

macro_rules! expr {
    ($e:expr) => {};
}

fn f() {
    expr!(_);
}

Is there some uniqueness about the underscore expression that prevents it from being used directly as an expr fragment? It seems to work OK if inside some other expression (like expr!((_));). If this is intended, then I think a footnote or something should be added to the metavariables section.

@petrochenkov
Copy link
Contributor

I'm a bit confused about the interaction of the underscore expression and macro_rules

It's all due to backward compatibility, for example _ is also a (keyword) identifier, but it doesn't match ident in macro_rules.
Every time we add something to Rust grammar proper we have to add exceptions to macro_rules matchers due to compatibility (unless the case is obscure and no breakage is found by crater).
cc rust-lang/lang-team#111

@varkor
Copy link
Member Author

varkor commented Dec 15, 2021

destructuring_assignment has now been stabilised (rust-lang/rust#90521), so I will update this issue soon with the requested changes.

@varkor
Copy link
Member Author

varkor commented Dec 25, 2021

I've updated the pull request with the requested changes.

@ehuss ehuss removed the S-waiting-on-stabilization Waiting for a stabilization PR to be merged in the main Rust repository label Dec 28, 2021
src/macros-by-example.md Outdated Show resolved Hide resolved
@ehuss
Copy link
Contributor

ehuss commented Jan 13, 2022

ping @varkor Just checking in to see if you had any questions, and if you can resolve the conflicts and address the final review comment.

@varkor
Copy link
Member Author

varkor commented Jan 14, 2022

@ehuss: thanks, I will do soon. I've just been in the process of moving recently, so I've been a little distracted. Will try to respond to the comments before the end of next week :)

@varkor
Copy link
Member Author

varkor commented Jan 17, 2022

I've addressed the final comment and fixed the merge conflict.

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

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

Looks great, thank you very much!

@ehuss ehuss merged commit 8474309 into rust-lang:master Jan 17, 2022
@varkor varkor deleted the destructuring-assignment branch January 17, 2022 17:27
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 19, 2022
Update books

## nomicon

1 commits in c05c452b36358821bf4122f9c418674edd1d713d..66d097d3d80e8f88c288c6879c7c2b909ecf8ad4
2021-12-13 15:23:48 +0900 to 2022-01-05 05:45:21 +0900
- Fix typo / type error in FFI code example (rust-lang/nomicon#327)

## reference

8 commits in f8ba2f12df60ee19b96de24ae5b73af3de8a446b..4dee6eb63d728ffb9e7a2ed443e9ada9275c69d2
2022-01-03 11:02:08 -0800 to 2022-01-18 09:26:33 -0800
- (minor) Remove Expression Path sub-types splits in Pattern specs (rust-lang/reference#1138)
- Document destructuring assignment (rust-lang/reference#1116)
- Document the 2021 edition changes to macros-by-example `pat` metavariables (rust-lang/reference#1135)
- Improve the documentation of macros-by-example metavariable names (rust-lang/reference#1130)
- trait-bounds.md: add pronoun 'that' (rust-lang/reference#1131)
- Say that macros-by-example `ident` metavariables can match raw identifiers (rust-lang/reference#1133)
- State in the UAX31 profile description that a lone `_` is not an identifier (rust-lang/reference#1129)
- Document syntax reserved in Rust 2021 (rust-lang/reference#1128)

## book

17 commits in d3740fb7aad0ea4a80ae20f64dee3a8cfc0c5c3c..f17df27fc14696912c48b8b7a7a8fa49e648088d
2022-01-03 21:46:04 -0500 to 2022-01-18 17:46:28 -0500
- Add a notice to the top of all nostarch snapshots
- Fix quotes
- Grammar (minor): 'or' → 'and' for enum variants
- Propagate edits of chapter 8 to src
- Replies to nostarch edits
- more edits
- ch8 from nostarch
- Fix grammar and line wrapping
- Merge remote-tracking branch 'origin/pr/2880'
- Remove wikipedia link
- Merge remote-tracking branch 'origin/pr/2927'
- Snapshot of ch14 for nostarch
- Backport fixes to chapter 14 noticed while doing nostarch snapshot
- Fix usage of find piped into xargs
- Adjust some more line numbers of Cargo.toml includes
- Merge branch '2909'
- Merge remote-tracking branch 'parkerziegler/fix/ch14-add-one-naming'

## rustc-dev-guide

7 commits in 875464457c4104686faf667f47848aa7b0f0a744..78dd6a4684cf8d6b72275fab6d0429ea40b66338
2021-12-28 22:17:49 -0600 to 2022-01-18 14:44:26 -0300
- Reorganize and expand the testing chapters. (rust-lang/rustc-dev-guide#1281)
- Add inline assembly internals (rust-lang/rustc-dev-guide#1266)
- Spelling: Rename `rust` to `Rust` (rust-lang/rustc-dev-guide#1288)
- Clean up section about FCPs (rust-lang/rustc-dev-guide#1287)
- Address more review comments in rust-lang/rustc-dev-guide#1286.
- Address review comments in rust-lang/rustc-dev-guide#1286.
- Streamline "Getting Started" some more.
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 this pull request may close these issues.

3 participants