summary refs log tree commit diff stats
path: root/tests/ui/example_need_cell.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/example_need_cell.rs')
-rw-r--r--tests/ui/example_need_cell.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/ui/example_need_cell.rs b/tests/ui/example_need_cell.rs
new file mode 100644
index 0000000..b6e12eb
--- /dev/null
+++ b/tests/ui/example_need_cell.rs
@@ -0,0 +1,12 @@
+//! Example of how Rust requires the use of a Cell to build a self-referential
+//! struct.
+//!
+//! NOTE: Also in top-level crate documentation. Keep 'em in sync.
+
+struct MySelfRefStruct<'this> {
+    this: &'this MySelfRefStruct<'this>,
+}
+
+fn main() {
+    let x = MySelfRefStruct { this: &x };
+}