2017-04-07 18:25:40 -05:00
|
|
|
#![feature(untagged_unions)]
|
|
|
|
#![allow(unused)]
|
|
|
|
|
|
|
|
#[allow(unions_with_drop_fields)]
|
|
|
|
union U {
|
|
|
|
x: ((Vec<u8>, Vec<u8>), Vec<u8>),
|
|
|
|
y: Box<Vec<u8>>,
|
|
|
|
}
|
|
|
|
|
2018-11-04 11:36:30 -06:00
|
|
|
fn use_borrow<T>(_: &T) {}
|
|
|
|
|
2017-04-07 18:25:40 -05:00
|
|
|
unsafe fn parent_sibling_borrow() {
|
|
|
|
let mut u = U { x: ((Vec::new(), Vec::new()), Vec::new()) };
|
|
|
|
let a = &mut u.x.0;
|
2018-11-04 11:36:30 -06:00
|
|
|
let b = &u.y; //~ ERROR cannot borrow `u.y`
|
|
|
|
use_borrow(a);
|
2017-04-07 18:25:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn parent_sibling_move() {
|
|
|
|
let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) };
|
|
|
|
let a = u.x.0;
|
2018-11-04 11:36:30 -06:00
|
|
|
let b = u.y; //~ ERROR use of moved value: `u.y`
|
2017-04-07 18:25:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn grandparent_sibling_borrow() {
|
|
|
|
let mut u = U { x: ((Vec::new(), Vec::new()), Vec::new()) };
|
|
|
|
let a = &mut (u.x.0).0;
|
2018-11-04 11:36:30 -06:00
|
|
|
let b = &u.y; //~ ERROR cannot borrow `u.y`
|
|
|
|
use_borrow(a);
|
2017-04-07 18:25:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn grandparent_sibling_move() {
|
|
|
|
let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) };
|
|
|
|
let a = (u.x.0).0;
|
2018-11-04 11:36:30 -06:00
|
|
|
let b = u.y; //~ ERROR use of moved value: `u.y`
|
2017-04-07 18:25:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn deref_sibling_borrow() {
|
|
|
|
let mut u = U { y: Box::default() };
|
|
|
|
let a = &mut *u.y;
|
2018-11-04 11:36:30 -06:00
|
|
|
let b = &u.x; //~ ERROR cannot borrow `u` (via `u.x`)
|
|
|
|
use_borrow(a);
|
2017-04-07 18:25:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn deref_sibling_move() {
|
|
|
|
let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) };
|
|
|
|
let a = *u.y;
|
2018-11-04 11:36:30 -06:00
|
|
|
let b = u.x; //~ ERROR use of moved value: `u.x`
|
2017-04-07 18:25:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn main() {}
|