1 // Example taken from RFC 1238 text
3 // https://github.com/rust-lang/rfcs/blob/master/text/1238-nonparametric-dropck.md
4 // #examples-of-code-that-will-start-to-be-rejected
6 // Compare against test/run-pass/issue28498-must-work-ex2.rs
10 struct Concrete<'a>(u32, Cell<Option<&'a Concrete<'a>>>);
12 struct Foo<T> { data: Vec<T> }
14 fn potentially_specialized_wrt_t<T>(t: &T) {
15 // Hypothetical code that does one thing for generic T and then is
16 // specialized for T == Concrete (and the specialized form can
17 // then access a reference held in concrete tuple).
19 // (We don't have specialization yet, but we want to allow for it
23 impl<T> Drop for Foo<T> {
25 potentially_specialized_wrt_t(&self.data[0])
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 //~^ ERROR borrow may still be in use when destructor runs
36 foo.data[1].1.set(Some(&foo.data[0]));