Skip to content

GCI: Don't try to eval / collect mono items inside overly generic free const items#136168

Merged
bors merged 1 commit intorust-lang:masterfrom
fmease:gci-fix-mono
Jan 29, 2025
Merged

GCI: Don't try to eval / collect mono items inside overly generic free const items#136168
bors merged 1 commit intorust-lang:masterfrom
fmease:gci-fix-mono

Conversation

@fmease
Copy link
Copy Markdown
Member

@fmease fmease commented Jan 28, 2025

Fixes #136156. Thanks for the pointers, errs!

There's one (preexisting) thing of note (maybe?). There's a difference between const _: () = panic!(); and const _<'a>: () = panic!();: The former is a pre-mono error, the latter is a post-mono error. For comparison, both fn _f() { const { panic!() } } and fn _f<'a: 'a>() { const { panic!() } } are post-mono errors.

cc @oli-obk
r? compiler-errors or reassign

@fmease fmease added the F-generic_const_items `#![feature(generic_const_items)]` label Jan 28, 2025
@rustbot rustbot added 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. labels Jan 28, 2025
@fmease fmease changed the title GCI: Don't try to collect mono items inside overly generic free const items GCI: Don't try eval / collect mono items inside overly generic free const items Jan 28, 2025
Copy link
Copy Markdown
Contributor

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

r=me when green

There's a difference between const _: () = panic!(); and const _<'a>: () = panic!();: The former is a pre-mono error, the latter is a post-mono error.

This seems inconsistent, and pretty bad. But luckily something we can change before stabilizing generic consts :)

I think we should probably change the code introduced in #121387 to instead call requires_monomorphization instead of is_empty on the generics.

It should also preferably check for impossible predicates in the same way we do for -Clink-dead-code/-Zcollect-mono-items=eager, since we must avoid monomorphizing consts with impossible (possibly trivial) preds. You could probably turn that into an ICE today.

You can feel free to do this in a separate PR, since it may cause some perf changes. Maybe open a follow-up issue for this?

@fmease fmease changed the title GCI: Don't try eval / collect mono items inside overly generic free const items GCI: Don't try to eval / collect mono items inside overly generic free const items Jan 28, 2025
@fmease
Copy link
Copy Markdown
Member Author

fmease commented Jan 28, 2025

@bors r=compiler-errors

@bors
Copy link
Copy Markdown
Collaborator

bors commented Jan 28, 2025

📌 Commit 0a9ee02 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 28, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 29, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang#136121 (Deduplicate operand creation between scalars, non-scalars and string patterns)
 - rust-lang#136134 (Fix SIMD codegen tests on LLVM 20)
 - rust-lang#136153 (Locate asan-odr-win with other sanitizer tests)
 - rust-lang#136161 (rustdoc: add nobuild typescript checking to our JS)
 - rust-lang#136166 (interpret: is_alloc_live: check global allocs last)
 - rust-lang#136168 (GCI: Don't try to eval / collect mono items inside overly generic free const items)
 - rust-lang#136170 (Reject unsound toggling of Arm atomics-32 target feature)
 - rust-lang#136176 (Render pattern types nicely in mir dumps)
 - rust-lang#136186 (uefi: process: Fix args)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 29, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang#136121 (Deduplicate operand creation between scalars, non-scalars and string patterns)
 - rust-lang#136134 (Fix SIMD codegen tests on LLVM 20)
 - rust-lang#136153 (Locate asan-odr-win with other sanitizer tests)
 - rust-lang#136161 (rustdoc: add nobuild typescript checking to our JS)
 - rust-lang#136166 (interpret: is_alloc_live: check global allocs last)
 - rust-lang#136168 (GCI: Don't try to eval / collect mono items inside overly generic free const items)
 - rust-lang#136170 (Reject unsound toggling of Arm atomics-32 target feature)
 - rust-lang#136176 (Render pattern types nicely in mir dumps)
 - rust-lang#136186 (uefi: process: Fix args)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit e37b744 into rust-lang:master Jan 29, 2025
@rustbot rustbot added this to the 1.86.0 milestone Jan 29, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 29, 2025
Rollup merge of rust-lang#136168 - fmease:gci-fix-mono, r=compiler-errors

GCI: Don't try to eval / collect mono items inside overly generic free const items

Fixes rust-lang#136156. Thanks for the pointers, errs!

There's one (preexisting) thing of note (maybe?). There's a difference between `const _: () = panic!();` and `const _<'a>: () = panic!();`: The former is a pre-mono error, the latter is a post-mono error. For comparison, both `fn _f() { const { panic!() } }` and `fn _f<'a: 'a>() { const { panic!() } }` are post-mono errors.

cc `@oli-obk`
r? compiler-errors or reassign
@fmease fmease deleted the gci-fix-mono branch January 29, 2025 15:28
github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this pull request Mar 11, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang#136121 (Deduplicate operand creation between scalars, non-scalars and string patterns)
 - rust-lang#136134 (Fix SIMD codegen tests on LLVM 20)
 - rust-lang#136153 (Locate asan-odr-win with other sanitizer tests)
 - rust-lang#136161 (rustdoc: add nobuild typescript checking to our JS)
 - rust-lang#136166 (interpret: is_alloc_live: check global allocs last)
 - rust-lang#136168 (GCI: Don't try to eval / collect mono items inside overly generic free const items)
 - rust-lang#136170 (Reject unsound toggling of Arm atomics-32 target feature)
 - rust-lang#136176 (Render pattern types nicely in mir dumps)
 - rust-lang#136186 (uefi: process: Fix args)

r? `@ghost`
`@rustbot` modify labels: rollup
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 7, 2026
GCI: During reachability analysis don't try to evaluate the initializer of overly generic free const items

We generally don't want the initializer of free const items to get evaluated if they have any non-lifetime generic parameters. However, while I did account for that in HIR analysis & mono item collection (rust-lang#136168 & rust-lang#136429), I didn't account for reachability analysis so far which means that on main we still evaluate such items if they are *public* for example.

The closed PR rust-lang#142293 from a year ago did address that as a byproduct but of course it wasn't merged since its primary goal was misguided. This PR extracts & improves upon the relevant parts of that PR which are necessary to fix said issue.

Follow up to rust-lang#136168 & rust-lang#136429.
Partially supersedes rust-lang#142293.
Part of rust-lang#113521.

r? @BoxyUwU
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 7, 2026
GCI: During reachability analysis don't try to evaluate the initializer of overly generic free const items

We generally don't want the initializer of free const items to get evaluated if they have any non-lifetime generic parameters. However, while I did account for that in HIR analysis & mono item collection (rust-lang#136168 & rust-lang#136429), I didn't account for reachability analysis so far which means that on main we still evaluate such items if they are *public* for example.

The closed PR rust-lang#142293 from a year ago did address that as a byproduct but of course it wasn't merged since its primary goal was misguided. This PR extracts & improves upon the relevant parts of that PR which are necessary to fix said issue.

Follow up to rust-lang#136168 & rust-lang#136429.
Partially supersedes rust-lang#142293.
Part of rust-lang#113521.

r? @BoxyUwU
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 7, 2026
GCI: During reachability analysis don't try to evaluate the initializer of overly generic free const items

We generally don't want the initializer of free const items to get evaluated if they have any non-lifetime generic parameters. However, while I did account for that in HIR analysis & mono item collection (rust-lang#136168 & rust-lang#136429), I didn't account for reachability analysis so far which means that on main we still evaluate such items if they are *public* for example.

The closed PR rust-lang#142293 from a year ago did address that as a byproduct but of course it wasn't merged since its primary goal was misguided. This PR extracts & improves upon the relevant parts of that PR which are necessary to fix said issue.

Follow up to rust-lang#136168 & rust-lang#136429.
Partially supersedes rust-lang#142293.
Part of rust-lang#113521.

r? @BoxyUwU
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 7, 2026
GCI: During reachability analysis don't try to evaluate the initializer of overly generic free const items

We generally don't want the initializer of free const items to get evaluated if they have any non-lifetime generic parameters. However, while I did account for that in HIR analysis & mono item collection (rust-lang#136168 & rust-lang#136429), I didn't account for reachability analysis so far which means that on main we still evaluate such items if they are *public* for example.

The closed PR rust-lang#142293 from a year ago did address that as a byproduct but of course it wasn't merged since its primary goal was misguided. This PR extracts & improves upon the relevant parts of that PR which are necessary to fix said issue.

Follow up to rust-lang#136168 & rust-lang#136429.
Partially supersedes rust-lang#142293.
Part of rust-lang#113521.

r? @BoxyUwU
rust-timer added a commit that referenced this pull request Apr 7, 2026
Rollup merge of #153269 - fmease:gci-reach-no-eval, r=BoxyUwU

GCI: During reachability analysis don't try to evaluate the initializer of overly generic free const items

We generally don't want the initializer of free const items to get evaluated if they have any non-lifetime generic parameters. However, while I did account for that in HIR analysis & mono item collection (#136168 & #136429), I didn't account for reachability analysis so far which means that on main we still evaluate such items if they are *public* for example.

The closed PR #142293 from a year ago did address that as a byproduct but of course it wasn't merged since its primary goal was misguided. This PR extracts & improves upon the relevant parts of that PR which are necessary to fix said issue.

Follow up to #136168 & #136429.
Partially supersedes #142293.
Part of #113521.

r? @BoxyUwU
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Apr 8, 2026
GCI: During reachability analysis don't try to evaluate the initializer of overly generic free const items

We generally don't want the initializer of free const items to get evaluated if they have any non-lifetime generic parameters. However, while I did account for that in HIR analysis & mono item collection (rust-lang/rust#136168 & rust-lang/rust#136429), I didn't account for reachability analysis so far which means that on main we still evaluate such items if they are *public* for example.

The closed PR rust-lang/rust#142293 from a year ago did address that as a byproduct but of course it wasn't merged since its primary goal was misguided. This PR extracts & improves upon the relevant parts of that PR which are necessary to fix said issue.

Follow up to rust-lang/rust#136168 & rust-lang/rust#136429.
Partially supersedes rust-lang/rust#142293.
Part of rust-lang/rust#113521.

r? @BoxyUwU
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)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

Development

Successfully merging this pull request may close these issues.

generic_const_items: Generic function pointer leads to ICEs during codegen

4 participants