File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
tests/run-pass/stacked-borrows Expand file tree Collapse file tree 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() {
1515 shr_and_raw ( ) ;
1616 disjoint_mutable_subborrows ( ) ;
1717 raw_ref_to_part ( ) ;
18+ array_casts ( ) ;
1819}
1920
2021// Make sure that reading from an `&mut` does, like reborrowing to `&`,
@@ -174,3 +175,14 @@ fn raw_ref_to_part() {
174175 assert ! ( typed. extra == 42 ) ;
175176 drop ( unsafe { Box :: from_raw ( whole) } ) ;
176177}
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