Skip to content

Commit 5e55fe8

Browse files
committed
Revert RIMOV for libcore
1 parent cc3bb7b commit 5e55fe8

File tree

7 files changed

+35
-35
lines changed

7 files changed

+35
-35
lines changed

src/libcore/dvec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use vec;
4646
* # WARNING
4747
*
4848
* For maximum performance, this type is implemented using some rather
49-
* unsafe code. In particular, this innocent looking `~[A]` pointer
49+
* unsafe code. In particular, this innocent looking `~[mut A]` pointer
5050
* *may be null!* Therefore, it is important you not reach into the
5151
* data structure manually but instead use the provided extensions.
5252
*
@@ -143,7 +143,7 @@ impl<A> DVec<A> {
143143
* and return a new vector to replace it with.
144144
*/
145145
#[inline(always)]
146-
fn swap_mut(f: &fn(v: ~[A]) -> ~[A]) {
146+
fn swap_mut(f: &fn(v: ~[mut A]) -> ~[mut A]) {
147147
do self.swap |v| {
148148
vec::cast_from_mut(f(vec::cast_to_mut(move v)))
149149
}
@@ -223,7 +223,7 @@ impl<A> DVec<A> {
223223
}
224224
225225
/// Gives access to the vector as a slice with mutable contents
226-
fn borrow_mut<R>(op: fn(x: &mut [A]) -> R) -> R {
226+
fn borrow_mut<R>(op: fn(x: &[mut A]) -> R) -> R {
227227
do self.check_out |v| {
228228
let mut v = move v;
229229
let result = op(v);

src/libcore/hash.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ struct SipState {
169169
mut v1: u64,
170170
mut v2: u64,
171171
mut v3: u64,
172-
mut tail: [u8 * 8], // unprocessed bytes
172+
tail: [mut u8 * 8], // unprocessed bytes
173173
mut ntail: uint, // how many bytes in tail are valid
174174
}
175175

@@ -183,7 +183,7 @@ fn SipState(key0: u64, key1: u64) -> SipState {
183183
mut v1 : 0u64,
184184
mut v2 : 0u64,
185185
mut v3 : 0u64,
186-
mut tail : [0u8,0,0,0,0,0,0,0],
186+
tail : [mut 0u8,0,0,0,0,0,0,0],
187187
mut ntail : 0u,
188188
};
189189
(&state).reset();

src/libcore/io.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub trait Reader {
5959
/// Read up to len bytes (or EOF) and put them into bytes (which
6060
/// must be at least len bytes long). Return number of bytes read.
6161
// FIXME (#2982): This should probably return an error.
62-
fn read(&self, bytes: &mut [u8], len: uint) -> uint;
62+
fn read(&self, bytes: &[mut u8], len: uint) -> uint;
6363

6464
/// Read a single byte, returning a negative value for EOF or read error.
6565
fn read_byte(&self) -> int;
@@ -419,7 +419,7 @@ fn convert_whence(whence: SeekStyle) -> i32 {
419419
}
420420

421421
impl *libc::FILE: Reader {
422-
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
422+
fn read(&self, bytes: &[mut u8], len: uint) -> uint {
423423
unsafe {
424424
do vec::as_mut_buf(bytes) |buf_p, buf_len| {
425425
assert buf_len >= len;
@@ -464,7 +464,7 @@ struct Wrapper<T, C> {
464464
// duration of its lifetime.
465465
// FIXME there really should be a better way to do this // #2004
466466
impl<R: Reader, C> Wrapper<R, C>: Reader {
467-
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
467+
fn read(&self, bytes: &[mut u8], len: uint) -> uint {
468468
self.base.read(bytes, len)
469469
}
470470
fn read_byte(&self) -> int { self.base.read_byte() }
@@ -531,7 +531,7 @@ pub struct BytesReader {
531531
}
532532
533533
impl BytesReader: Reader {
534-
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
534+
fn read(&self, bytes: &[mut u8], len: uint) -> uint {
535535
let count = uint::min(len, self.bytes.len() - self.pos);
536536
537537
let view = vec::view(self.bytes, self.pos, self.bytes.len());

src/libcore/rand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl Rng {
254254
}
255255

256256
/// Shuffle a mutable vec in place
257-
fn shuffle_mut<T>(values: &mut [T]) {
257+
fn shuffle_mut<T>(values: &[mut T]) {
258258
let mut i = values.len();
259259
while i >= 2u {
260260
// invariant: elements with index >= i have been locked in place.

src/libcore/run.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program {
289289

290290
fn read_all(rd: io::Reader) -> ~str {
291291
let buf = io::with_bytes_writer(|wr| {
292-
let mut bytes = [0, ..4096];
292+
let mut bytes = [mut 0, ..4096];
293293
while !rd.eof() {
294294
let nread = rd.read(bytes, bytes.len());
295295
wr.write(bytes.view(0, nread));
@@ -387,7 +387,7 @@ pub fn readclose(fd: c_int) -> ~str {
387387
let file = os::fdopen(fd);
388388
let reader = io::FILE_reader(file, false);
389389
let buf = io::with_bytes_writer(|writer| {
390-
let mut bytes = [0, ..4096];
390+
let mut bytes = [mut 0, ..4096];
391391
while !reader.eof() {
392392
let nread = reader.read(bytes, bytes.len());
393393
writer.write(bytes.view(0, nread));

src/libcore/uint-template.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ pub pure fn to_str_bytes<U>(neg: bool, num: T, radix: uint,
252252
// Enough room to hold any number in any radix.
253253
// Worst case: 64-bit number, binary-radix, with
254254
// a leading negative sign = 65 bytes.
255-
let mut buf : [u8 * 65] = [0u8, ..65];
255+
let buf : [mut u8 * 65] = [mut 0u8, ..65];
256256
let len = buf.len();
257257

258258
let mut i = len;

src/libcore/vec.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,12 @@ pub pure fn build_sized_opt<A>(size: Option<uint>,
206206
}
207207

208208
/// Produces a mut vector from an immutable vector.
209-
pub pure fn cast_to_mut<T>(v: ~[T]) -> ~[T] {
209+
pub pure fn cast_to_mut<T>(v: ~[T]) -> ~[mut T] {
210210
unsafe { ::cast::transmute(v) }
211211
}
212212

213213
/// Produces an immutable vector from a mut vector.
214-
pub pure fn cast_from_mut<T>(v: ~[T]) -> ~[T] {
214+
pub pure fn cast_from_mut<T>(v: ~[mut T]) -> ~[T] {
215215
unsafe { ::cast::transmute(v) }
216216
}
217217

@@ -562,7 +562,7 @@ pub fn consume<T>(v: ~[T], f: fn(uint, v: T)) {
562562
}
563563
}
564564

565-
pub fn consume_mut<T>(v: ~[T], f: fn(uint, v: T)) {
565+
pub fn consume_mut<T>(v: ~[mut T], f: fn(uint, v: T)) {
566566
consume(vec::cast_from_mut(v), f)
567567
}
568568

@@ -731,7 +731,7 @@ pub pure fn append_one<T>(lhs: ~[T], x: T) -> ~[T] {
731731
}
732732

733733
#[inline(always)]
734-
pub pure fn append_mut<T: Copy>(lhs: ~[T], rhs: &[const T]) -> ~[T] {
734+
pub pure fn append_mut<T: Copy>(lhs: ~[mut T], rhs: &[const T]) -> ~[mut T] {
735735
cast_to_mut(append(cast_from_mut(lhs), rhs))
736736
}
737737

@@ -1263,12 +1263,12 @@ pub pure fn zip<T, U>(v: ~[T], u: ~[U]) -> ~[(T, U)] {
12631263
* * a - The index of the first element
12641264
* * b - The index of the second element
12651265
*/
1266-
pub fn swap<T>(v: &mut [T], a: uint, b: uint) {
1266+
pub fn swap<T>(v: &[mut T], a: uint, b: uint) {
12671267
v[a] <-> v[b];
12681268
}
12691269

12701270
/// Reverse the order of elements in a vector, in place
1271-
pub fn reverse<T>(v: &mut [T]) {
1271+
pub fn reverse<T>(v: &[mut T]) {
12721272
let mut i: uint = 0;
12731273
let ln = len::<T>(v);
12741274
while i < ln / 2 { v[i] <-> v[ln - i - 1]; i += 1; }
@@ -1349,7 +1349,7 @@ pub pure fn each<T>(v: &r/[T], f: fn(&r/T) -> bool) {
13491349
/// a vector with mutable contents and you would like
13501350
/// to mutate the contents as you iterate.
13511351
#[inline(always)]
1352-
pub fn each_mut<T>(v: &mut [T], f: fn(elem: &mut T) -> bool) {
1352+
pub fn each_mut<T>(v: &[mut T], f: fn(elem: &mut T) -> bool) {
13531353
let mut i = 0;
13541354
let n = v.len();
13551355
while i < n {
@@ -1519,7 +1519,7 @@ pub pure fn as_const_buf<T,U>(s: &[const T],
15191519

15201520
/// Similar to `as_imm_buf` but passing a `*mut T`
15211521
#[inline(always)]
1522-
pub pure fn as_mut_buf<T,U>(s: &mut [T],
1522+
pub pure fn as_mut_buf<T,U>(s: &[mut T],
15231523
f: fn(*mut T, uint) -> U) -> U {
15241524

15251525
unsafe {
@@ -1640,9 +1640,9 @@ pub mod traits {
16401640
}
16411641
}
16421642

1643-
impl<T: Copy> ~[T] : Add<&[const T],~[T]> {
1643+
impl<T: Copy> ~[mut T] : Add<&[const T],~[mut T]> {
16441644
#[inline(always)]
1645-
pure fn add(&self, rhs: & &self/[const T]) -> ~[T] {
1645+
pure fn add(&self, rhs: & &self/[const T]) -> ~[mut T] {
16461646
append_mut(copy *self, (*rhs))
16471647
}
16481648
}
@@ -2066,7 +2066,7 @@ pub mod raw {
20662066

20672067
/** see `to_ptr()` */
20682068
#[inline(always)]
2069-
pub unsafe fn to_mut_ptr<T>(v: &mut [T]) -> *mut T {
2069+
pub unsafe fn to_mut_ptr<T>(v: &[mut T]) -> *mut T {
20702070
let repr: **SliceRepr = ::cast::transmute(&v);
20712071
return ::cast::reinterpret_cast(&addr_of(&((**repr).data)));
20722072
}
@@ -2099,7 +2099,7 @@ pub mod raw {
20992099
* is newly allocated.
21002100
*/
21012101
#[inline(always)]
2102-
pub unsafe fn init_elem<T>(v: &mut [T], i: uint, val: T) {
2102+
pub unsafe fn init_elem<T>(v: &[mut T], i: uint, val: T) {
21032103
let mut box = Some(val);
21042104
do as_mut_buf(v) |p, _len| {
21052105
let mut box2 = None;
@@ -2133,7 +2133,7 @@ pub mod raw {
21332133
* may overlap.
21342134
*/
21352135
#[inline(always)]
2136-
pub unsafe fn copy_memory<T>(dst: &mut [T], src: &[const T],
2136+
pub unsafe fn copy_memory<T>(dst: &[mut T], src: &[const T],
21372137
count: uint) {
21382138
assert dst.len() >= count;
21392139
assert src.len() >= count;
@@ -2200,7 +2200,7 @@ pub mod bytes {
22002200
* may overlap.
22012201
*/
22022202
#[inline(always)]
2203-
pub fn copy_memory(dst: &mut [u8], src: &[const u8], count: uint) {
2203+
pub fn copy_memory(dst: &[mut u8], src: &[const u8], count: uint) {
22042204
// Bound checks are done at vec::raw::copy_memory.
22052205
unsafe { vec::raw::copy_memory(dst, src, count) }
22062206
}
@@ -3155,7 +3155,7 @@ mod tests {
31553155

31563156
#[test]
31573157
fn reverse_and_reversed() {
3158-
let mut v: ~[int] = ~[10, 20];
3158+
let v: ~[mut int] = ~[mut 10, 20];
31593159
assert (v[0] == 10);
31603160
assert (v[1] == 20);
31613161
reverse(v);
@@ -3170,13 +3170,13 @@ mod tests {
31703170

31713171
let v4 = reversed::<int>(~[]);
31723172
assert (v4 == ~[]);
3173-
let mut v3: ~[int] = ~[];
3173+
let v3: ~[mut int] = ~[mut];
31743174
reverse::<int>(v3);
31753175
}
31763176

31773177
#[test]
31783178
fn reversed_mut() {
3179-
let mut v2 = reversed::<int>(~[10, 20]);
3179+
let v2 = reversed::<int>(~[mut 10, 20]);
31803180
assert (v2[0] == 20);
31813181
assert (v2[1] == 10);
31823182
}
@@ -3302,7 +3302,7 @@ mod tests {
33023302
#[test]
33033303
fn cast_from_mut_no_copy() {
33043304
unsafe {
3305-
let mut x = ~[1, 2, 3];
3305+
let x = ~[mut 1, 2, 3];
33063306
let addr = raw::to_ptr(x);
33073307
let x_imm = cast_from_mut(x);
33083308
let addr_imm = raw::to_ptr(x_imm);
@@ -3564,7 +3564,7 @@ mod tests {
35643564
#[ignore(windows)]
35653565
#[should_fail]
35663566
fn test_consume_mut_fail() {
3567-
let mut v = ~[(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
3567+
let v = ~[mut (~0, @0), (~0, @0), (~0, @0), (~0, @0)];
35683568
let mut i = 0;
35693569
do consume_mut(v) |_i, _elt| {
35703570
if i == 2 {
@@ -3592,7 +3592,7 @@ mod tests {
35923592
#[ignore(windows)]
35933593
#[should_fail]
35943594
fn test_map_fail() {
3595-
let mut v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
3595+
let v = [mut (~0, @0), (~0, @0), (~0, @0), (~0, @0)];
35963596
let mut i = 0;
35973597
do map(v) |_elt| {
35983598
if i == 2 {
@@ -3918,7 +3918,7 @@ mod tests {
39183918
#[ignore(cfg(windows))]
39193919
#[should_fail]
39203920
fn test_as_mut_buf_fail() {
3921-
let mut v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
3921+
let v = [mut (~0, @0), (~0, @0), (~0, @0), (~0, @0)];
39223922
do as_mut_buf(v) |_buf, _i| {
39233923
fail
39243924
}
@@ -3929,7 +3929,7 @@ mod tests {
39293929
#[ignore(cfg(windows))]
39303930
fn test_copy_memory_oob() {
39313931
unsafe {
3932-
let mut a = [1, 2, 3, 4];
3932+
let a = [mut 1, 2, 3, 4];
39333933
let b = [1, 2, 3, 4, 5];
39343934
raw::copy_memory(a, b, 5);
39353935
}

0 commit comments

Comments
 (0)