summary refs log tree commit diff stats
path: root/tests/ui/example_opaque_vs_drop.rs
blob: b2c1809867bb4ceded3d89bc2fd644b652b66c98 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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() {
}