summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/simplify_duplicate_unreachable_blocks.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
commit631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch)
treea1b87c8f8cad01cf18f7c5f57a08f102771ed303 /tests/mir-opt/simplify_duplicate_unreachable_blocks.rs
parentAdding debian version 1.69.0+dfsg1-1. (diff)
downloadrustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz
rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/mir-opt/simplify_duplicate_unreachable_blocks.rs')
-rw-r--r--tests/mir-opt/simplify_duplicate_unreachable_blocks.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/mir-opt/simplify_duplicate_unreachable_blocks.rs b/tests/mir-opt/simplify_duplicate_unreachable_blocks.rs
new file mode 100644
index 000000000..e2578407f
--- /dev/null
+++ b/tests/mir-opt/simplify_duplicate_unreachable_blocks.rs
@@ -0,0 +1,30 @@
+#![feature(custom_mir, core_intrinsics)]
+#![crate_type = "lib"]
+
+use std::intrinsics::mir::*;
+
+// unit-test: SimplifyCfg-after-uninhabited-enum-branching
+
+// EMIT_MIR simplify_duplicate_unreachable_blocks.assert_nonzero_nonmax.SimplifyCfg-after-uninhabited-enum-branching.diff
+#[custom_mir(dialect = "runtime", phase = "post-cleanup")]
+pub unsafe fn assert_nonzero_nonmax(x: u8) -> u8 {
+ mir!(
+ {
+ match x {
+ 0 => unreachable1,
+ u8::MAX => unreachable2,
+ _ => retblock,
+ }
+ }
+ unreachable1 = {
+ Unreachable()
+ }
+ unreachable2 = {
+ Unreachable()
+ }
+ retblock = {
+ RET = x;
+ Return()
+ }
+ )
+}