Skip to content

[STACKED] GCI: Imply outlives-bounds on free (generic) const items - #143029

Open
fmease wants to merge 4 commits into
rust-lang:mainfrom
fmease:gci-imply
Open

fmease wants to merge 4 commits into
rust-lang:mainfrom
fmease:gci-imply

Conversation

@fmease

@fmease fmease commented Jun 25, 2025 •

Copy link
Copy Markdown
Member

View all comments

Caution

Stacked on top of PR #164012. The empty "branch separator" commit is the boundary.

Part of #113521.

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

@fmease fmease added the F-generic_const_items `#![feature(generic_const_items)]` label Jun 25, 2025
@rustbot rustbot added A-rustc-dev-guide Area: rustc-dev-guide T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 25, 2025
@fmease fmease moved this to In Progress in Generic Const Items (GCI) Jun 25, 2025
@fmease

fmease commented Jun 25, 2025

Copy link
Copy Markdown
Member Author

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors Bot added a commit that referenced this pull request Jun 25, 2025
GCI: Imply outlives-bounds on free (generic) const items
@rust-bors

rust-bors Bot commented Jun 25, 2025

Copy link
Copy Markdown
Contributor

⌛ Trying commit 5aa3d2a with merge eb427c5…

To cancel the try build, run the command @bors2 try cancel.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 25, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jun 25, 2025

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: eb427c5 (eb427c5414bee321329c635f289f46816100d758, parent: d14d202262d13df896b0c624b0cec6e4bfde631a)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (eb427c5): comparison URL.

Overall result: ❌ regressions - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.2% [0.2%, 0.2%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.2%, 0.2%] 3

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 689.033s -> 689.561s (0.08%)
Artifact size: 372.09 MiB -> 372.11 MiB (0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 27, 2025
@fmease

fmease commented Jun 27, 2025 •

Copy link
Copy Markdown
Member Author

(All of these failures are cycle errors that now occur when we try to recover from the user using _ in / omitting the type of consts, this "niceness" really is the bane of my existence)

@fmease

fmease commented Jun 27, 2025

Copy link
Copy Markdown
Member Author

@bors2 try parent=last @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jun 27, 2025

Copy link
Copy Markdown
Contributor

⌛ Trying commit c2b8a0b with merge 25444d3…

To cancel the try build, run the command @bors2 try cancel.

rust-bors Bot added a commit that referenced this pull request Jun 27, 2025
GCI: Imply outlives-bounds on free (generic) const items

Part of #113521.
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 27, 2025
@fmease fmease added the rla-silenced Silences rust-log-analyzer postings to the PR it's added on. label Jun 27, 2025
@rust-bors

rust-bors Bot commented Jun 27, 2025

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 25444d3 (25444d3ddb1285d7ea04f0b89fdf4318a474d5df, parent: d14d202262d13df896b0c624b0cec6e4bfde631a)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (25444d3): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (secondary 2.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.6% [2.5%, 2.7%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 689.033s -> 690.033s (0.15%)
Artifact size: 372.09 MiB -> 372.08 MiB (-0.00%)

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Jun 28, 2025
@bors

This comment was marked as resolved.

@rustbot

This comment has been minimized.

@fmease fmease changed the title GCI: Imply outlives-bounds on free (generic) const items [STACKED] GCI: Imply outlives-bounds on free (generic) const items Oct 15, 2026
@fmease fmease added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Oct 15, 2026
@rustbot

This comment has been minimized.

@fmease

fmease commented Oct 18, 2026 •

Copy link
Copy Markdown
Member Author

This is now ready for review. However, it's still stacked on top of cleanup / refactoring PR #164012 which needs to be reviewed & merged beforehand.

What has changed since the last review?

  1. We now infer outlives bounds from const aliases (in ADT / CTA / const item signatures & const item RHSs (if direct)) addressing [STACKED] GCI: Imply outlives-bounds on free (generic) const items #143029 (comment) / [STACKED] GCI: Imply outlives-bounds on free (generic) const items #143029 (comment).
    • We don't "yet" try to infer outlives bounds from other kinds of type-system consts / direct const args like "struct literals" (ConstKind::Value where the Ty is an Adt). Last week I couldn't come up with any snippet that could observe this, nothing of that sort compiled, maybe (m)GCA isn't far enough along in this regard. In any case, I'd like to postpone it & only ship what's implemented right now
  2. Greatly improved the test coverage & quality
  3. Replied to two or your review comments about perf & soundness/robustness: [STACKED] GCI: Imply outlives-bounds on free (generic) const items #143029 (comment), [STACKED] GCI: Imply outlives-bounds on free (generic) const items #143029 (comment)

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Oct 18, 2026
@fmease

fmease commented Oct 18, 2026

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 18, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 18, 2026
[STACKED] GCI: Imply outlives-bounds on free (generic) const items
@rust-bors

rust-bors Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: ef27a0e (ef27a0e2fd3476ff2405e22d7d3b1072d6ca1bcf)
Base parent: 33295d7 (33295d734447c7a2c22c44190f11bce6164a035a)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (ef27a0e): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -3.9%, secondary 2.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.8% [0.9%, 4.8%] 6
Improvements ✅
(primary)
-3.9% [-3.9%, -3.9%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -3.9% [-3.9%, -3.9%] 1

Cycles

Results (secondary -1.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.7% [1.7%, 1.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.5% [-4.5%, -4.5%] 1
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 488.147s -> 489.834s (0.35%)
Artifact size: 408.98 MiB -> 409.08 MiB (0.02%)

@rust-bors

This comment has been minimized.

@rustbot

rustbot commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main 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.

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.

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-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

6 participants