summary refs log tree commit diff
path: root/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/print3.rs
blob: c7f46318aaef7b29a9ec2c15dabdfb4471c7e216 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//@ known-bug: #107975
//@ compile-flags: -Copt-level=2
//@ run-pass

// https://github.com/rust-lang/rust/issues/107975#issuecomment-1430704499

use std::ptr;

fn main() {
    let a: usize = {
        let v = 0;
        ptr::from_ref(&v).expose_provenance()
    };
    let b: usize = {
        let v = 0;
        ptr::from_ref(&v).expose_provenance()
    };

    assert_ne!(a, b);
    assert_ne!(a, b);
    let c = a;
    assert_eq!(format!("{} {} {}", a == b, a == c, b == c), "false true false");
    println!("{a} {b}");
    assert_eq!(format!("{} {} {}", a == b, a == c, b == c), "true true true");
}