RIMOV, round 5

find ./ -type f -name "*.rs" -exec sed -i "s/\&\[mut /\&mut \[/g" {} \;
This commit is contained in:
Ben Striegel 2013-01-29 21:30:22 -05:00
parent 12e8151fb0
commit f08af9a7a5
22 changed files with 64 additions and 60 deletions

View File

@ -223,7 +223,7 @@ impl<A> DVec<A> {
}
/// Gives access to the vector as a slice with mutable contents
fn borrow_mut<R>(op: fn(x: &[mut A]) -> R) -> R {
fn borrow_mut<R>(op: fn(x: &mut [A]) -> R) -> R {
do self.check_out |v| {
let mut v = move v;
let result = op(v);

View File

@ -59,7 +59,7 @@ pub trait Reader {
/// Read up to len bytes (or EOF) and put them into bytes (which
/// must be at least len bytes long). Return number of bytes read.
// FIXME (#2982): This should probably return an error.
fn read(&self, bytes: &[mut u8], len: uint) -> uint;
fn read(&self, bytes: &mut [u8], len: uint) -> uint;
/// Read a single byte, returning a negative value for EOF or read error.
fn read_byte(&self) -> int;
@ -419,7 +419,7 @@ fn convert_whence(whence: SeekStyle) -> i32 {
}
impl *libc::FILE: Reader {
fn read(&self, bytes: &[mut u8], len: uint) -> uint {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
unsafe {
do vec::as_mut_buf(bytes) |buf_p, buf_len| {
assert buf_len >= len;
@ -464,7 +464,7 @@ struct Wrapper<T, C> {
// duration of its lifetime.
// FIXME there really should be a better way to do this // #2004
impl<R: Reader, C> Wrapper<R, C>: Reader {
fn read(&self, bytes: &[mut u8], len: uint) -> uint {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
self.base.read(bytes, len)
}
fn read_byte(&self) -> int { self.base.read_byte() }
@ -531,7 +531,7 @@ pub struct BytesReader {
}
impl BytesReader: Reader {
fn read(&self, bytes: &[mut u8], len: uint) -> uint {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
let count = uint::min(len, self.bytes.len() - self.pos);
let view = vec::view(self.bytes, self.pos, self.bytes.len());

View File

@ -254,7 +254,7 @@ impl Rng {
}
/// Shuffle a mutable vec in place
fn shuffle_mut<T>(values: &[mut T]) {
fn shuffle_mut<T>(values: &mut [T]) {
let mut i = values.len();
while i >= 2u {
// invariant: elements with index >= i have been locked in place.

View File

@ -1263,12 +1263,12 @@ pub pure fn zip<T, U>(v: ~[T], u: ~[U]) -> ~[(T, U)] {
* * a - The index of the first element
* * b - The index of the second element
*/
pub fn swap<T>(v: &[mut T], a: uint, b: uint) {
pub fn swap<T>(v: &mut [T], a: uint, b: uint) {
v[a] <-> v[b];
}
/// Reverse the order of elements in a vector, in place
pub fn reverse<T>(v: &[mut T]) {
pub fn reverse<T>(v: &mut [T]) {
let mut i: uint = 0;
let ln = len::<T>(v);
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) {
/// a vector with mutable contents and you would like
/// to mutate the contents as you iterate.
#[inline(always)]
pub fn each_mut<T>(v: &[mut T], f: fn(elem: &mut T) -> bool) {
pub fn each_mut<T>(v: &mut [T], f: fn(elem: &mut T) -> bool) {
let mut i = 0;
let n = v.len();
while i < n {
@ -1519,7 +1519,7 @@ pub pure fn as_const_buf<T,U>(s: &[const T],
/// Similar to `as_imm_buf` but passing a `*mut T`
#[inline(always)]
pub pure fn as_mut_buf<T,U>(s: &[mut T],
pub pure fn as_mut_buf<T,U>(s: &mut [T],
f: fn(*mut T, uint) -> U) -> U {
unsafe {
@ -2066,7 +2066,7 @@ pub mod raw {
/** see `to_ptr()` */
#[inline(always)]
pub unsafe fn to_mut_ptr<T>(v: &[mut T]) -> *mut T {
pub unsafe fn to_mut_ptr<T>(v: &mut [T]) -> *mut T {
let repr: **SliceRepr = ::cast::transmute(&v);
return ::cast::reinterpret_cast(&addr_of(&((**repr).data)));
}
@ -2099,7 +2099,7 @@ pub mod raw {
* is newly allocated.
*/
#[inline(always)]
pub unsafe fn init_elem<T>(v: &[mut T], i: uint, val: T) {
pub unsafe fn init_elem<T>(v: &mut [T], i: uint, val: T) {
let mut box = Some(val);
do as_mut_buf(v) |p, _len| {
let mut box2 = None;
@ -2133,7 +2133,7 @@ pub mod raw {
* may overlap.
*/
#[inline(always)]
pub unsafe fn copy_memory<T>(dst: &[mut T], src: &[const T],
pub unsafe fn copy_memory<T>(dst: &mut [T], src: &[const T],
count: uint) {
assert dst.len() >= count;
assert src.len() >= count;
@ -2199,8 +2199,12 @@ pub mod bytes {
* Copies `count` bytes from `src` to `dst`. The source and destination
* may overlap.
*/
<<<<<<< HEAD
#[inline(always)]
pub fn copy_memory(dst: &[mut u8], src: &[const u8], count: uint) {
=======
pub fn copy_memory(dst: &mut [u8], src: &[const u8], count: uint) {
>>>>>>> RIMOV, round 5
// Bound checks are done at vec::raw::copy_memory.
unsafe { vec::raw::copy_memory(dst, src, count) }
}

View File

@ -127,13 +127,13 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
}
}
fn all_mem(cls: &[mut x86_64_reg_class]) {
fn all_mem(cls: &mut [x86_64_reg_class]) {
for uint::range(0, cls.len()) |i| {
cls[i] = memory_class;
}
}
fn unify(cls: &[mut x86_64_reg_class],
fn unify(cls: &mut [x86_64_reg_class],
i: uint,
newv: x86_64_reg_class) {
if cls[i] == newv {
@ -159,7 +159,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
}
fn classify_struct(tys: &[TypeRef],
cls: &[mut x86_64_reg_class], i: uint,
cls: &mut [x86_64_reg_class], i: uint,
off: uint) {
let mut field_off = off;
for vec::each(tys) |ty| {
@ -170,7 +170,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
}
fn classify(ty: TypeRef,
cls: &[mut x86_64_reg_class], ix: uint,
cls: &mut [x86_64_reg_class], ix: uint,
off: uint) {
unsafe {
let t_align = ty_align(ty);
@ -220,7 +220,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
}
}
fn fixup(ty: TypeRef, cls: &[mut x86_64_reg_class]) {
fn fixup(ty: TypeRef, cls: &mut [x86_64_reg_class]) {
unsafe {
let mut i = 0u;
let llty = llvm::LLVMGetTypeKind(ty) as int;

View File

@ -778,7 +778,7 @@ pub impl LookupContext {
/*!
*
* In the event that we are invoking a method with a receiver
* of a linear borrowed type like `&mut T` or `&[mut T]`,
* of a linear borrowed type like `&mut T` or `&mut [T]`,
* we will "reborrow" the receiver implicitly. For example, if
* you have a call `r.inc()` and where `r` has type `&mut T`,
* then we treat that like `(&mut *r).inc()`. This avoids

View File

@ -43,7 +43,7 @@ pub impl BufReader {
}
impl BufReader: Reader {
fn read(&self, bytes: &[mut u8], len: uint) -> uint {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
self.as_bytes_reader(|r| r.read(bytes, len) )
}
fn read_byte(&self) -> int {

View File

@ -863,7 +863,7 @@ impl TcpSocket {
/// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket`
impl TcpSocketBuf: io::Reader {
fn read(&self, buf: &[mut u8], len: uint) -> uint {
fn read(&self, buf: &mut [u8], len: uint) -> uint {
if len == 0 { return 0 }
let mut count: uint = 0;

View File

@ -788,7 +788,7 @@ pub mod node {
* * forest - The forest. This vector is progressively rewritten during
* execution and should be discarded as meaningless afterwards.
*/
pub fn tree_from_forest_destructive(forest: &[mut @Node]) -> @Node {
pub fn tree_from_forest_destructive(forest: &mut [@Node]) -> @Node {
let mut i;
let mut len = vec::len(forest);
while len > 1u {

View File

@ -64,7 +64,7 @@ pub pure fn merge_sort<T: Copy>(v: &[const T], le: Le<T>) -> ~[T] {
}
}
fn part<T: Copy>(arr: &[mut T], left: uint,
fn part<T: Copy>(arr: &mut [T], left: uint,
right: uint, pivot: uint, compare_func: Le<T>) -> uint {
let pivot_value = arr[pivot];
arr[pivot] <-> arr[right];
@ -81,7 +81,7 @@ fn part<T: Copy>(arr: &[mut T], left: uint,
return storage_index;
}
fn qsort<T: Copy>(arr: &[mut T], left: uint,
fn qsort<T: Copy>(arr: &mut [T], left: uint,
right: uint, compare_func: Le<T>) {
if right > left {
let pivot = (left + right) / 2u;
@ -100,12 +100,12 @@ fn qsort<T: Copy>(arr: &[mut T], left: uint,
* Has worst case O(n^2) performance, average case O(n log n).
* This is an unstable sort.
*/
pub fn quick_sort<T: Copy>(arr: &[mut T], compare_func: Le<T>) {
pub fn quick_sort<T: Copy>(arr: &mut [T], compare_func: Le<T>) {
if len::<T>(arr) == 0u { return; }
qsort::<T>(arr, 0u, len::<T>(arr) - 1u, compare_func);
}
fn qsort3<T: Copy Ord Eq>(arr: &[mut T], left: int, right: int) {
fn qsort3<T: Copy Ord Eq>(arr: &mut [T], left: int, right: int) {
if right <= left { return; }
let v: T = arr[right];
let mut i: int = left - 1;
@ -162,7 +162,7 @@ fn qsort3<T: Copy Ord Eq>(arr: &[mut T], left: int, right: int) {
*
* This is an unstable sort.
*/
pub fn quick_sort3<T: Copy Ord Eq>(arr: &[mut T]) {
pub fn quick_sort3<T: Copy Ord Eq>(arr: &mut [T]) {
if arr.len() <= 1 { return; }
qsort3(arr, 0, (arr.len() - 1) as int);
}
@ -171,7 +171,7 @@ pub trait Sort {
fn qsort(self);
}
impl<T: Copy Ord Eq> &[mut T] : Sort {
impl<T: Copy Ord Eq> &mut [T] : Sort {
fn qsort(self) { quick_sort3(self); }
}
@ -179,7 +179,7 @@ const MIN_MERGE: uint = 64;
const MIN_GALLOP: uint = 7;
const INITIAL_TMP_STORAGE: uint = 128;
pub fn tim_sort<T: Copy Ord>(array: &[mut T]) {
pub fn tim_sort<T: Copy Ord>(array: &mut [T]) {
let size = array.len();
if size < 2 {
return;
@ -218,7 +218,7 @@ pub fn tim_sort<T: Copy Ord>(array: &[mut T]) {
ms.merge_force_collapse(array);
}
fn binarysort<T: Copy Ord>(array: &[mut T], start: uint) {
fn binarysort<T: Copy Ord>(array: &mut [T], start: uint) {
let size = array.len();
let mut start = start;
assert start <= size;
@ -249,7 +249,7 @@ fn binarysort<T: Copy Ord>(array: &[mut T], start: uint) {
}
// Reverse the order of elements in a slice, in place
fn reverse_slice<T>(v: &[mut T], start: uint, end:uint) {
fn reverse_slice<T>(v: &mut [T], start: uint, end:uint) {
let mut i = start;
while i < end / 2 {
util::swap(&mut v[i], &mut v[end - i - 1]);
@ -268,7 +268,7 @@ pure fn min_run_length(n: uint) -> uint {
return n + r;
}
fn count_run_ascending<T: Copy Ord>(array: &[mut T]) -> uint {
fn count_run_ascending<T: Copy Ord>(array: &mut [T]) -> uint {
let size = array.len();
assert size > 0;
if size == 1 { return 1; }
@ -412,7 +412,7 @@ impl<T: Copy Ord> MergeState<T> {
self.runs.push(tmp);
}
fn merge_at(&self, n: uint, array: &[mut T]) {
fn merge_at(&self, n: uint, array: &mut [T]) {
let mut size = self.runs.len();
assert size >= 2;
assert n == size-2 || n == size-3;
@ -453,7 +453,7 @@ impl<T: Copy Ord> MergeState<T> {
self.runs.pop();
}
fn merge_lo(&self, array: &[mut T], base1: uint, len1: uint,
fn merge_lo(&self, array: &mut [T], base1: uint, len1: uint,
base2: uint, len2: uint) {
assert len1 != 0 && len2 != 0 && base1+len1 == base2;
@ -556,7 +556,7 @@ impl<T: Copy Ord> MergeState<T> {
}
}
fn merge_hi(&self, array: &[mut T], base1: uint, len1: uint,
fn merge_hi(&self, array: &mut [T], base1: uint, len1: uint,
base2: uint, len2: uint) {
assert len1 != 1 && len2 != 0 && base1 + len1 == base2;
@ -674,7 +674,7 @@ impl<T: Copy Ord> MergeState<T> {
}
}
fn merge_collapse(&self, array: &[mut T]) {
fn merge_collapse(&self, array: &mut [T]) {
while self.runs.len() > 1 {
let mut n = self.runs.len()-2;
let chk = do self.runs.borrow |arr| {
@ -692,7 +692,7 @@ impl<T: Copy Ord> MergeState<T> {
}
}
fn merge_force_collapse(&self, array: &[mut T]) {
fn merge_force_collapse(&self, array: &mut [T]) {
while self.runs.len() > 1 {
let mut n = self.runs.len()-2;
if n > 0 {
@ -708,7 +708,7 @@ impl<T: Copy Ord> MergeState<T> {
}
#[inline(always)]
fn copy_vec<T: Copy>(dest: &[mut T], s1: uint,
fn copy_vec<T: Copy>(dest: &mut [T], s1: uint,
from: &[const T], s2: uint, len: uint) {
assert s1+len <= dest.len() && s2+len <= from.len();
@ -726,7 +726,7 @@ mod test_qsort3 {
use core::vec;
pub fn check_sort(v1: &[mut int], v2: &[mut int]) {
pub fn check_sort(v1: &mut [int], v2: &mut [int]) {
let len = vec::len::<int>(v1);
quick_sort3::<int>(v1);
let mut i = 0;
@ -772,7 +772,7 @@ mod test_qsort {
use core::int;
use core::vec;
pub fn check_sort(v1: &[mut int], v2: &[mut int]) {
pub fn check_sort(v1: &mut [int], v2: &mut [int]) {
let len = vec::len::<int>(v1);
pure fn leual(a: &int, b: &int) -> bool { *a <= *b }
quick_sort::<int>(v1, leual);
@ -923,7 +923,7 @@ mod test_tim_sort {
pure fn ge(&self, other: &CVal) -> bool { (*self).val >= other.val }
}
fn check_sort(v1: &[mut int], v2: &[mut int]) {
fn check_sort(v1: &mut [int], v2: &mut [int]) {
let len = vec::len::<int>(v1);
tim_sort::<int>(v1);
let mut i = 0u;

View File

@ -16,7 +16,7 @@ fn eval_A(i: uint, j: uint) -> float {
1.0/(((i+j)*(i+j+1u)/2u+i+1u) as float)
}
fn eval_A_times_u(u: &[const float], Au: &[mut float]) {
fn eval_A_times_u(u: &[const float], Au: &mut [float]) {
let N = vec::len(u);
let mut i = 0u;
while i < N {
@ -30,7 +30,7 @@ fn eval_A_times_u(u: &[const float], Au: &[mut float]) {
}
}
fn eval_At_times_u(u: &[const float], Au: &[mut float]) {
fn eval_At_times_u(u: &[const float], Au: &mut [float]) {
let N = vec::len(u);
let mut i = 0u;
while i < N {
@ -44,7 +44,7 @@ fn eval_At_times_u(u: &[const float], Au: &[mut float]) {
}
}
fn eval_AtA_times_u(u: &[const float], AtAu: &[mut float]) {
fn eval_AtA_times_u(u: &[const float], AtAu: &mut [float]) {
let v = vec::cast_to_mut(vec::from_elem(vec::len(u), 0.0));
eval_A_times_u(u, v);
eval_At_times_u(v, AtAu);

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn write(v: &[mut int]) {
fn write(v: &mut [int]) {
v[0] += 1;
}

View File

@ -9,7 +9,7 @@
// except according to those terms.
// xfail-test
fn function() -> &[mut int] {
fn function() -> &mut [int] {
let mut x: &static/[int] = &[1,2,3];
x[0] = 12345;
x //~ ERROR bad

View File

@ -4,7 +4,7 @@ pure fn sum(x: &[int]) -> int {
return sum;
}
fn sum_mut(y: &[mut int]) -> int {
fn sum_mut(y: &mut [int]) -> int {
sum(y)
}

View File

@ -2,7 +2,7 @@ fn foo(v: &[const uint]) -> ~[uint] {
v.to_vec()
}
fn bar(v: &[mut uint]) -> ~[uint] {
fn bar(v: &mut [uint]) -> ~[uint] {
v.to_vec()
}

View File

@ -2,7 +2,7 @@ trait Reverser {
fn reverse(&self);
}
fn bar(v: &[mut uint]) {
fn bar(v: &mut [uint]) {
vec::reverse(v);
vec::reverse(v);
vec::reverse(v);

View File

@ -2,13 +2,13 @@ trait Reverser {
fn reverse(&self);
}
impl &[mut uint] : Reverser {
impl &mut [uint] : Reverser {
fn reverse(&self) {
vec::reverse(*self);
}
}
fn bar(v: &[mut uint]) {
fn bar(v: &mut [uint]) {
v.reverse();
v.reverse();
v.reverse();

View File

@ -4,7 +4,7 @@ pub trait Reader {
/// Read up to len bytes (or EOF) and put them into bytes (which
/// must be at least len bytes long). Return number of bytes read.
// FIXME (#2982): This should probably return an error.
fn read(&self, bytes: &[mut u8], len: uint) -> uint;
fn read(&self, bytes: &mut [u8], len: uint) -> uint;
}
pub trait ReaderUtil {
@ -27,7 +27,7 @@ struct S {
}
impl S: Reader {
fn read(&self, bytes: &[mut u8], len: uint) -> uint {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
0
}
}

View File

@ -4,7 +4,7 @@ pub trait Reader {
/// Read up to len bytes (or EOF) and put them into bytes (which
/// must be at least len bytes long). Return number of bytes read.
// FIXME (#2982): This should probably return an error.
fn read(&self, bytes: &[mut u8], len: uint) -> uint;
fn read(&self, bytes: &mut [u8], len: uint) -> uint;
}
pub trait ReaderUtil {
@ -27,7 +27,7 @@ struct S {
}
impl S: Reader {
fn read(&self, bytes: &[mut u8], len: uint) -> uint {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
0
}
}

View File

@ -4,7 +4,7 @@ pub trait Reader {
/// Read up to len bytes (or EOF) and put them into bytes (which
/// must be at least len bytes long). Return number of bytes read.
// FIXME (#2982): This should probably return an error.
fn read(&self, bytes: &[mut u8], len: uint) -> uint;
fn read(&self, bytes: &mut [u8], len: uint) -> uint;
}
pub trait ReaderUtil {
@ -27,7 +27,7 @@ struct S {
}
impl S: Reader {
fn read(&self, bytes: &[mut u8], len: uint) -> uint {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
0
}
}

View File

@ -4,7 +4,7 @@ pub trait Reader {
/// Read up to len bytes (or EOF) and put them into bytes (which
/// must be at least len bytes long). Return number of bytes read.
// FIXME (#2982): This should probably return an error.
fn read(bytes: &[mut u8], len: uint) -> uint;
fn read(bytes: &mut [u8], len: uint) -> uint;
}
pub trait ReaderUtil {
@ -27,7 +27,7 @@ struct S {
}
impl S: Reader {
fn read(bytes: &[mut u8], len: uint) -> uint {
fn read(bytes: &mut [u8], len: uint) -> uint {
0
}
}

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn swap<T>(v: &[mut T], i: int, j: int) { v[i] <-> v[j]; }
fn swap<T>(v: &mut [T], i: int, j: int) { v[i] <-> v[j]; }
fn main() {
let mut a: ~[int] = ~[0, 1, 2, 3, 4, 5, 6];