diff --git a/tests/ui/codegen/nondetermenistic-int-expose-provenance.rs b/tests/ui/codegen/nondetermenistic-int-expose-provenance.rs new file mode 100644 index 0000000000000..8a7c113384091 --- /dev/null +++ b/tests/ui/codegen/nondetermenistic-int-expose-provenance.rs @@ -0,0 +1,21 @@ +//@ run-pass +//@ known-bug: #107975 + +#![feature(exposed_provenance)] + +use std::ptr::addr_of; + +fn main() { + let a: usize = { + let v = 0u8; + addr_of!(v).expose_provenance() + }; + let b: usize = { + let v = 0u8; + addr_of!(v).expose_provenance() + }; + let i: usize = a - b; + assert_ne!(i, 0); + println!("{}", i); + assert_eq!(i, 0); +} diff --git a/tests/ui/codegen/nondetermenistic-int-regular.rs b/tests/ui/codegen/nondetermenistic-int-regular.rs new file mode 100644 index 0000000000000..a49a32fdae541 --- /dev/null +++ b/tests/ui/codegen/nondetermenistic-int-regular.rs @@ -0,0 +1,17 @@ +//@ run-pass +//@ known-bug: #107975 + +fn main() { + let a: usize = { + let v = 0u8; + &v as *const _ as usize + }; + let b: usize = { + let v = 0u8; + &v as *const _ as usize + }; + let i: usize = a - b; + assert_ne!(i, 0); + println!("{}", i); + assert_eq!(i, 0); +} diff --git a/tests/ui/codegen/nondetermenistic-int-strict-provenance.rs b/tests/ui/codegen/nondetermenistic-int-strict-provenance.rs new file mode 100644 index 0000000000000..952bb30a4806c --- /dev/null +++ b/tests/ui/codegen/nondetermenistic-int-strict-provenance.rs @@ -0,0 +1,21 @@ +//@ run-pass +//@ known-bug: #107975 + +#![feature(strict_provenance)] + +use std::ptr::addr_of; + +fn main() { + let a: usize = { + let v = 0u8; + addr_of!(v).addr() + }; + let b: usize = { + let v = 0u8; + addr_of!(v).addr() + }; + let i: usize = a - b; + assert_ne!(i, 0); + println!("{}", i); + assert_eq!(i, 0); +}