-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Conversation
scope 1 { | ||
debug x => const 2_u32 is 1..=; | ||
scope 2 { | ||
debug y => const 0_u32 is 1..=; |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
r? compiler-errors @bors r+ rollup |
tests/mir-opt/pattern_types.rs
Outdated
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..=} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
…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
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
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
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
avoid falling through to the fallback rendering that just does a hex dump
r? @scottmcm
best reviewed commit by commit