Skip to content

Rearrange the generics chapter#2165

Open
ehuss wants to merge 24 commits intorust-lang:masterfrom
ehuss:generics
Open

Rearrange the generics chapter#2165
ehuss wants to merge 24 commits intorust-lang:masterfrom
ehuss:generics

Conversation

@ehuss
Copy link
Copy Markdown
Contributor

@ehuss ehuss commented Feb 10, 2026

This rearranges things so that there is a comprehensive "Generics" chapter under "Types" that covers the various aspects of generics. The general outline is:

  • Generics moved out of "Items" and into "Types". Although generics are defined in items, it really belongs in the type system chapter, since generics themselves are not items.
  • Moved where clauses to the "Trait and lifetime bounds" chapter because where clauses are more closely aligned with bounds.
  • Created a "Generic arguments" section, and moved some of the generic argument rules there.
  • Created dedicated sub-chapters for lifetimes, types, and const.

There's a little more reworking such as mentioned in #925 about reworking the "Generic functions", but I didn't feel like doing more extensive rewriting at this time.

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Feb 10, 2026
@ehuss ehuss marked this pull request as draft February 12, 2026 02:12
@rustbot rustbot removed the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Feb 12, 2026
@rustbot

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. label Apr 7, 2026
@ehuss ehuss marked this pull request as ready for review May 4, 2026 23:45
@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label May 4, 2026
@ehuss
Copy link
Copy Markdown
Contributor Author

ehuss commented May 4, 2026

I have pushed up some updates and I think this is now ready for review. I ultimately decided to go ahead and move each generic kind into a dedicated chapter, even though the current content is a bare-bones skeleton.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

ehuss added 16 commits May 6, 2026 06:28
Preparing to split into multiple subchapters.
This makes some small editorial and rule name updates to prepare
the Generics chapter for having separate sections on parameters,
arguments, and the different generic kinds.
Organizationally I think it makes more sense, since this chapter is all
about defining bounds.
This follows the intended style that intros come first in a section.
This moves the generic args so that the Generics chapter is whole, and
covers all the aspects of generics.
This is just cleanup for clarity, and being more direct on what exactly
they are.
This may not be terribly useful, but it felt awkward not having
something here.
This rewrites the intro to be a little more precise about the different
kinds of arguments.
This will cover the rules specific to arguments.
This moves generics.arguments.complex-const-params and
generics.const.argument.const-expr to the const arguments section.

These rules have been reworked to simplify how they are presented.
…tion

Move this rule to the arguments section since it is pertaining to
arguments.
This adds a whole section describing how generic arguments are matched
with their parameters.
This adds some rules explaining the basics of this. Of course the actual
inference algorithm should eventually be described.
This adds a section with rules describing associated item constraints.

I'm not 100% certain this is the best chapter layout to place this
section. Perhaps it should go somewhere else?

I have intentionally used the terminology "associated item constraint"
even though it is currently only *types* that are constrained. My
intention is that once MCGA is stabilized, it will also include consts.
ehuss added 8 commits May 6, 2026 06:30
Attributes can go on any kind of generic parameter
This was stabilized in 1.37 (via
rust-lang/rust#61547), but the documentation
here was never updated.

There is a longer history of these being stabilized and then `cfg` being
removed and then added again, see
rust-lang/rust#48848
rust-lang/rust#51279
rust-lang/rust#51283.
This is only a bare-bones skeleton. The intent is that this should get
filled out with more rules specific to generic lifetimes.
This is only a bare-bones skeleton. The intent is that this should get
filled out with more rules specific to generic types.
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 6, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. S-waiting-on-review Status: The marked PR is awaiting review from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants