summaryrefslogtreecommitdiffstats
path: root/library/core/tests/mem.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/core/tests/mem.rs')
-rw-r--r--library/core/tests/mem.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/library/core/tests/mem.rs b/library/core/tests/mem.rs
index 0362e1c8a..1cfb4fd9f 100644
--- a/library/core/tests/mem.rs
+++ b/library/core/tests/mem.rs
@@ -1,4 +1,5 @@
use core::mem::*;
+use core::ptr;
#[cfg(panic = "unwind")]
use std::rc::Rc;
@@ -76,6 +77,25 @@ fn align_of_val_basic() {
}
#[test]
+#[cfg(not(bootstrap))] // stage 0 doesn't have the fix yet, so the test fails
+fn align_of_val_raw_packed() {
+ #[repr(C, packed)]
+ struct B {
+ f: [u32],
+ }
+ let storage = [0u8; 4];
+ let b: *const B = ptr::from_raw_parts(storage.as_ptr().cast(), 1);
+ assert_eq!(unsafe { align_of_val_raw(b) }, 1);
+
+ const ALIGN_OF_VAL_RAW: usize = {
+ let storage = [0u8; 4];
+ let b: *const B = ptr::from_raw_parts(storage.as_ptr().cast(), 1);
+ unsafe { align_of_val_raw(b) }
+ };
+ assert_eq!(ALIGN_OF_VAL_RAW, 1);
+}
+
+#[test]
fn test_swap() {
let mut x = 31337;
let mut y = 42;