about summary refs log tree commit diff
path: root/tests/ui/consts/oncecell-const-init-57781.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/consts/oncecell-const-init-57781.rs')
-rw-r--r--tests/ui/consts/oncecell-const-init-57781.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/consts/oncecell-const-init-57781.rs b/tests/ui/consts/oncecell-const-init-57781.rs
new file mode 100644
index 00000000000..27426ef2549
--- /dev/null
+++ b/tests/ui/consts/oncecell-const-init-57781.rs
@@ -0,0 +1,21 @@
+// https://github.com/rust-lang/rust/issues/57781
+//@ run-pass
+
+use std::cell::UnsafeCell;
+use std::collections::HashMap;
+
+struct OnceCell<T> {
+    _value: UnsafeCell<Option<T>>,
+}
+
+impl<T> OnceCell<T> {
+    const INIT: OnceCell<T> = OnceCell {
+        _value: UnsafeCell::new(None),
+    };
+}
+
+pub fn crash<K, T>() {
+    let _ = OnceCell::<HashMap<K, T>>::INIT;
+}
+
+fn main() {}