Removing interior mut on vectors, round 1

find ./ -type f -name "*.rs" -exec sed -i "s/let mut\(.*\)\[mut[ ]\?/let
mut\1\[/g" {} \;
This commit is contained in:
Ben Striegel 2013-01-29 21:02:53 -05:00
parent 7d8ae4403e
commit a8ff91a630
7 changed files with 10 additions and 10 deletions

View file

@ -289,7 +289,7 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program {
fn read_all(rd: io::Reader) -> ~str {
let buf = io::with_bytes_writer(|wr| {
let mut bytes = [mut 0, ..4096];
let mut bytes = [0, ..4096];
while !rd.eof() {
let nread = rd.read(bytes, bytes.len());
wr.write(bytes.view(0, nread));
@ -387,7 +387,7 @@ pub fn readclose(fd: c_int) -> ~str {
let file = os::fdopen(fd);
let reader = io::FILE_reader(file, false);
let buf = io::with_bytes_writer(|writer| {
let mut bytes = [mut 0, ..4096];
let mut bytes = [0, ..4096];
while !reader.eof() {
let nread = reader.read(bytes, bytes.len());
writer.write(bytes.view(0, nread));

View file

@ -156,7 +156,7 @@ fn readclose(fd: libc::c_int) -> ~str {
let file = os::fdopen(fd);
let reader = io::FILE_reader(file, false);
let buf = io::with_bytes_writer(|writer| {
let mut bytes = [mut 0, ..4096];
let mut bytes = [0, ..4096];
while !reader.eof() {
let nread = reader.read(bytes, bytes.len());
writer.write(bytes.view(0, nread));

View file

@ -9,7 +9,7 @@
// except according to those terms.
fn main() {
let mut x: ~[mut int] = ~[mut 3];
let mut x: ~[mut int] = ~[3];
let y: ~[int] = ~[3];
x = y; //~ ERROR values differ in mutability
}

View file

@ -11,7 +11,7 @@
type point = { x: int, y: int };
fn a() {
let mut p = ~[mut 1];
let mut p = ~[1];
// Create an immutable pointer into p's contents:
let _q: &int = &p[0]; //~ NOTE loan of mutable vec content granted here
@ -25,7 +25,7 @@ fn b() {
// here we alias the mutable vector into an imm slice and try to
// modify the original:
let mut p = ~[mut 1];
let mut p = ~[1];
do borrow(p) { //~ NOTE loan of mutable vec content granted here
p[0] = 5; //~ ERROR assigning to mutable vec content prohibited due to outstanding loan
@ -35,7 +35,7 @@ fn b() {
fn c() {
// Legal because the scope of the borrow does not include the
// modification:
let mut p = ~[mut 1];
let mut p = ~[1];
borrow(p, ||{});
p[0] = 5;
}

View file

@ -33,7 +33,7 @@ fn main() {
{
let mut res = foo(x);
let mut v = ~[mut];
let mut v = ~[];
v = move ~[mut (move res)] + v; //~ ERROR instantiating a type parameter with an incompatible type (needs `copy`, got `&static`, missing `copy`)
assert (v.len() == 2);
}

View file

@ -12,7 +12,7 @@
fn main()
{
// See #2969 -- error message should be improved
let mut x = [mut 1, 2, 4];
let mut x = [1, 2, 4];
let v : &int = &x[2];
x[2] = 6;
assert *v == 6;

View file

@ -10,7 +10,7 @@
// xfail-test
fn function() -> &[mut int] {
let mut x: &static/[mut int] = &[mut 1,2,3];
let mut x: &static/[mut int] = &[1,2,3];
x[0] = 12345;
x //~ ERROR bad
}