1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Example taken from RFC 1238 text
13 // https://github.com/rust-lang/rfcs/blob/master/text/1238-nonparametric-dropck.md
14 // #example-of-the-unguarded-escape-hatch
16 #![feature(dropck_parametricity)]
19 struct Concrete<'a>(u32, Cell<Option<&'a Concrete<'a>>>);
21 struct Foo<T> { data: Vec<T> }
23 impl<T> Drop for Foo<T> {
24 // Below is the UGEH attribute
25 #[unsafe_destructor_blind_to_params]
26 fn drop(&mut self) { }
30 let mut foo = Foo { data: Vec::new() };
31 foo.data.push(Concrete(0, Cell::new(None)));
32 foo.data.push(Concrete(0, Cell::new(None)));
34 foo.data[0].1.set(Some(&foo.data[1]));
35 foo.data[1].1.set(Some(&foo.data[0]));