let nmi: *mut dyn ToString = null_mut::<isize>();
assert!(nmi.is_null());
- #[cfg(not(bootstrap))]
- {
- extern "C" {
- type Extern;
- }
- let ec: *const Extern = null::<Extern>();
- assert!(ec.is_null());
-
- let em: *mut Extern = null_mut::<Extern>();
- assert!(em.is_null());
+ extern "C" {
+ type Extern;
}
+ let ec: *const Extern = null::<Extern>();
+ assert!(ec.is_null());
+
+ let em: *mut Extern = null_mut::<Extern>();
+ assert!(em.is_null());
}
#[test]
}
}
+#[test]
+fn swap_copy_untyped() {
+ // We call `{swap,copy}{,_nonoverlapping}` at `bool` type on data that is not a valid bool.
+ // These should all do untyped copies, so this should work fine.
+ let mut x = 5u8;
+ let mut y = 6u8;
+
+ let ptr1 = &mut x as *mut u8 as *mut bool;
+ let ptr2 = &mut y as *mut u8 as *mut bool;
+
+ unsafe {
+ ptr::swap(ptr1, ptr2);
+ ptr::swap_nonoverlapping(ptr1, ptr2, 1);
+ }
+ assert_eq!(x, 5);
+ assert_eq!(y, 6);
+
+ unsafe {
+ ptr::copy(ptr1, ptr2, 1);
+ ptr::copy_nonoverlapping(ptr1, ptr2, 1);
+ }
+ assert_eq!(x, 5);
+ assert_eq!(y, 5);
+}
+
#[test]
fn test_const_copy() {
const {