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.)
6 // compile-flags:-Zborrowck=mir
9 #![feature(dropck_eyepatch)]
11 fn use_x(_: usize) -> bool { true }
14 let mut v = [1, 2, 3];
15 let p: WrapMayNotDangle<&usize> = WrapMayNotDangle { value: &v[0] };
20 v[0] += 1; //~ ERROR cannot assign to `v[_]` because it is borrowed
23 v[0] += 1; //~ ERROR cannot assign to `v[_]` because it is borrowed
26 struct WrapMayNotDangle<T> {
30 impl<T> Drop for WrapMayNotDangle<T> {
31 fn drop(&mut self) { }