2017-08-09 20:01:10 -05:00
|
|
|
#![allow(unused_variables)]
|
|
|
|
|
|
|
|
mod safe {
|
|
|
|
use std::slice::from_raw_parts_mut;
|
|
|
|
|
|
|
|
pub fn split_at_mut<T>(self_: &mut [T], mid: usize) -> (&mut [T], &mut [T]) {
|
|
|
|
let len = self_.len();
|
|
|
|
let ptr = self_.as_mut_ptr();
|
|
|
|
|
|
|
|
unsafe {
|
|
|
|
assert!(mid <= len);
|
|
|
|
|
|
|
|
(from_raw_parts_mut(ptr, len - mid), // BUG: should be "mid" instead of "len - mid"
|
2018-10-30 10:46:28 -05:00
|
|
|
//~^ ERROR reference with non-reactivatable tag
|
2017-08-09 20:01:10 -05:00
|
|
|
from_raw_parts_mut(ptr.offset(mid as isize), len - mid))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut array = [1,2,3,4];
|
2018-10-17 09:55:59 -05:00
|
|
|
let (a, b) = safe::split_at_mut(&mut array, 0);
|
2018-10-19 09:07:40 -05:00
|
|
|
a[1] = 5;
|
2018-10-17 09:55:59 -05:00
|
|
|
b[1] = 6;
|
2017-08-09 20:01:10 -05:00
|
|
|
}
|