diff options
Diffstat (limited to 'src/test')
29 files changed, 49 insertions, 63 deletions
diff --git a/src/test/bench/noise.rs b/src/test/bench/noise.rs index 4ad77a695dd..1c530e3851e 100644 --- a/src/test/bench/noise.rs +++ b/src/test/bench/noise.rs @@ -52,7 +52,7 @@ impl Noise2DContext { for (i, x) in permutations.iter_mut().enumerate() { *x = i as i32; } - rng.shuffle(permutations); + rng.shuffle(&mut permutations); Noise2DContext { rgradients: rgradients, permutations: permutations } } diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index b4292c2b050..b38b8e66d7d 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -118,7 +118,7 @@ impl Perm { fn max(&self) -> u32 { self.fact[self.n as uint] } fn next(&mut self) -> P { - next_permutation(self.perm.p, self.cnt); + next_permutation(&mut self.perm.p, &mut self.cnt); self.permcount += 1; self.perm @@ -141,7 +141,7 @@ fn work(mut perm: Perm, n: uint, max: uint) -> (i32, i32) { while p.p[0] != 1 { let k = p.p[0] as uint; - reverse(p.p, k); + reverse(&mut p.p, k); flips += 1; } diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index 0a3370fa487..0b4a1d91968 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -198,7 +198,7 @@ impl<'a, W: Writer> RandomFasta<'a, W> { buf[i] = self.nextc(); } buf[LINE_LEN] = '\n' as u8; - try!(self.out.write(buf)); + try!(self.out.write(&buf)); } for i in range(0u, chars_left) { buf[i] = self.nextc(); @@ -225,12 +225,12 @@ fn main() { } out.write_line(">TWO IUB ambiguity codes").unwrap(); - let iub = sum_and_scale(IUB); + let iub = sum_and_scale(&IUB); let mut random = RandomFasta::new(&mut out, iub.as_slice()); random.make(n * 3).unwrap(); random.out.write_line(">THREE Homo sapiens frequency").unwrap(); - let homo_sapiens = sum_and_scale(HOMO_SAPIENS); + let homo_sapiens = sum_and_scale(&HOMO_SAPIENS); random.lookup = make_lookup(homo_sapiens.as_slice()); random.make(n * 5).unwrap(); diff --git a/src/test/compile-fail/lint-uppercase-variables.rs b/src/test/compile-fail/lint-uppercase-variables.rs index 902cd63b1e7..2f840ee0761 100644 --- a/src/test/compile-fail/lint-uppercase-variables.rs +++ b/src/test/compile-fail/lint-uppercase-variables.rs @@ -30,7 +30,7 @@ fn main() { let mut f = File::open(&Path::new("something.txt")); let mut buff = [0u8, ..16]; - match f.read(buff) { + match f.read(&mut buff) { Ok(cnt) => println!("read this many bytes: {}", cnt), Err(IoError{ kind: EndOfFile, .. }) => println!("Got end of file: {}", EndOfFile.to_string()), //~^ ERROR variable `EndOfFile` should have a snake case name such as `end_of_file` diff --git a/src/test/compile-fail/non-exhaustive-pattern-witness.rs b/src/test/compile-fail/non-exhaustive-pattern-witness.rs index 7f1204ceee8..55cdcdce82c 100644 --- a/src/test/compile-fail/non-exhaustive-pattern-witness.rs +++ b/src/test/compile-fail/non-exhaustive-pattern-witness.rs @@ -54,7 +54,7 @@ enum Enum { } fn vectors_with_nested_enums() { - let x: &'static [Enum] = [First, Second(false)]; + let x: &'static [Enum] = &[First, Second(false)]; match x { //~^ ERROR non-exhaustive patterns: `[Second(true), Second(false)]` not covered [] => (), diff --git a/src/test/pretty/issue-4264.pp b/src/test/pretty/issue-4264.pp index c5229f0f9f9..f3c749da95f 100644 --- a/src/test/pretty/issue-4264.pp +++ b/src/test/pretty/issue-4264.pp @@ -39,8 +39,9 @@ pub fn bar() { () => { #[inline] #[allow(dead_code)] - static __STATIC_FMTSTR: [&'static str, ..(1u as uint)] = - ([("test" as &'static str)] as [&'static str, ..1]); + static __STATIC_FMTSTR: &'static [&'static str] = + (&([("test" as &'static str)] as [&'static str, ..1]) as + &'static [&'static str, ..1]); let __args_vec = (&([] as [core::fmt::Argument<'_>, ..0]) as &[core::fmt::Argument<'_>, ..0]); @@ -49,7 +50,7 @@ pub fn bar() { ((::std::fmt::Arguments::new as unsafe fn(&'static [&'static str], &'a [core::fmt::Argument<'a>]) -> core::fmt::Arguments<'a>)((__STATIC_FMTSTR as - [&'static str, ..1]), + &'static [&'static str]), (__args_vec as &[core::fmt::Argument<'_>, ..0])) diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs index 0d90636ec91..f822da4cdcf 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -53,5 +53,5 @@ pub fn main() { // Call a method z.iterate(|y| { assert!(z[*y as uint] == *y); true }); // Call a parameterized function - assert_eq!(length::<int, &[int]>(z), z.len()); + assert_eq!(length::<int, &[int]>(&z), z.len()); } diff --git a/src/test/run-pass/borrowck-freeze-frozen-mut.rs b/src/test/run-pass/borrowck-freeze-frozen-mut.rs index f224042bc79..21f5d0e6c14 100644 --- a/src/test/run-pass/borrowck-freeze-frozen-mut.rs +++ b/src/test/run-pass/borrowck-freeze-frozen-mut.rs @@ -21,7 +21,7 @@ fn get<'a, T>(ms: &'a MutSlice<'a, T>, index: uint) -> &'a T { pub fn main() { let mut data = [1i, 2, 3]; { - let slice = MutSlice { data: data }; + let slice = MutSlice { data: &mut data }; slice.data[0] += 4; let index0 = get(&slice, 0); let index1 = get(&slice, 1); diff --git a/src/test/run-pass/capture-clauses-boxed-closures.rs b/src/test/run-pass/capture-clauses-boxed-closures.rs index a1411146ddd..d24b9332917 100644 --- a/src/test/run-pass/capture-clauses-boxed-closures.rs +++ b/src/test/run-pass/capture-clauses-boxed-closures.rs @@ -17,7 +17,7 @@ fn each<T>(x: &[T], f: |&T|) { fn main() { let mut sum = 0u; let elems = [ 1u, 2, 3, 4, 5 ]; - each(elems, |val| sum += *val); + each(&elems, |val| sum += *val); assert_eq!(sum, 15); } diff --git a/src/test/run-pass/capture-clauses-unboxed-closures.rs b/src/test/run-pass/capture-clauses-unboxed-closures.rs index a826f4df5b3..9f333fd043f 100644 --- a/src/test/run-pass/capture-clauses-unboxed-closures.rs +++ b/src/test/run-pass/capture-clauses-unboxed-closures.rs @@ -19,6 +19,6 @@ fn each<'a,T,F:FnMut(&'a T)>(x: &'a [T], mut f: F) { fn main() { let mut sum = 0u; let elems = [ 1u, 2, 3, 4, 5 ]; - each(elems, |&mut: val: &uint| sum += *val); + each(&elems, |&mut: val: &uint| sum += *val); assert_eq!(sum, 15); } diff --git a/src/test/run-pass/cci_iter_exe.rs b/src/test/run-pass/cci_iter_exe.rs index df03c93dad3..7191d5078b8 100644 --- a/src/test/run-pass/cci_iter_exe.rs +++ b/src/test/run-pass/cci_iter_exe.rs @@ -15,7 +15,7 @@ extern crate cci_iter_lib; pub fn main() { //let bt0 = sys::rusti::frame_address(1u32); //println!("%?", bt0); - cci_iter_lib::iter([1i, 2, 3], |i| { + cci_iter_lib::iter(&[1i, 2, 3], |i| { println!("{}", *i); //assert!(bt0 == sys::rusti::frame_address(2u32)); }) diff --git a/src/test/run-pass/const-str-ptr.rs b/src/test/run-pass/const-str-ptr.rs index 7395a997a05..47d59eca263 100644 --- a/src/test/run-pass/const-str-ptr.rs +++ b/src/test/run-pass/const-str-ptr.rs @@ -17,13 +17,13 @@ const C: *const u8 = B as *const u8; pub fn main() { unsafe { let foo = &A as *const u8; - assert_eq!(str::raw::from_utf8(A), "hi"); + assert_eq!(str::raw::from_utf8(&A), "hi"); assert_eq!(string::raw::from_buf_len(foo, A.len()), "hi".to_string()); assert_eq!(string::raw::from_buf_len(C, B.len()), "hi".to_string()); assert!(*C == A[0]); assert!(*(&B[0] as *const u8) == A[0]); - let bar = str::raw::from_utf8(A).to_c_str(); + let bar = str::raw::from_utf8(&A).to_c_str(); assert_eq!(bar.as_str(), "hi".to_c_str().as_str()); } } diff --git a/src/test/run-pass/const-vec-syntax.rs b/src/test/run-pass/const-vec-syntax.rs index 84ee54cfdde..c0566277e4e 100644 --- a/src/test/run-pass/const-vec-syntax.rs +++ b/src/test/run-pass/const-vec-syntax.rs @@ -12,5 +12,5 @@ fn f(_: &[int]) {} pub fn main() { let v = [ 1, 2, 3 ]; - f(v); + f(&v); } diff --git a/src/test/run-pass/const-vecs-and-slices.rs b/src/test/run-pass/const-vecs-and-slices.rs index c61f26e0bb6..1a2a3e36e87 100644 --- a/src/test/run-pass/const-vecs-and-slices.rs +++ b/src/test/run-pass/const-vecs-and-slices.rs @@ -11,7 +11,7 @@ static x : [int, ..4] = [1,2,3,4]; static y : &'static [int] = &[1,2,3,4]; static z : &'static [int, ..4] = &[1,2,3,4]; -static zz : &'static [int] = [1,2,3,4]; +static zz : &'static [int] = &[1,2,3,4]; pub fn main() { println!("{}", x[1]); diff --git a/src/test/run-pass/issue-11205.rs b/src/test/run-pass/issue-11205.rs index c2c291c0bec..89224e1fb12 100644 --- a/src/test/run-pass/issue-11205.rs +++ b/src/test/run-pass/issue-11205.rs @@ -72,11 +72,11 @@ fn main() { let r = &1i; let r: [&Foo, ..2] = [r, ..2]; let _n = F { - t: r + t: &r }; let x: [&Foo, ..2] = [&1i, &2i]; let _n = F { - t: x + t: &x }; struct M<'a> { @@ -87,6 +87,6 @@ fn main() { }; let x: [Box<Foo>, ..2] = [box 1i, box 2i]; let _n = M { - t: x + t: &x }; } diff --git a/src/test/run-pass/issue-12028.rs b/src/test/run-pass/issue-12028.rs index 4d64103e502..dbfa330d33d 100644 --- a/src/test/run-pass/issue-12028.rs +++ b/src/test/run-pass/issue-12028.rs @@ -37,7 +37,7 @@ impl<S: Stream, H: StreamHasher<S>> Hash<H> for u8 { impl<S: Stream, H: StreamHasher<S>> StreamHash<S, H> for u8 { fn input_stream(&self, stream: &mut S) { - stream.input([*self]); + stream.input(&[*self]); } } diff --git a/src/test/run-pass/issue-14940.rs b/src/test/run-pass/issue-14940.rs index acadc81df63..cef09af1fcf 100644 --- a/src/test/run-pass/issue-14940.rs +++ b/src/test/run-pass/issue-14940.rs @@ -15,7 +15,7 @@ fn main() { let args = os::args(); if args.len() > 1 { let mut out = stdio::stdout(); - out.write(['a' as u8, ..128 * 1024]).unwrap(); + out.write(&['a' as u8, ..128 * 1024]).unwrap(); } else { let out = Command::new(args[0].as_slice()).arg("child").output(); let out = out.unwrap(); diff --git a/src/test/run-pass/issue-15080.rs b/src/test/run-pass/issue-15080.rs index 1709321a71c..c2c370ae504 100644 --- a/src/test/run-pass/issue-15080.rs +++ b/src/test/run-pass/issue-15080.rs @@ -26,5 +26,5 @@ fn main() { break } } - assert!(result.as_slice() == [2, 4]); + assert!(result.as_slice() == &[2, 4]); } diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 04866c56913..f4206312edb 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -63,7 +63,7 @@ fn read_board_grid<rdr:'static + io::Reader>(mut input: rdr) let mut input: &mut io::Reader = &mut input; let mut grid = Vec::new(); let mut line = [0, ..10]; - input.read(line); + input.read(&mut line); let mut row = Vec::new(); for c in line.iter() { row.push(square_from_char(*c as char)) diff --git a/src/test/run-pass/issue-7784.rs b/src/test/run-pass/issue-7784.rs index 666847517ef..f0310cd8df3 100644 --- a/src/test/run-pass/issue-7784.rs +++ b/src/test/run-pass/issue-7784.rs @@ -33,6 +33,6 @@ fn main() { let out = bar("baz", "foo"); let [a, xs.., d] = out; assert_eq!(a, "baz"); - assert!(xs == ["foo", "foo"]); + assert!(xs == &["foo", "foo"]); assert_eq!(d, "baz"); } diff --git a/src/test/run-pass/issue-8398.rs b/src/test/run-pass/issue-8398.rs index 0884db63326..185d75743a4 100644 --- a/src/test/run-pass/issue-8398.rs +++ b/src/test/run-pass/issue-8398.rs @@ -11,7 +11,7 @@ use std::io; fn foo(a: &mut io::Writer) { - a.write([]).unwrap(); + a.write(&[]).unwrap(); } pub fn main(){} diff --git a/src/test/run-pass/issue-9249.rs b/src/test/run-pass/issue-9249.rs index 013aef57223..2795fd59c0c 100644 --- a/src/test/run-pass/issue-9249.rs +++ b/src/test/run-pass/issue-9249.rs @@ -8,5 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -static DATA:&'static [&'static str] = ["my string"]; +static DATA:&'static [&'static str] = &["my string"]; fn main() { } diff --git a/src/test/run-pass/regions-borrow-evec-fixed.rs b/src/test/run-pass/regions-borrow-evec-fixed.rs index 9022ff92c8f..0264e64f70d 100644 --- a/src/test/run-pass/regions-borrow-evec-fixed.rs +++ b/src/test/run-pass/regions-borrow-evec-fixed.rs @@ -13,6 +13,6 @@ fn foo(x: &[int]) -> int { } pub fn main() { - let p = [1,2,3,4,5]; + let p = &[1,2,3,4,5]; assert_eq!(foo(p), 1); } diff --git a/src/test/run-pass/rename-directory.rs b/src/test/run-pass/rename-directory.rs index 43a62524717..b5cee20232b 100644 --- a/src/test/run-pass/rename-directory.rs +++ b/src/test/run-pass/rename-directory.rs @@ -25,7 +25,7 @@ fn rename_directory() { let tmpdir = TempDir::new("rename_directory").ok().expect("rename_directory failed"); let tmpdir = tmpdir.path(); - let old_path = tmpdir.join_many(["foo", "bar", "baz"]); + let old_path = tmpdir.join_many(&["foo", "bar", "baz"]); fs::mkdir_recursive(&old_path, io::USER_RWX); let test_file = &old_path.join("temp.txt"); @@ -46,11 +46,11 @@ fn rename_directory() { }); assert_eq!(libc::fclose(ostream), (0u as libc::c_int)); - let new_path = tmpdir.join_many(["quux", "blat"]); + let new_path = tmpdir.join_many(&["quux", "blat"]); fs::mkdir_recursive(&new_path, io::USER_RWX); fs::rename(&old_path, &new_path.join("newdir")); assert!(new_path.join("newdir").is_dir()); - assert!(new_path.join_many(["newdir", "temp.txt"]).exists()); + assert!(new_path.join_many(&["newdir", "temp.txt"]).exists()); } } diff --git a/src/test/run-pass/sigpipe-should-be-ignored.rs b/src/test/run-pass/sigpipe-should-be-ignored.rs index 8c68ef173a5..1804dd2e135 100644 --- a/src/test/run-pass/sigpipe-should-be-ignored.rs +++ b/src/test/run-pass/sigpipe-should-be-ignored.rs @@ -21,7 +21,7 @@ fn test() { let mut writer = PipeStream::open(writer); drop(reader); - let _ = writer.write([1]); + let _ = writer.write(&[1]); } fn main() { diff --git a/src/test/run-pass/stat.rs b/src/test/run-pass/stat.rs index 67728e6c8dd..250eafa2f49 100644 --- a/src/test/run-pass/stat.rs +++ b/src/test/run-pass/stat.rs @@ -21,7 +21,7 @@ pub fn main() { Ok(f) => { let mut f = f; for _ in range(0u, 1000) { - f.write([0]); + f.write(&[0]); } } } diff --git a/src/test/run-pass/utf8_chars.rs b/src/test/run-pass/utf8_chars.rs index 30f6f4b464e..d343e485b24 100644 --- a/src/test/run-pass/utf8_chars.rs +++ b/src/test/run-pass/utf8_chars.rs @@ -27,17 +27,17 @@ pub fn main() { assert!((str::is_utf8(s.as_bytes()))); // invalid prefix - assert!((!str::is_utf8([0x80_u8]))); + assert!((!str::is_utf8(&[0x80_u8]))); // invalid 2 byte prefix - assert!((!str::is_utf8([0xc0_u8]))); - assert!((!str::is_utf8([0xc0_u8, 0x10_u8]))); + assert!((!str::is_utf8(&[0xc0_u8]))); + assert!((!str::is_utf8(&[0xc0_u8, 0x10_u8]))); // invalid 3 byte prefix - assert!((!str::is_utf8([0xe0_u8]))); - assert!((!str::is_utf8([0xe0_u8, 0x10_u8]))); - assert!((!str::is_utf8([0xe0_u8, 0xff_u8, 0x10_u8]))); + assert!((!str::is_utf8(&[0xe0_u8]))); + assert!((!str::is_utf8(&[0xe0_u8, 0x10_u8]))); + assert!((!str::is_utf8(&[0xe0_u8, 0xff_u8, 0x10_u8]))); // invalid 4 byte prefix - assert!((!str::is_utf8([0xf0_u8]))); - assert!((!str::is_utf8([0xf0_u8, 0x10_u8]))); - assert!((!str::is_utf8([0xf0_u8, 0xff_u8, 0x10_u8]))); - assert!((!str::is_utf8([0xf0_u8, 0xff_u8, 0xff_u8, 0x10_u8]))); + assert!((!str::is_utf8(&[0xf0_u8]))); + assert!((!str::is_utf8(&[0xf0_u8, 0x10_u8]))); + assert!((!str::is_utf8(&[0xf0_u8, 0xff_u8, 0x10_u8]))); + assert!((!str::is_utf8(&[0xf0_u8, 0xff_u8, 0xff_u8, 0x10_u8]))); } diff --git a/src/test/run-pass/vec-dst.rs b/src/test/run-pass/vec-dst.rs index 11b58948e05..d8bf0a5c627 100644 --- a/src/test/run-pass/vec-dst.rs +++ b/src/test/run-pass/vec-dst.rs @@ -8,17 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn sub_expr() { - // Test for a &[T] => &&[T] coercion in sub-expression position - // (surprisingly, this can cause errors which are not caused by either of: - // `let x = vec.slice_mut(0, 2);` - // `foo(vec.slice_mut(0, 2));` ). - let mut vec: Vec<int> = vec!(1, 2, 3, 4); - let b: &mut [int] = [1, 2]; - assert!(vec.slice_mut(0, 2) == b); -} - -fn index() { +pub fn main() { // Tests for indexing into box/& [T, ..n] let x: [int, ..3] = [1, 2, 3]; let mut x: Box<[int, ..3]> = box x; @@ -40,8 +30,3 @@ fn index() { assert!(x[1] == 45); assert!(x[2] == 3); } - -pub fn main() { - sub_expr(); - index(); -} diff --git a/src/test/run-pass/vec-matching-fold.rs b/src/test/run-pass/vec-matching-fold.rs index 63914a8df31..cc2061c3cf3 100644 --- a/src/test/run-pass/vec-matching-fold.rs +++ b/src/test/run-pass/vec-matching-fold.rs @@ -33,7 +33,7 @@ fn foldr<T,U:Clone>(values: &[T], } pub fn main() { - let x = [1i, 2, 3, 4, 5]; + let x = &[1i, 2, 3, 4, 5]; let product = foldl(x, 1i, |a, b| a * *b); assert_eq!(product, 120); |
