]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/address-of.rs
Rollup merge of #68767 - kubo39:patch-macos, r=shepmaster
[rust.git] / src / test / mir-opt / address-of.rs
1 fn address_of_reborrow() {
2     let y = &[0; 10];
3     let mut z = &mut [0; 10];
4
5     y as *const _;
6     y as *const [i32; 10];
7     y as *const dyn Send;
8     y as *const [i32];
9     y as *const i32;            // This is a cast, not a coercion
10
11     let p: *const _ = y;
12     let p: *const [i32; 10] = y;
13     let p: *const dyn Send = y;
14     let p: *const [i32] = y;
15
16     z as *const _;
17     z as *const [i32; 10];
18     z as *const dyn Send;
19     z as *const [i32];
20
21     let p: *const _ = z;
22     let p: *const [i32; 10] = z;
23     let p: *const dyn Send = z;
24     let p: *const [i32] = z;
25
26     z as *mut _;
27     z as *mut [i32; 10];
28     z as *mut dyn Send;
29     z as *mut [i32];
30
31     let p: *mut _ = z;
32     let p: *mut [i32; 10] = z;
33     let p: *mut dyn Send = z;
34     let p: *mut [i32] = z;
35 }
36
37 // The normal borrows here should be preserved
38 fn borrow_and_cast(mut x: i32) {
39     let p = &x as *const i32;
40     let q = &mut x as *const i32;
41     let r = &mut x as *mut i32;
42 }
43
44 fn main() {}
45
46 // START rustc.address_of_reborrow.SimplifyCfg-initial.after.mir
47 // bb0: {
48 //  ...
49 //  _5 = &raw const (*_1); // & to *const casts
50 //  ...
51 //  _7 = &raw const (*_1);
52 //  ...
53 //  _11 = &raw const (*_1);
54 //  ...
55 //  _14 = &raw const (*_1);
56 //  ...
57 //  _16 = &raw const (*_1);
58 //  ...
59 //  _17 = &raw const (*_1); // & to *const coercions
60 //  ...
61 //  _18 = &raw const (*_1);
62 //  ...
63 //  _20 = &raw const (*_1);
64 //  ...
65 //  _22 = &raw const (*_1);
66 // ...
67 //  _24 = &raw const (*_2); // &mut to *const casts
68 // ...
69 //  _26 = &raw const (*_2);
70 // ...
71 //  _30 = &raw const (*_2);
72 // ...
73 //  _33 = &raw const (*_2);
74 // ...
75 //  _34 = &raw const (*_2); // &mut to *const coercions
76 // ...
77 //  _35 = &raw const (*_2);
78 // ...
79 //  _37 = &raw const (*_2);
80 // ...
81 //  _39 = &raw const (*_2);
82 // ...
83 //  _41 = &raw mut (*_2); // &mut to *mut casts
84 // ...
85 //  _43 = &raw mut (*_2);
86 // ...
87 //  _47 = &raw mut (*_2);
88 // ...
89 //  _50 = &raw mut (*_2);
90 // ...
91 //  _51 = &raw mut (*_2); // &mut to *mut coercions
92 // ...
93 //  _52 = &raw mut (*_2);
94 // ...
95 //  _54 = &raw mut (*_2);
96 // ...
97 //  _56 = &raw mut (*_2);
98 // ...
99 // }
100 // END rustc.address_of_reborrow.SimplifyCfg-initial.after.mir
101
102 // START rustc.borrow_and_cast.EraseRegions.after.mir
103 // bb0: {
104 //  ...
105 //  _4 = &_1;
106 //  ...
107 //  _7 = &mut _1;
108 //  ...
109 //  _10 = &mut _1;
110 //  ...
111 // }
112 // END rustc.borrow_and_cast.EraseRegions.after.mir