Demode some code using by-mutbl-ref; warn about by-mutbl-ref
The parser now warns about use of mutbl-ref mode, though it's kind of a lie since this commit doesn't remove support for the mode. Changed move_val_init to have stage0 and stage1/2 versions, the latter of which is demoded. Changed the type that the typechecker expects the move_val_init intrinsic to have. After this is pushed, I can make a new snapshot, which will remove the need for the stage0 versions.
This commit is contained in:
@@ -21,7 +21,11 @@ extern mod rustrt {
|
||||
#[abi = "rust-intrinsic"]
|
||||
extern mod rusti {
|
||||
#[legacy_exports];
|
||||
#[cfg(stage0)]
|
||||
fn move_val_init<T>(&dst: T, -src: T);
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
fn move_val_init<T>(dst: &mut T, -src: T);
|
||||
}
|
||||
|
||||
/// Returns the number of elements the vector can hold without reallocating
|
||||
@@ -176,7 +180,9 @@ pub mod raw {
|
||||
push_slow(v, move initval);
|
||||
}
|
||||
}
|
||||
|
||||
// This doesn't bother to make sure we have space.
|
||||
#[cfg(stage0)]
|
||||
#[inline(always)] // really pretty please
|
||||
pub unsafe fn push_fast<T>(v: &mut @[const T], initval: T) {
|
||||
let repr: **VecRepr = ::cast::reinterpret_cast(&v);
|
||||
@@ -186,6 +192,18 @@ pub mod raw {
|
||||
let p = ptr::offset(p, fill) as *mut T;
|
||||
rusti::move_val_init(*p, move initval);
|
||||
}
|
||||
// This doesn't bother to make sure we have space.
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
#[inline(always)] // really pretty please
|
||||
pub unsafe fn push_fast<T>(v: &mut @[const T], initval: T) {
|
||||
let repr: **VecRepr = ::cast::reinterpret_cast(&v);
|
||||
let fill = (**repr).unboxed.fill;
|
||||
(**repr).unboxed.fill += sys::size_of::<T>();
|
||||
let p = addr_of(&((**repr).unboxed.data));
|
||||
let p = ptr::offset(p, fill) as *mut T;
|
||||
rusti::move_val_init(&mut(*p), move initval);
|
||||
}
|
||||
|
||||
pub unsafe fn push_slow<T>(v: &mut @[const T], initval: T) {
|
||||
reserve_at_least(v, v.len() + 1u);
|
||||
|
||||
Reference in New Issue
Block a user