1 // Basic test for liveness constraints: the region (`R1`) that appears
2 // in the type of `p` must include everything until `p` is dropped
3 // because of destructor. (Note that the stderr also identifies this
4 // destructor in the error message.)
7 #![feature(dropck_eyepatch)]
9 fn use_x(_
: usize) -> bool { true }
12 let mut v
= [1, 2, 3];
13 let p
: WrapMayNotDangle
<&usize> = WrapMayNotDangle { value: &v[0] }
;
18 v
[0] += 1; //~ ERROR cannot assign to `v[_]` because it is borrowed
21 v
[0] += 1; //~ ERROR cannot assign to `v[_]` because it is borrowed
24 struct WrapMayNotDangle
<T
> {
28 impl<T
> Drop
for WrapMayNotDangle
<T
> {
29 fn drop(&mut self) { }