Skip to content

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

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

fmease
Copy link
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
Member

@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
Member Author

fmease commented Jan 28, 2025

@bors r=compiler-errors

@bors
Copy link
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
6 checks passed
@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
# for free to join this conversation on GitHub. Already have an account? # 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