Skip to content

Rename grammar rule TypeParamBounds to just Bounds - #2258

Merged
ehuss merged 1 commit into
rust-lang:masterfrom
fmease:rn-type-param-bounds
May 6, 2026
Merged

Rename grammar rule TypeParamBounds to just Bounds#2258
ehuss merged 1 commit into
rust-lang:masterfrom
fmease:rn-type-param-bounds

Conversation

@fmease

@fmeasefmease commented May 5, 2026

Copy link
Copy Markdown
Member

I take issue with the name of grammar rule TypeParamBounds. Bounds aren't inherently tied to type parameters, they can perfectly exist without them. This name stems from an ancient time when where-clauses didn't exist yet and bounds could only be put on type parameters. Today, that is no longer true.

Consider the following program which contains bounds that aren't associated with type parameters in any way:

fnf0()wherei32:Copy{}fnf1()where[&'staticstr;10]: std::fmt::Debug{}fnf2<constN:usize>()where[String;N]:Copy{}fnf3<'a>()where&'a():Sized{}

Bounds can be placed on any type. I'd also be fine with renaming it to TypeBounds, just anything but TypeParamBounds :)

@rustbotrustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label May 5, 2026
@ehuss

ehuss commented May 5, 2026

Copy link
Copy Markdown
Contributor

Sounds reasonable to me.

Can you also update the sentence in paths.type.intro that says "type parameter bounds" and replace that with something else ("type bounds" maybe?) if that makes sense.

@fmease
fmeaseforce-pushed the rn-type-param-bounds branch from 02a79dd to cbe9a8aCompareMay 6, 2026 12:34
@fmease

Copy link
Copy Markdown
MemberAuthor

I've gone ahead and removed the mention entirely:

-Type paths are used within type definitions, trait bounds, type parameter bounds, and qualified paths.+Type paths are used within type definitions, trait bounds, and qualified paths.

That's because it was redundant anyway. Bound (formerly TypeParamBound) is defined as Lifetime | TraitBound | UseBound but TraitBound is already listed in that sentence and obviously Lifetime and UseBound don't contain TypePaths.

@fmease

fmease commented May 6, 2026

Copy link
Copy Markdown
MemberAuthor

I've also taken the liberty to rename trait-bounds.md to bounds.md since it actually describes all three kinds of bounds: Trait bounds, lifetime bounds (outlives-bounds) and use-bounds (precise capturing).

Feel free to drop that commit if you'd like to see that split off into a separate PR.

Edit: Dropped again since I forgot about URL stability and since I can't be bothered to add redirects (if you even can; I only know about the JS-driven URL fragment redirects); the Book and the rustc book both reference trait-bounds.md.

@fmease
fmeaseforce-pushed the rn-type-param-bounds branch from cbe9a8a to d6f4cc4CompareMay 6, 2026 12:38

@ehussehuss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ehuss
ehuss added this pull request to the merge queueMay 6, 2026
Merged via the queue into rust-lang:master with commit cf0e391May 6, 2026
6 checks passed
@rustbotrustbot removed the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label May 6, 2026
@fmease
fmease deleted the rn-type-param-bounds branch May 6, 2026 13:29
@rustbotrustbot mentioned this pull request May 18, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 18, 2026
Update books
## rust-lang/reference
9 commits in 581920f9109f141b88b860b3e1e8359e3896a150..ad35aca481751a06afeb23820a672b0f3b11a476
2026-05-14 17:00:42 UTC to 2026-05-04 18:27:13 UTC
- ci: declare contents:read on CI workflow (rust-lang/reference#2271)
- Fix the grammar of generic arguments (rust-lang/reference#2247)
- Rename grammar rule `TypeParamBounds` to just `Bounds` (rust-lang/reference#2258)
- Update `used` to use the attribute template (rust-lang/reference#1905)
- Place HRTB binders before fn qualifiers (rust-lang/reference#2260)
- Glossary: add new entry documenting zero-sized types (rust-lang/reference#2203)
- Fix test failure on macOS with link_section (rust-lang/reference#2246)
- Make definition of fragment specifier `path` more precise (rust-lang/reference#2248)
- gitignore linkcheck (rust-lang/reference#2252)
rust-timer added a commit to rust-lang/rust that referenced this pull request May 19, 2026
Rollup merge of #156723 - rustbot:docs-update, r=ehuss
Update books
## rust-lang/reference
9 commits in 581920f9109f141b88b860b3e1e8359e3896a150..ad35aca481751a06afeb23820a672b0f3b11a476
2026-05-14 17:00:42 UTC to 2026-05-04 18:27:13 UTC
- ci: declare contents:read on CI workflow (rust-lang/reference#2271)
- Fix the grammar of generic arguments (rust-lang/reference#2247)
- Rename grammar rule `TypeParamBounds` to just `Bounds` (rust-lang/reference#2258)
- Update `used` to use the attribute template (rust-lang/reference#1905)
- Place HRTB binders before fn qualifiers (rust-lang/reference#2260)
- Glossary: add new entry documenting zero-sized types (rust-lang/reference#2203)
- Fix test failure on macOS with link_section (rust-lang/reference#2246)
- Make definition of fragment specifier `path` more precise (rust-lang/reference#2248)
- gitignore linkcheck (rust-lang/reference#2252)
@ehussehuss added this to the 1.97.0 milestone Jun 16, 2026
Sign up for freeto 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

@fmease@ehuss@rustbot