about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAmanjeev Sethi <aj@amanjeev.com>2022-09-02 19:12:03 -0400
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-02-15 10:25:06 +0000
commitca109af2acceee83b21fefe22713e3f34c04130b (patch)
treeb77774696affe47faebf27ea224e2d8303084bfb
parentbd6b3361339522cc258d1f4165e3340e4cb1add4 (diff)
downloadrust-ca109af2acceee83b21fefe22713e3f34c04130b.tar.gz
rust-ca109af2acceee83b21fefe22713e3f34c04130b.zip
Add regression test
-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() {}