Skip to content

[early rough draft] GCI: Don't evaluate free const items with impossible predicates #142293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fmease
Copy link
Member

@fmease fmease commented Jun 10, 2025

No description provided.

@fmease fmease added the F-generic_const_items `#![feature(generic_const_items)]` label Jun 10, 2025
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 10, 2025
@fmease fmease changed the title [early rough draft] GCI: Don't evaluate the free const items with impossible predicates [early rough draft] GCI: Don't evaluate free const items with impossible predicates Jun 10, 2025
@fmease
Copy link
Member Author

fmease commented Jun 10, 2025

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 10, 2025

⌛ Trying commit 74ec3ea with merge 4151b9a

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

rust-bors bot added a commit that referenced this pull request Jun 10, 2025
[early rough draft] GCI: Don't evaluate free const items with impossible predicates
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 10, 2025
@fmease fmease moved this to In Progress in Generic Const Items (GCI) Jun 10, 2025
@rust-log-analyzer

This comment was marked as off-topic.

@fmease fmease added the rla-silenced Silences rust-log-analyzer postings to the PR it's added on. label Jun 10, 2025
@BoxyUwU BoxyUwU self-assigned this Jun 10, 2025
Copy link
Member Author

@fmease fmease Jun 10, 2025

Choose a reason for hiding this comment

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

This one might be dicey since we don't check requires_own_monomorization. impossible_predicates is likely wrong without it. Example by Boxy: <T> [T]: Sized.

Copy link
Member

@BoxyUwU BoxyUwU left a comment

Choose a reason for hiding this comment

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

We should consider moving all of these call-site checks into ctfe itself, e.g. eval_to_const_value_raw_provider. This wont affect const patterns which go through _for_typeck versions of the CTFE entry points.

I also then think that the impossible predicates check in that place should ICE on predicates containing non region params as that shouldn't be reachable (and if it is, then we're evaluating generic constants in places we might not want to be).

// for codegen. Everything else is only needed during const-eval, so even if
// const-eval happens in a downstream crate, all they need is
// `mir_for_ctfe`.
match self.tcx.const_eval_poly_to_alloc(item.owner_id.def_id.into()) {
Copy link
Member

Choose a reason for hiding this comment

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

This being one such place where we evaluate generic stuff where we probably oughtn't

@rust-bors
Copy link

rust-bors bot commented Jun 10, 2025

☀️ Try build successful (CI)
Build commit: 4151b9a (4151b9aaad261468f4260336981f34de2f05df15)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4151b9a): 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 (primary -5.1%, secondary -2.1%)

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)
3.5% [3.5%, 3.5%] 1
Improvements ✅
(primary)
-5.1% [-9.4%, -3.0%] 6
Improvements ✅
(secondary)
-2.3% [-4.3%, -1.1%] 21
All ❌✅ (primary) -5.1% [-9.4%, -3.0%] 6

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: 753.145s -> 753.291s (0.02%)
Artifact size: 372.18 MiB -> 372.22 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-generic_const_items `#![feature(generic_const_items)]` rla-silenced Silences rust-log-analyzer postings to the PR it's added on. 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.

5 participants