about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/statics/recursive_interior_mut.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/ui/statics/recursive_interior_mut.rs b/tests/ui/statics/recursive_interior_mut.rs
new file mode 100644
index 00000000000..7e3083909d5
--- /dev/null
+++ b/tests/ui/statics/recursive_interior_mut.rs
@@ -0,0 +1,20 @@
+// check-pass
+
+use std::cell::Cell;
+use std::ptr::NonNull;
+
+struct ChunkFooter {
+    prev: Cell<NonNull<ChunkFooter>>,
+}
+
+struct EmptyChunkFooter(ChunkFooter);
+
+unsafe impl Sync for EmptyChunkFooter {}
+
+static EMPTY_CHUNK: EmptyChunkFooter = EmptyChunkFooter(ChunkFooter {
+    prev: Cell::new(unsafe {
+        NonNull::new_unchecked(&EMPTY_CHUNK as *const EmptyChunkFooter as *mut ChunkFooter)
+    }),
+});
+
+fn main() {}