-
Notifications
You must be signed in to change notification settings - Fork 496
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
Say that ...
range patterns are rejected in the 2021 edition
#1114
Conversation
src/patterns.md
Outdated
@@ -535,6 +533,8 @@ minimum to maximum value. The range of values for a `char` type are precisely th | |||
ranges containing all Unicode Scalar Values: `'\u{0000}'..='\u{D7FF}'` and | |||
`'\u{E000}'..='\u{10FFFF}'`. | |||
|
|||
> **Edition Differences**: Before the 2021 edition, closed range patterns may be written using `...` in place of `..=`, with the same meaning. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify that before the 2021 edition ..=
is also allowed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reworded in b83fcc1
Thanks for the PR! The |
I've added a footnote. I'm not sure anything currently defines whether this rule is considered to be part of the grammar or something that happens after parsing: I don't know a way to make rustc distinguish these cases. As far as the implementation is concerned, I see rust-lang/wg-grammar#6 and rust-lang/wg-grammar#41 have been left unsettled. Out of interest, I checked what |
60f2ae8
to
b83fcc1
Compare
I'm sorry, I misremembered how that was implemented. I went ahead and removed the last commit, since I was mistaken about how this works. I was thinking this was done in the parser. From a language perspective, you can test how parsing works via macros, or using false macro_rules! pat {
($e:pat) => {};
}
#[cfg(FALSE)]
fn f(x: i32) {
match x {
1...2 => {}
}
}
fn main() {
pat!(1...2);
} The idea for the grammar in the reference is to capture what ends up in the AST, which is relevant to macros and expansion. As for how this is actually implemented, the key part is here where the lint is defined with |
Update books ## nomicon 1 commits in 49681ea4a9fa81173dbe9ffed74b4d4a35eae9e3..c05c452b36358821bf4122f9c418674edd1d713d 2021-11-24 16:27:28 +0900 to 2021-12-13 15:23:48 +0900 - Update the guidance on uninitialized data with ptr::addr_of_mut (rust-lang/nomicon#325) ## reference 3 commits in 954f3d441ad880737a13e241108f791a4d2a38cd..06f9e61931bcf58b91dfe6c924057e42ce273ee1 2021-11-29 11:11:30 -0800 to 2021-12-17 07:31:40 -0800 - keep consistent for primitive types (rust-lang/reference#1118) - README.md: link to mdbook docs (rust-lang/reference#1117) - Say that `...` range patterns are rejected in the 2021 edition (rust-lang/reference#1114) ## book 4 commits in 5f9358faeb1f46e19b8a23a21e79fd7fe150491e..8a0bb3c96e71927b80fa2286d7a5a5f2547c6aa4 2021-12-05 21:33:16 -0500 to 2021-12-22 20:54:27 -0500 - Propagate edits back - Fix number disagreement. Fixes rust-lang/book#2858. - Wrap some code in main to make scopes clearer. Fixes rust-lang/book#2830. - Respond to ch5 nostarch edits ## rustc-dev-guide 9 commits in a374e7d..9bf0028 2021-12-03 09:26:47 -0800 to 2021-12-20 21:53:57 +0900 - remove rustfix item in test intro (rust-lang/rustc-dev-guide#1277) - Move date-check comment to fix Markdown syntax - Update humor docs for special-casing ferris emoji - Fix some broken links (rust-lang/rustc-dev-guide#1274) - Update rustdoc internals - Update HIR chapter to use `HirId` instead of `NodeId` - Fix some broken links - Update src/getting-started.md - Improve documentation on r?
Corresponding issue is #1071