diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/crashes/131227.rs | 16 | ||||
| -rw-r--r-- | tests/ui/dataflow_const_prop/ptr-in-switch-int-issue-131227.rs | 19 |
2 files changed, 19 insertions, 16 deletions
diff --git a/tests/crashes/131227.rs b/tests/crashes/131227.rs deleted file mode 100644 index f46185b5b4a..00000000000 --- a/tests/crashes/131227.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ known-bug: #131227 -//@ compile-flags: -Zmir-opt-level=3 - -static mut G: () = (); - -fn myfunc() -> i32 { - let var = &raw mut G; - if var.is_null() { - return 0; - } - 0 -} - -fn main() { - myfunc(); -} diff --git a/tests/ui/dataflow_const_prop/ptr-in-switch-int-issue-131227.rs b/tests/ui/dataflow_const_prop/ptr-in-switch-int-issue-131227.rs new file mode 100644 index 00000000000..7a55e13d0ee --- /dev/null +++ b/tests/ui/dataflow_const_prop/ptr-in-switch-int-issue-131227.rs @@ -0,0 +1,19 @@ +//! Issue: <https://github.com/rust-lang/rust/issues/131227> +//! Test that constant propagation in SwitchInt does not crash +//! when encountering a ptr-to-int transmute. + +//@ check-pass +//@ compile-flags: -Zmir-enable-passes=+InstSimplify-before-inline,+DataflowConstProp + +#![crate_type = "lib"] + +static mut G: i32 = 0; + +pub fn myfunc() -> i32 { + let var = &raw mut G; + let u: usize = unsafe { std::mem::transmute(var) }; + match u { + 0 => 0, + _ => 1, + } +} |
