]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/issue-31567.rs
fix merge conflicts
[rust.git] / src / test / ui / nll / issue-31567.rs
1 // Regression test for #31567: cached results of projections were
2 // causing region relations not to be enforced at all the places where
3 // they have to be enforced.
4
5 #![feature(nll)]
6
7 struct VecWrapper<'a>(&'a mut S);
8
9 struct S(Box<u32>);
10
11 fn get_dangling<'a>(v: VecWrapper<'a>) -> &'a u32 {
12     let s_inner: &'a S = &*v.0; //~ ERROR borrow may still be in use when destructor runs [E0713]
13     &s_inner.0
14 }
15
16 impl<'a> Drop for VecWrapper<'a> {
17     fn drop(&mut self) {
18         *self.0 = S(Box::new(0));
19     }
20 }
21
22 fn main() {
23     let mut s = S(Box::new(11));
24     let vw = VecWrapper(&mut s);
25     let dangling = get_dangling(vw);
26     println!("{}", dangling);
27 }