Skip to content
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

Render pattern types nicely in mir dumps #136176

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jan 28, 2025

avoid falling through to the fallback rendering that just does a hex dump

r? @scottmcm

best reviewed commit by commit

@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
scope 1 {
debug x => const 2_u32 is 1..=;
scope 2 {
debug y => const 0_u32 is 1..=;
Copy link
Contributor Author

@oli-obk oli-obk Jan 28, 2025

Choose a reason for hiding this comment

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

This one is fun. We do render as transmute for other things that are invalid (e.g. chars that aren't valid chars, or bools that aren't 0 or 1), but it's harder to do this here without running validation on it... and I'm not sure all the extra logic for doing so would be worth it.

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.

Would be nice if we had some way of statically validating that a ScalarInt is valid in a Layout for this exact check (and it may be useful elsewhere in the compiler).

But looks fine for now.

@compiler-errors
Copy link
Member

r? compiler-errors @bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 28, 2025

📌 Commit fd6713f has been approved by compiler-errors

It is now in the queue for this repository.

@rustbot rustbot assigned compiler-errors and unassigned scottmcm Jan 28, 2025
@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
fn main() {
// CHECK: debug x => const {transmute(0x00000002): (u32) is 1..=}
let x: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(2) };
// CHECK: debug y => const {transmute(0x00000000): (u32) is 1..=}
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, definitely interesting. I guess this is falling under the "compilation doesn't have to detect UB" rule?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well... we kinda do because there could be no UB, just const prop crossing a check that prevents UB. So this could happen in dead code. So there is an argument for showing that in pretty printing. I'll see if I can pull out the logic we use in const validation in a way that makes it reusable here

Zalathar added a commit to Zalathar/rust that referenced this pull request Jan 29, 2025
…ompiler-errors

Render pattern types nicely in mir dumps

avoid falling through to the fallback rendering that just does a hex dump

r? `@scottmcm`

best reviewed commit by commit
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 f49ad60 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#136176 - oli-obk:pattern-type-mir-opts, r=compiler-errors

Render pattern types nicely in mir dumps

avoid falling through to the fallback rendering that just does a hex dump

r? ``@scottmcm``

best reviewed commit by commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
None yet
Development

Successfully merging this pull request may close these issues.

5 participants