about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-02-06 13:09:58 +0100
committerGitHub <noreply@github.com>2025-02-06 13:09:58 +0100
commit62cad970e86b00bd731226426cb259148679fbb7 (patch)
tree8ad2ef69a923d8599060c09282ee96f54f924dcd /tests
parent7ca29360a7983323c0c3a9623ba8eef0cc68e663 (diff)
parentab3115990d333b8b782f8ea062c881fda377a353 (diff)
downloadrust-62cad970e86b00bd731226426cb259148679fbb7.tar.gz
rust-62cad970e86b00bd731226426cb259148679fbb7.zip
Rollup merge of #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 https://github.com/rust-lang/rust/pull/136176

cc ``@compiler-errors`` ``@scottmcm``

r? ``@RalfJung`` because of the interpreter changes
Diffstat (limited to 'tests')
-rw-r--r--tests/mir-opt/pattern_types.main.PreCodegen.after.mir2
-rw-r--r--tests/mir-opt/pattern_types.rs2
2 files changed, 2 insertions, 2 deletions
diff --git a/tests/mir-opt/pattern_types.main.PreCodegen.after.mir b/tests/mir-opt/pattern_types.main.PreCodegen.after.mir
index 8c99902f9b8..5ff90de9615 100644
--- a/tests/mir-opt/pattern_types.main.PreCodegen.after.mir
+++ b/tests/mir-opt/pattern_types.main.PreCodegen.after.mir
@@ -5,7 +5,7 @@ fn main() -> () {
     scope 1 {
         debug x => const 2_u32 is 1..=;
         scope 2 {
-            debug y => const 0_u32 is 1..=;
+            debug y => const {transmute(0x00000000): (u32) is 1..=};
         }
     }
 
diff --git a/tests/mir-opt/pattern_types.rs b/tests/mir-opt/pattern_types.rs
index 217c64b90cb..0369ccf9a9d 100644
--- a/tests/mir-opt/pattern_types.rs
+++ b/tests/mir-opt/pattern_types.rs
@@ -7,6 +7,6 @@ use std::pat::pattern_type;
 fn main() {
     // CHECK: debug x => const 2_u32 is 1..=
     let x: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(2) };
-    // CHECK: debug y => const 0_u32 is 1..=
+    // CHECK: debug y => const {transmute(0x00000000): (u32) is 1..=}
     let y: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(0) };
 }