diff --git a/rust-version b/rust-version index a6374bf120c9..74b2e148f839 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -0309953232d9957aef4c7c5a24fcb30735b2066b +1773f14a24c49356b384e45ebb45643bc9bef2c4 diff --git a/tests/run-pass/stacked-borrows/stacked-borrows.rs b/tests/run-pass/stacked-borrows/stacked-borrows.rs index f76d4e64c6c9..0401a6640fd3 100644 --- a/tests/run-pass/stacked-borrows/stacked-borrows.rs +++ b/tests/run-pass/stacked-borrows/stacked-borrows.rs @@ -15,6 +15,7 @@ fn main() { shr_and_raw(); disjoint_mutable_subborrows(); raw_ref_to_part(); + array_casts(); } // Make sure that reading from an `&mut` does, like reborrowing to `&`, @@ -174,3 +175,14 @@ fn raw_ref_to_part() { assert!(typed.extra == 42); drop(unsafe { Box::from_raw(whole) }); } + +/// When casting an array reference to a raw element ptr, that should cover the whole array. +fn array_casts() { + let mut x: [usize; 2] = [0, 0]; + let p = &mut x as *mut usize; + unsafe { *p.add(1) = 1; } + + let x: [usize; 2] = [0, 1]; + let p = &x as *const usize; + assert_eq!(unsafe { *p.add(1) }, 1); +}