Skip to content

[STACKED] Extend support of lint explicit_outlives_requirements to (generic) const items - #164797

Draft
fmease wants to merge 6 commits into
rust-lang:mainfrom
fmease:gci-eor-lint
Draft

fmease wants to merge 6 commits into
rust-lang:mainfrom
fmease:gci-eor-lint

Conversation

@fmease

@fmease fmease commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Caution

Stacked on top of PR #143029 which itself is stacked on top of PR #164012. Empty "branch separator" commits are the boundaries.

Best reviewed by ignoring whitespace changes.

Part of #113521.

(No LLM was or will be used by me during the entire creation process of this PR)

@fmease fmease added S-blocked Status: Blocked on something else such as an RFC or other implementation work. F-generic_const_items `#![feature(generic_const_items)]` labels Oct 23, 2026
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-rustc-dev-guide Area: rustc-dev-guide S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 23, 2026
@fmease fmease removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 23, 2026
@fmease fmease moved this to In Progress in Generic Const Items (GCI) Oct 23, 2026
@fmease fmease changed the title [STACKED] Extend support of lint explict_outlives_requirement to (generic) const items [STACKED] Extend support of lint explict_outlives_requirements to (generic) const items Oct 23, 2026
@rust-bors

This comment has been minimized.

@fmease fmease changed the title [STACKED] Extend support of lint explict_outlives_requirements to (generic) const items [STACKED] Extend support of lint explicit_outlives_requirements to (generic) const items Oct 23, 2026
@rust-bors

This comment has been minimized.

In summary, rename various things & update a lot of comments.

1. Rename some types, fns that have "clause" in their name to contain
   "outlives clause" instead. While we are in a module called `outlives`,
   it's not immediately obvious & it certainly doesn't imply that all of
   these things only represent / act on outlives-clauses.
   Requested by Boxy.
2. Both `global_inferred_outlives` and `explicit_map` store a "global"
   mapping from each crate-local item to a set of outlives-clauses
   collected so far (one containing the inferred ones, the other the
   explicit ones). So name both consistently: `global_inferred_clauses`
   and `global_explicit_clauses`, respectively.
   Similarly for their types which are now prefixed with `Global`.
3. Remove a bunch of really obvious & distracting comments.
4. Reduce rightward drift in the `ty::Dynamic` match arm by using an
   if-let guard.
5. Deduplicate code shared between ADTs & CTAs in `inferred_outlives_of`
6. `bug!()` in a `GenericArgKind::Const(_)` branch which we know is
   currently unreachable and which should explode if that were to change.
7. Rename `CrateClausesMap` to `CrateInferredOutlivesClausesMap`.
   The type is public & lives in `rustc_middle` since
   `inferred_outlives_crate` is a query. Considering that, its name is
   way too general.
   Moreover, remove all of its docs. This type can only be constructed
   via query `inferred_outlives_crate` (well, and via the provider) which
   has good docs already that also warn about the fact that query
   `inferred_outlives_of` should always be used instead.
8. Remove comment "Typically there won't be many of these [explicit
   outlives clauses], except in older code where they were mandatory" is
   unnecessary and factually incorrect since there are various places
   where we don't imply (early-bound) outlives-bounds.
9. Re. comment "Visit all the crates [...]" and "[...] we walk the crates
   again [...]" is no longer correct: We only (re)visit the items in the
   local crate; the inferred outlives clauses for cross-crate items have
   already been computed and stored in the relevant crate metadata files.
10. Fix the example given in `check_explicit_clauses`'s docs, it has
    several issues: Struct `Outer` gets used as a trait bound, it uses
    `...: 'static` bounds and states they get processed but as a matter
    of fact we don't process static bounds, we specifically only infer
    clauses where the LHS is early-bound!
11. Various minor code tweaks.
@fmease fmease mentioned this pull request Nov 12, 2026
1 of 7 tasks

This branch has not been deployed

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

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-rustc-dev-guide Area: rustc-dev-guide F-generic_const_items `#![feature(generic_const_items)]` S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants