GCI: Imply outlives-bounds on free (generic) const items#143029
GCI: Imply outlives-bounds on free (generic) const items#143029fmease wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
@bors2 try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
GCI: Imply outlives-bounds on free (generic) const items
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (eb427c5): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking 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 @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 689.033s -> 689.561s (0.08%) |
|
(All of these failures are cycle errors that now occur when we try to recover from the user using |
|
@bors2 try parent=last @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
GCI: Imply outlives-bounds on free (generic) const items Part of #113521.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (25444d3): comparison URL. Overall result: no relevant changes - no action neededBenchmarking 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 Instruction countThis 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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 689.033s -> 690.033s (0.15%) |
This comment was marked as resolved.
This comment was marked as resolved.
|
The rustc-dev-guide subtree was changed. If this PR only touches the dev guide consider submitting a PR directly to rust-lang/rustc-dev-guide otherwise thank you for updating the dev guide with your changes. |
| if tcx.generics_of(item_def_id).is_empty() { | ||
| // Fast path. | ||
| return &[]; | ||
| } |
There was a problem hiding this comment.
This fast path allowed me to turn a perf regression (#143029 (comment)) back into neutral state (#143029 (comment)).
This comment has been minimized.
This comment has been minimized.
|
Needs a trivial rebase but it's still ready for review. I'm afk now. |
|
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. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I forgot that I still had to break one more kind of query cycle. CI should be fixed now 🤞 |
There was a problem hiding this comment.
Right, I completely forgot about implementing that part of implied bounds back in June 2025. This PR should definitely be blocked on me implementing that but feel free to review the other parts already.
It should hopefully be straightforward to implement modulo perf, I just need to visit & handle ConstKind::Unevaluated in insert_outlives_predicate.
Edit: Actually it's not necessarily blocking since this is only observable under mGCA/GCE? I might just slap //@ known-bug: unknown on it 🤷
There was a problem hiding this comment.
i think not even GCE as there you'll have anon consts with the same predicates as the item its inside of. mGCA should be the only way to get a const item directly used in a type signature which has clauses that are actual useful to derive implied bounds from
|
I am... unsure of this 🤔 I need to think a bit about this conceptually. |
|
Is there a test that demonstrates the (lack of) implied bounds for associated consts? |
In |
| /// Infer outlives-predicates for the items in the local crate. | ||
| pub(super) fn infer_predicates( | ||
| tcx: TyCtxt<'_>, | ||
| ) -> FxIndexMap<DefId, ty::EarlyBinder<'_, RequiredPredicates<'_>>> { |
There was a problem hiding this comment.
can we rename this stuff to be infer_outlives_predicates and RequiredOutlivesPredicates lol
| // | ||
| // This is correct as we only ever imply outlives-predicates where the outlived | ||
| // region is early-bound ... for which the item must have generic parameters. | ||
| DefKind::Const { .. } if !tcx.generics_of(item_did).is_empty() => { |
There was a problem hiding this comment.
I could imagine for mgca wanting to imply bounds from the rhs too. e.g. const FOO<'a>: () = BAR::<'a> where BAR bounds 'a: 'static
| // | ||
| // This is correct as we only ever imply outlives-predicates where the outlived | ||
| // region is early-bound ... for which the item must have generic parameters. | ||
| DefKind::Const { .. } if !tcx.generics_of(item_did).is_empty() => { |
There was a problem hiding this comment.
where does that perf regression you were talking about actually come from? is it having this query return more stuff? would feature gating this match arm improve things too?
There was a problem hiding this comment.
also kind of generally wondering if itd be "safer" to gate this behind GCI to avoid any accidents but that seems.. unlikely to happen
|
OK makes sense to me 🤔 |
|
can you record an item on the tracking issue for GCI that we should think about implied bounds before stabilization (i.e. what kinds we want) |
|
☔ The latest upstream changes (presumably #153919) made this pull request unmergeable. Please resolve the merge conflicts. |
View all comments
Part of #113521.