File tree 2 files changed +13
-1
lines changed
tests/run-pass/stacked-borrows
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 1
- 0309953232d9957aef4c7c5a24fcb30735b2066b
1
+ 1773f14a24c49356b384e45ebb45643bc9bef2c4
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ fn main() {
15
15
shr_and_raw ( ) ;
16
16
disjoint_mutable_subborrows ( ) ;
17
17
raw_ref_to_part ( ) ;
18
+ array_casts ( ) ;
18
19
}
19
20
20
21
// Make sure that reading from an `&mut` does, like reborrowing to `&`,
@@ -174,3 +175,14 @@ fn raw_ref_to_part() {
174
175
assert ! ( typed. extra == 42 ) ;
175
176
drop ( unsafe { Box :: from_raw ( whole) } ) ;
176
177
}
178
+
179
+ /// When casting an array reference to a raw element ptr, that should cover the whole array.
180
+ fn array_casts ( ) {
181
+ let mut x: [ usize ; 2 ] = [ 0 , 0 ] ;
182
+ let p = & mut x as * mut usize ;
183
+ unsafe { * p. add ( 1 ) = 1 ; }
184
+
185
+ let x: [ usize ; 2 ] = [ 0 , 1 ] ;
186
+ let p = & x as * const usize ;
187
+ assert_eq ! ( unsafe { * p. add( 1 ) } , 1 ) ;
188
+ }
You can’t perform that action at this time.
0 commit comments