-
Notifications
You must be signed in to change notification settings - Fork 530
Simplify GenericParams grammar #1795
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
Merged
traviscross
merged 2 commits into
rust-lang:master
from
joshtriplett:simplify-generic-params
Apr 17, 2025
Merged
Simplify GenericParams grammar #1795
traviscross
merged 2 commits into
rust-lang:master
from
joshtriplett:simplify-generic-params
Apr 17, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The definition of GenericParams had separate productions for the cases of zero params and one-or-more params. Merge those two cases, to make the railroad diagram clearer.
This makes it easier to read the production from left to right: a GenericParam, zero or more (comma followed by GenericParam), optional trailing comma.
traviscross
approved these changes
Apr 17, 2025
ChrisDenton
added a commit
to ChrisDenton/rust
that referenced
this pull request
Apr 22, 2025
Update books ## rust-lang/nomicon 1 commits in 0c10c30cc54736c5c194ce98c50e2de84eeb6e79..c76a20f0d987145dcedf05c5c073ce8d91f2e82a 2025-04-15 20:54:57 UTC to 2025-04-15 20:54:57 UTC - Say that dereferencing a pointer to a ZST is no longer undefined (rust-lang/nomicon#467) ## rust-lang/reference 7 commits in 3340922df189bddcbaad17dc3927d51a76bcd5ed..3bf3402aea982b876eb56c87da17b0685c6461d5 2025-04-18 13:44:45 UTC to 2025-04-17 17:27:01 UTC - Use `cfg(false)` instead of `cfg(FALSE)` (rust-lang/reference#1763) - Add `cfg(true)` and `cfg(false)` to conditional compilation (RFC 3695) (rust-lang/reference#1762) - Refactor rendering with `RenderCtx` (rust-lang/reference#1796) - attributes/codegen: update aarch64 features (rust-lang/reference#1791) - Simplify GenericParams grammar (rust-lang/reference#1795) - Add rule identifiers for the ABI chapter (rust-lang/reference#1793) - Remove broken footnote links from grammar summary (rust-lang/reference#1794)
ChrisDenton
added a commit
to ChrisDenton/rust
that referenced
this pull request
Apr 22, 2025
Update books ## rust-lang/nomicon 1 commits in 0c10c30cc54736c5c194ce98c50e2de84eeb6e79..c76a20f0d987145dcedf05c5c073ce8d91f2e82a 2025-04-15 20:54:57 UTC to 2025-04-15 20:54:57 UTC - Say that dereferencing a pointer to a ZST is no longer undefined (rust-lang/nomicon#467) ## rust-lang/reference 7 commits in 3340922df189bddcbaad17dc3927d51a76bcd5ed..3bf3402aea982b876eb56c87da17b0685c6461d5 2025-04-18 13:44:45 UTC to 2025-04-17 17:27:01 UTC - Use `cfg(false)` instead of `cfg(FALSE)` (rust-lang/reference#1763) - Add `cfg(true)` and `cfg(false)` to conditional compilation (RFC 3695) (rust-lang/reference#1762) - Refactor rendering with `RenderCtx` (rust-lang/reference#1796) - attributes/codegen: update aarch64 features (rust-lang/reference#1791) - Simplify GenericParams grammar (rust-lang/reference#1795) - Add rule identifiers for the ABI chapter (rust-lang/reference#1793) - Remove broken footnote links from grammar summary (rust-lang/reference#1794)
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 23, 2025
Rollup merge of rust-lang#140124 - rustbot:docs-update, r=ehuss Update books ## rust-lang/nomicon 1 commits in 0c10c30cc54736c5c194ce98c50e2de84eeb6e79..c76a20f0d987145dcedf05c5c073ce8d91f2e82a 2025-04-15 20:54:57 UTC to 2025-04-15 20:54:57 UTC - Say that dereferencing a pointer to a ZST is no longer undefined (rust-lang/nomicon#467) ## rust-lang/reference 7 commits in 3340922df189bddcbaad17dc3927d51a76bcd5ed..3bf3402aea982b876eb56c87da17b0685c6461d5 2025-04-18 13:44:45 UTC to 2025-04-17 17:27:01 UTC - Use `cfg(false)` instead of `cfg(FALSE)` (rust-lang/reference#1763) - Add `cfg(true)` and `cfg(false)` to conditional compilation (RFC 3695) (rust-lang/reference#1762) - Refactor rendering with `RenderCtx` (rust-lang/reference#1796) - attributes/codegen: update aarch64 features (rust-lang/reference#1791) - Simplify GenericParams grammar (rust-lang/reference#1795) - Add rule identifiers for the ABI chapter (rust-lang/reference#1793) - Remove broken footnote links from grammar summary (rust-lang/reference#1794)
github-actions bot
pushed a commit
to rust-lang/miri
that referenced
this pull request
Apr 23, 2025
Update books ## rust-lang/nomicon 1 commits in 0c10c30cc54736c5c194ce98c50e2de84eeb6e79..c76a20f0d987145dcedf05c5c073ce8d91f2e82a 2025-04-15 20:54:57 UTC to 2025-04-15 20:54:57 UTC - Say that dereferencing a pointer to a ZST is no longer undefined (rust-lang/nomicon#467) ## rust-lang/reference 7 commits in 3340922df189bddcbaad17dc3927d51a76bcd5ed..3bf3402aea982b876eb56c87da17b0685c6461d5 2025-04-18 13:44:45 UTC to 2025-04-17 17:27:01 UTC - Use `cfg(false)` instead of `cfg(FALSE)` (rust-lang/reference#1763) - Add `cfg(true)` and `cfg(false)` to conditional compilation (RFC 3695) (rust-lang/reference#1762) - Refactor rendering with `RenderCtx` (rust-lang/reference#1796) - attributes/codegen: update aarch64 features (rust-lang/reference#1791) - Simplify GenericParams grammar (rust-lang/reference#1795) - Add rule identifiers for the ABI chapter (rust-lang/reference#1793) - Remove broken footnote links from grammar summary (rust-lang/reference#1794)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When reading through the grammar, I found it surprising that GenericParams had
two separate alternatives, one for the empty case and one for the one-or-more
case. That seemed to obfuscate that GenericParams contains zero-or-more
GenericParam. This structure likely arose in order to express the optional
trailing comma correctly; however, it's possible to express that in another
way.
Rework
GenericParams
to have a single production that uses?
, which thendeduplicates the surrounding
<
and>
, and (in my opinion) simplifies thehandling of the trailing comma.