]> git.proxmox.com Git - rustc.git/blobdiff - src/libcoretest/cell.rs
Imported Upstream version 1.1.0+dfsg1
[rustc.git] / src / libcoretest / cell.rs
index 85dd10390038fadc92ac4e3faf3d260d029497d3..f02312b8641e118f7ec3d7b20cb228067732690c 100644 (file)
@@ -159,3 +159,28 @@ fn refcell_default() {
     let cell: RefCell<u64> = Default::default();
     assert_eq!(0, *cell.borrow());
 }
+
+#[test]
+fn unsafe_cell_unsized() {
+    let cell: &UnsafeCell<[i32]> = &UnsafeCell::new([1, 2, 3]);
+    {
+        let val: &mut [i32] = unsafe { &mut *cell.get() };
+        val[0] = 4;
+        val[2] = 5;
+    }
+    let comp: &mut [i32] = &mut [4, 2, 5];
+    assert_eq!(unsafe { &mut *cell.get() }, comp);
+}
+
+// FIXME(#25351) needs deeply nested coercions of DST structs.
+// #[test]
+// fn refcell_unsized() {
+//     let cell: &RefCell<[i32]> = &RefCell::new([1, 2, 3]);
+//     {
+//         let b = &mut *cell.borrow_mut();
+//         b[0] = 4;
+//         b[2] = 5;
+//     }
+//     let comp: &mut [i32] = &mut [4, 2, 5];
+//     assert_eq!(&*cell.borrow(), comp);
+// }