diff options
| author | bors <bors@rust-lang.org> | 2021-05-03 20:56:34 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-05-03 20:56:34 +0000 |
| commit | 88f19c6dab716c6281af7602e30f413e809c5974 (patch) | |
| tree | f7af4b32537043e9dfbdd884f811ee8fe0122d90 /library/core/tests/const_ptr.rs | |
| parent | 9a1dfd2dc5c42a2ee84b4606aa08cdadf8c0ee87 (diff) | |
| parent | 47c7b9c5788055ddbbb59d0d1fc909af7b48668d (diff) | |
| download | rust-1.52.0.tar.gz rust-1.52.0.zip | |
Auto merge of #84864 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum 1.52.0
[stable] 1.52.0 release This includes the release notes (#84183) as well as cherry-picked commits from: * [beta] revert PR #77885 #84710 * [beta] remove assert_matches #84759 * Revert PR 81473 to resolve (on beta) issues 81626 and 81658. #83171 * [beta] rustdoc revert deref recur #84868 * Fix ICE of for-loop mut borrowck where no suggestions are available #83401 Additionally in "fresh work" we're also: * reverting: directly expose copy and copy_nonoverlapping intrinsics #81238 to avoid https://github.com/rust-lang/rust/issues/84297 on 1.52
Diffstat (limited to 'library/core/tests/const_ptr.rs')
| -rw-r--r-- | library/core/tests/const_ptr.rs | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/library/core/tests/const_ptr.rs b/library/core/tests/const_ptr.rs index 152fed803ec..4158a4dece7 100644 --- a/library/core/tests/const_ptr.rs +++ b/library/core/tests/const_ptr.rs @@ -50,52 +50,52 @@ fn mut_ptr_read() { assert_eq!(UNALIGNED, u16::from_ne_bytes([0x23, 0x45])); } -#[test] -fn write() { - use core::ptr; - - const fn write_aligned() -> i32 { - let mut res = 0; - unsafe { - ptr::write(&mut res as *mut _, 42); - } - res - } - const ALIGNED: i32 = write_aligned(); - assert_eq!(ALIGNED, 42); - - const fn write_unaligned() -> [u16; 2] { - let mut two_aligned = [0u16; 2]; - unsafe { - let unaligned_ptr = (two_aligned.as_mut_ptr() as *mut u8).add(1) as *mut u16; - ptr::write_unaligned(unaligned_ptr, u16::from_ne_bytes([0x23, 0x45])); - } - two_aligned - } - const UNALIGNED: [u16; 2] = write_unaligned(); - assert_eq!(UNALIGNED, [u16::from_ne_bytes([0x00, 0x23]), u16::from_ne_bytes([0x45, 0x00])]); -} - -#[test] -fn mut_ptr_write() { - const fn aligned() -> i32 { - let mut res = 0; - unsafe { - (&mut res as *mut i32).write(42); - } - res - } - const ALIGNED: i32 = aligned(); - assert_eq!(ALIGNED, 42); - - const fn write_unaligned() -> [u16; 2] { - let mut two_aligned = [0u16; 2]; - unsafe { - let unaligned_ptr = (two_aligned.as_mut_ptr() as *mut u8).add(1) as *mut u16; - unaligned_ptr.write_unaligned(u16::from_ne_bytes([0x23, 0x45])); - } - two_aligned - } - const UNALIGNED: [u16; 2] = write_unaligned(); - assert_eq!(UNALIGNED, [u16::from_ne_bytes([0x00, 0x23]), u16::from_ne_bytes([0x45, 0x00])]); -} +//#[test] +//fn write() { +// use core::ptr; +// +// const fn write_aligned() -> i32 { +// let mut res = 0; +// unsafe { +// ptr::write(&mut res as *mut _, 42); +// } +// res +// } +// const ALIGNED: i32 = write_aligned(); +// assert_eq!(ALIGNED, 42); +// +// const fn write_unaligned() -> [u16; 2] { +// let mut two_aligned = [0u16; 2]; +// unsafe { +// let unaligned_ptr = (two_aligned.as_mut_ptr() as *mut u8).add(1) as *mut u16; +// ptr::write_unaligned(unaligned_ptr, u16::from_ne_bytes([0x23, 0x45])); +// } +// two_aligned +// } +// const UNALIGNED: [u16; 2] = write_unaligned(); +// assert_eq!(UNALIGNED, [u16::from_ne_bytes([0x00, 0x23]), u16::from_ne_bytes([0x45, 0x00])]); +//} + +//#[test] +//fn mut_ptr_write() { +// const fn aligned() -> i32 { +// let mut res = 0; +// unsafe { +// (&mut res as *mut i32).write(42); +// } +// res +// } +// const ALIGNED: i32 = aligned(); +// assert_eq!(ALIGNED, 42); +// +// const fn write_unaligned() -> [u16; 2] { +// let mut two_aligned = [0u16; 2]; +// unsafe { +// let unaligned_ptr = (two_aligned.as_mut_ptr() as *mut u8).add(1) as *mut u16; +// unaligned_ptr.write_unaligned(u16::from_ne_bytes([0x23, 0x45])); +// } +// two_aligned +// } +// const UNALIGNED: [u16; 2] = write_unaligned(); +// assert_eq!(UNALIGNED, [u16::from_ne_bytes([0x00, 0x23]), u16::from_ne_bytes([0x45, 0x00])]); +//} |
