diff options
Diffstat (limited to 'tests/ui/example_opaque_vs_drop.rs')
-rw-r--r-- | tests/ui/example_opaque_vs_drop.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/ui/example_opaque_vs_drop.rs b/tests/ui/example_opaque_vs_drop.rs new file mode 100644 index 0000000..b2c1809 --- /dev/null +++ b/tests/ui/example_opaque_vs_drop.rs @@ -0,0 +1,25 @@ +//! Example of how `opaque!` prevents unsound `Drop`. +//! +//! NOTE: Also in trait `Opaque` documentation. Keep 'em in sync. + +use std::cell::Cell; +use selfref::opaque; + +struct Foo<'a> { + foo: Cell<Option<&'a Foo<'a>>>, +} + +impl<'a> Drop for Foo<'a> { + fn drop(&mut self) { + } +} + +struct FooKey; +opaque! { + impl Opaque for FooKey { + type Kind<'a> = Foo<'a>; + } +} + +fn main() { +} |