Render pattern types nicely in mir dumps by oli-obk · Pull Request #136176 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation6 Commits2 Checks6 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
avoid falling through to the fallback rendering that just does a hex dump
r? @scottmcm
best reviewed commit by commit
rustbot added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
scope 1 { |
---|
debug x => const 2_u32 is 1..=; |
scope 2 { |
debug y => const 0_u32 is 1..=; |
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.
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
📌 Commit fd6713f has been approved by compiler-errors
It is now in the queue for this repository.
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
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..=} |
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?
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
…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
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
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
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request
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
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request
Pretty print pattern type values with transmute if they don't satisfy their pattern
Instead of printing 0_u32 is 1..
, we now print the default fallback rendering that we also use for invalid bools, chars, ...: {transmute(0x00000000): (u32) is 1..=}
.
These cases can occur in mir dumps when const prop propagates a constant across a safety check that would prevent the actually UB value from existing. That's fine though, as it's dead code and we always need to allow UB in dead code.
follow-up to rust-lang#136176
cc @compiler-errors
@scottmcm
r? @RalfJung
because of the interpreter changes
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request
Pretty print pattern type values with transmute if they don't satisfy their pattern
Instead of printing 0_u32 is 1..
, we now print the default fallback rendering that we also use for invalid bools, chars, ...: {transmute(0x00000000): (u32) is 1..=}
.
These cases can occur in mir dumps when const prop propagates a constant across a safety check that would prevent the actually UB value from existing. That's fine though, as it's dead code and we always need to allow UB in dead code.
follow-up to rust-lang#136176
cc @compiler-errors
@scottmcm
r? @RalfJung
because of the interpreter changes
jieyouxu added a commit to jieyouxu/rust that referenced this pull request
Pretty print pattern type values with transmute if they don't satisfy their pattern
Instead of printing 0_u32 is 1..
, we now print the default fallback rendering that we also use for invalid bools, chars, ...: {transmute(0x00000000): (u32) is 1..=}
.
These cases can occur in mir dumps when const prop propagates a constant across a safety check that would prevent the actually UB value from existing. That's fine though, as it's dead code and we always need to allow UB in dead code.
follow-up to rust-lang#136176
cc @compiler-errors
@scottmcm
r? @RalfJung
because of the interpreter changes
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request
Pretty print pattern type values with transmute if they don't satisfy their pattern
Instead of printing 0_u32 is 1..
, we now print the default fallback rendering that we also use for invalid bools, chars, ...: {transmute(0x00000000): (u32) is 1..=}
.
These cases can occur in mir dumps when const prop propagates a constant across a safety check that would prevent the actually UB value from existing. That's fine though, as it's dead code and we always need to allow UB in dead code.
follow-up to rust-lang#136176
cc @compiler-errors
@scottmcm
r? @RalfJung
because of the interpreter changes
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request
Pretty print pattern type values with transmute if they don't satisfy their pattern
Instead of printing 0_u32 is 1..
, we now print the default fallback rendering that we also use for invalid bools, chars, ...: {transmute(0x00000000): (u32) is 1..=}
.
These cases can occur in mir dumps when const prop propagates a constant across a safety check that would prevent the actually UB value from existing. That's fine though, as it's dead code and we always need to allow UB in dead code.
follow-up to rust-lang#136176
cc @compiler-errors
@scottmcm
r? @RalfJung
because of the interpreter changes
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request
Rollup merge of rust-lang#136235 - oli-obk:transmuty-pat-tys, r=RalfJung
Pretty print pattern type values with transmute if they don't satisfy their pattern
Instead of printing 0_u32 is 1..
, we now print the default fallback rendering that we also use for invalid bools, chars, ...: {transmute(0x00000000): (u32) is 1..=}
.
These cases can occur in mir dumps when const prop propagates a constant across a safety check that would prevent the actually UB value from existing. That's fine though, as it's dead code and we always need to allow UB in dead code.
follow-up to rust-lang#136176
cc @compiler-errors
@scottmcm
r? @RalfJung
because of the interpreter changes
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request
Pretty print pattern type values with transmute if they don't satisfy their pattern
Instead of printing 0_u32 is 1..
, we now print the default fallback rendering that we also use for invalid bools, chars, ...: {transmute(0x00000000): (u32) is 1..=}
.
These cases can occur in mir dumps when const prop propagates a constant across a safety check that would prevent the actually UB value from existing. That's fine though, as it's dead code and we always need to allow UB in dead code.
follow-up to rust-lang/rust#136176
cc @compiler-errors
@scottmcm
r? @RalfJung
because of the interpreter changes
github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this pull request
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
Labels
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Relevant to the compiler team, which will review and decide on the PR/issue.