diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2015-02-01 21:53:25 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2015-02-05 13:45:01 -0500 |
| commit | 17bc7d8d5be3be9674d702ccad2fa88c487d23b0 (patch) | |
| tree | 325defba0f55b48273cd3f0814fe6c083dee5d41 /src/test | |
| parent | 2c05354211b04a52cc66a0b8ad8b2225eaf9e972 (diff) | |
cleanup: replace `as[_mut]_slice()` calls with deref coercions
Diffstat (limited to 'src/test')
128 files changed, 294 insertions, 297 deletions
diff --git a/src/test/auxiliary/plugin_args.rs b/src/test/auxiliary/plugin_args.rs index e01a95d461b..6779cf997c1 100644 --- a/src/test/auxiliary/plugin_args.rs +++ b/src/test/auxiliary/plugin_args.rs @@ -38,7 +38,7 @@ impl TTMacroExpander for Expander { let attr = ecx.attribute(sp, self.args.clone()); let src = pprust::attribute_to_string(&attr); - let interned = token::intern_and_get_ident(src.as_slice()); + let interned = token::intern_and_get_ident(&src); MacExpr::new(ecx.expr_str(sp, interned)) } } diff --git a/src/test/auxiliary/roman_numerals.rs b/src/test/auxiliary/roman_numerals.rs index 3096adaaf11..3fe7a29256d 100644 --- a/src/test/auxiliary/roman_numerals.rs +++ b/src/test/auxiliary/roman_numerals.rs @@ -46,7 +46,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) } }; - let mut text = text.as_slice(); + let mut text = &*text; let mut total = 0u; while !text.is_empty() { match NUMERALS.iter().find(|&&(rn, _)| text.starts_with(rn)) { diff --git a/src/test/auxiliary/static-methods-crate.rs b/src/test/auxiliary/static-methods-crate.rs index 6cb16f04ce1..d84ded25702 100644 --- a/src/test/auxiliary/static-methods-crate.rs +++ b/src/test/auxiliary/static-methods-crate.rs @@ -25,7 +25,7 @@ impl read for int { impl read for bool { fn readMaybe(s: String) -> Option<bool> { - match s.as_slice() { + match &*s { "true" => Some(true), "false" => Some(false), _ => None diff --git a/src/test/bench/core-map.rs b/src/test/bench/core-map.rs index 8330c159769..12c95e4c60c 100644 --- a/src/test/bench/core-map.rs +++ b/src/test/bench/core-map.rs @@ -102,7 +102,7 @@ fn vector<M: MutableMap>(map: &mut M, n_keys: uint, dist: &[uint]) { fn main() { let args = os::args(); - let args = args.as_slice(); + let args = args; let n_keys = { if args.len() == 2 { args[1].parse::<uint>().unwrap() @@ -143,7 +143,7 @@ fn main() { { println!(" Random integers:"); let mut map: BTreeMap<uint,uint> = BTreeMap::new(); - vector(&mut map, n_keys, rand.as_slice()); + vector(&mut map, n_keys, &rand); } // FIXME: #9970 @@ -162,6 +162,6 @@ fn main() { { println!(" Random integers:"); let mut map: HashMap<uint,uint> = HashMap::new(); - vector(&mut map, n_keys, rand.as_slice()); + vector(&mut map, n_keys, &rand); } } diff --git a/src/test/bench/core-set.rs b/src/test/bench/core-set.rs index b78b147348a..33ac8a43b43 100644 --- a/src/test/bench/core-set.rs +++ b/src/test/bench/core-set.rs @@ -180,7 +180,7 @@ fn empty_results() -> Results { fn main() { let args = os::args(); - let args = args.as_slice(); + let args = args; let num_keys = { if args.len() == 2 { args[1].parse::<uint>().unwrap() diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 388868eee70..991c08f60be 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -29,7 +29,7 @@ fn main() { macro_rules! bench { ($id:ident) => - (maybe_run_test(argv.as_slice(), + (maybe_run_test(&argv, stringify!($id).to_string(), $id)) } @@ -94,7 +94,7 @@ fn vec_plus() { v.extend(rv.into_iter()); } else { let mut rv = rv.clone(); - rv.push_all(v.as_slice()); + rv.push_all(&v); v = rv; } i += 1; @@ -110,12 +110,12 @@ fn vec_append() { let rv = repeat(i).take(r.gen_range(0u, i + 1)).collect::<Vec<_>>(); if r.gen() { let mut t = v.clone(); - t.push_all(rv.as_slice()); + t.push_all(&rv); v = t; } else { let mut t = rv.clone(); - t.push_all(v.as_slice()); + t.push_all(&v); v = t; } i += 1; @@ -129,11 +129,11 @@ fn vec_push_all() { for i in 0u..1500 { let mut rv = repeat(i).take(r.gen_range(0u, i + 1)).collect::<Vec<_>>(); if r.gen() { - v.push_all(rv.as_slice()); + v.push_all(&rv); } else { swap(&mut v, &mut rv); - v.push_all(rv.as_slice()); + v.push_all(&rv); } } } @@ -142,7 +142,7 @@ fn is_utf8_ascii() { let mut v : Vec<u8> = Vec::new(); for _ in 0u..20000 { v.push('b' as u8); - if str::from_utf8(v.as_slice()).is_err() { + if str::from_utf8(&v).is_err() { panic!("from_utf8 panicked"); } } @@ -153,7 +153,7 @@ fn is_utf8_multibyte() { let mut v : Vec<u8> = Vec::new(); for _ in 0u..5000 { v.push_all(s.as_bytes()); - if str::from_utf8(v.as_slice()).is_err() { + if str::from_utf8(&v).is_err() { panic!("from_utf8 panicked"); } } diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index 259b4d9418d..be42cb277f7 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -103,5 +103,5 @@ fn main() { }; println!("{:?}", args); - run(args.as_slice()); + run(&args); } diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index 1341c03e505..d9eea02a176 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -110,5 +110,5 @@ fn main() { }; println!("{:?}", args); - run(args.as_slice()); + run(&args); } diff --git a/src/test/bench/rt-messaging-ping-pong.rs b/src/test/bench/rt-messaging-ping-pong.rs index a67deac67db..e4e8b4a6e6e 100644 --- a/src/test/bench/rt-messaging-ping-pong.rs +++ b/src/test/bench/rt-messaging-ping-pong.rs @@ -65,7 +65,7 @@ fn ping_pong_bench(n: uint, m: uint) { fn main() { let args = os::args(); - let args = args.as_slice(); + let args = args; let n = if args.len() == 3 { args[1].parse::<uint>().unwrap() } else { diff --git a/src/test/bench/rt-parfib.rs b/src/test/bench/rt-parfib.rs index 7dc94efcf91..13b8a5ca763 100644 --- a/src/test/bench/rt-parfib.rs +++ b/src/test/bench/rt-parfib.rs @@ -32,7 +32,7 @@ fn parfib(n: uint) -> uint { fn main() { let args = os::args(); - let args = args.as_slice(); + let args = args; let n = if args.len() == 2 { args[1].parse::<uint>().unwrap() } else { diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs index dc65a63c5cb..38648b426f6 100644 --- a/src/test/bench/shootout-binarytrees.rs +++ b/src/test/bench/shootout-binarytrees.rs @@ -85,7 +85,7 @@ fn inner(depth: i32, iterations: i32) -> String { fn main() { let args = std::os::args(); - let args = args.as_slice(); + let args = args; let n = if std::os::getenv("RUST_BENCH").is_some() { 17 } else if args.len() <= 1u { diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 0835dd9a08e..30bbb3bc924 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -82,7 +82,7 @@ fn show_color_list(set: Vec<Color>) -> String { let mut out = String::new(); for col in &set { out.push(' '); - out.push_str(format!("{:?}", col).as_slice()); + out.push_str(&format!("{:?}", col)); } out } @@ -230,7 +230,7 @@ fn main() { let nn = if std::os::getenv("RUST_BENCH").is_some() { 200000 } else { - std::os::args().as_slice() + std::os::args() .get(1) .and_then(|arg| arg.parse().ok()) .unwrap_or(600u) diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index 47613e2d69c..92e1bc1a922 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -180,7 +180,7 @@ fn fannkuch(n: i32) -> (i32, i32) { } fn main() { - let n = std::os::args().as_slice() + let n = std::os::args() .get(1) .and_then(|arg| arg.parse().ok()) .unwrap_or(2i32); diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index 5386fc0419d..954bd5b2f79 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -124,7 +124,7 @@ impl<'a, W: Writer> RepeatFasta<'a, W> { let mut buf = repeat(0u8).take(alu_len + LINE_LEN).collect::<Vec<_>>(); let alu: &[u8] = self.alu.as_bytes(); - copy_memory(buf.as_mut_slice(), alu); + copy_memory(&mut buf, alu); let buf_len = buf.len(); copy_memory(&mut buf[alu_len..buf_len], &alu[..LINE_LEN]); @@ -209,7 +209,7 @@ impl<'a, W: Writer> RandomFasta<'a, W> { fn main() { let args = os::args(); - let args = args.as_slice(); + let args = args; let n = if args.len() > 1 { args[1].parse::<uint>().unwrap() } else { @@ -226,12 +226,12 @@ fn main() { out.write_line(">TWO IUB ambiguity codes").unwrap(); let iub = sum_and_scale(&IUB); - let mut random = RandomFasta::new(&mut out, iub.as_slice()); + let mut random = RandomFasta::new(&mut out, &iub); random.make(n * 3).unwrap(); random.out.write_line(">THREE Homo sapiens frequency").unwrap(); let homo_sapiens = sum_and_scale(&HOMO_SAPIENS); - random.lookup = make_lookup(homo_sapiens.as_slice()); + random.lookup = make_lookup(&homo_sapiens); random.make(n * 5).unwrap(); random.out.write_str("\n").unwrap(); diff --git a/src/test/bench/shootout-fasta.rs b/src/test/bench/shootout-fasta.rs index 8a2a8453a9e..141e098745e 100644 --- a/src/test/bench/shootout-fasta.rs +++ b/src/test/bench/shootout-fasta.rs @@ -104,7 +104,7 @@ fn make_fasta<W: Writer, I: Iterator<Item=u8>>( fn run<W: Writer>(writer: &mut W) -> std::old_io::IoResult<()> { let args = os::args(); - let args = args.as_slice(); + let args = args; let n = if os::getenv("RUST_BENCH").is_some() { 25000000 } else if args.len() <= 1u { diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index ad8e6551a03..ed93594534c 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -64,9 +64,9 @@ fn sort_and_fmt(mm: &HashMap<Vec<u8> , uint>, total: uint) -> String { let mut buffer = String::new(); for &(ref k, v) in &pairs_sorted { - buffer.push_str(format!("{:?} {:0.3}\n", - k.to_ascii_uppercase(), - v).as_slice()); + buffer.push_str(&format!("{:?} {:0.3}\n", + k.to_ascii_uppercase(), + v)); } return buffer @@ -122,8 +122,8 @@ fn make_sequence_processor(sz: uint, line = from_parent.recv().unwrap(); if line == Vec::new() { break; } - carry.push_all(line.as_slice()); - carry = windows_with_carry(carry.as_slice(), sz, |window| { + carry.push_all(&line); + carry = windows_with_carry(&carry, sz, |window| { update_freq(&mut freqs, window); total += 1u; }); diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index e3f8e60df93..474e5464293 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -261,7 +261,7 @@ fn print_frequencies(frequencies: &Table, frame: uint) { for entry in frequencies.iter() { vector.push((entry.count, entry.code)); } - vector.as_mut_slice().sort(); + vector.sort(); let mut total_count = 0; for &(count, _) in &vector { @@ -270,7 +270,7 @@ fn print_frequencies(frequencies: &Table, frame: uint) { for &(count, key) in vector.iter().rev() { println!("{} {:.3}", - key.unpack(frame).as_slice(), + key.unpack(frame), (count as f32 * 100.0) / (total_count as f32)); } println!(""); @@ -301,11 +301,11 @@ fn main() { let nb_freqs: Vec<_> = (1u..3).map(|i| { let input = input.clone(); - (i, Thread::scoped(move|| generate_frequencies(input.as_slice(), i))) + (i, Thread::scoped(move|| generate_frequencies(&input, i))) }).collect(); let occ_freqs: Vec<_> = OCCURRENCES.iter().map(|&occ| { let input = input.clone(); - Thread::scoped(move|| generate_frequencies(input.as_slice(), occ.len())) + Thread::scoped(move|| generate_frequencies(&input, occ.len())) }).collect(); for (i, freq) in nb_freqs { diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index a5729c5b5bd..e2d51fbf411 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -124,7 +124,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> { Thread::scoped(move|| { let mut res: Vec<u8> = Vec::with_capacity((chunk_size * w) / 8); - let init_r_slice = vec_init_r.as_slice(); + let init_r_slice = vec_init_r; let start = i * chunk_size; let end = if i == (WORKERS - 1) { @@ -134,7 +134,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> { }; for &init_i in &vec_init_i[start..end] { - write_line(init_i, init_r_slice, &mut res); + write_line(init_i, &init_r_slice, &mut res); } res @@ -143,7 +143,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> { try!(writeln!(&mut out as &mut Writer, "P4\n{} {}", w, h)); for res in data { - try!(out.write(res.join().ok().unwrap().as_slice())); + try!(out.write(&res.join().ok().unwrap())); } out.flush() } diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index a8de1469456..71fe1c6affc 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -103,7 +103,7 @@ struct Planet { fn advance(bodies: &mut [Planet;N_BODIES], dt: f64, steps: int) { for _ in 0..steps { - let mut b_slice = bodies.as_mut_slice(); + let mut b_slice: &mut [_] = bodies; loop { let bi = match shift_mut_ref(&mut b_slice) { Some(bi) => bi, diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index ea1d913b3e2..a1a9fbb471a 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -57,7 +57,7 @@ fn parse_opts(argv: Vec<String> ) -> Config { let argv = argv.iter().map(|x| x.to_string()).collect::<Vec<_>>(); let opt_args = &argv[1..argv.len()]; - match getopts::getopts(opt_args, opts.as_slice()) { + match getopts::getopts(opt_args, &opts) { Ok(ref m) => { return Config {stress: m.opt_present("stress")} } diff --git a/src/test/bench/shootout-reverse-complement.rs b/src/test/bench/shootout-reverse-complement.rs index dd8e7fdfbde..82887386814 100644 --- a/src/test/bench/shootout-reverse-complement.rs +++ b/src/test/bench/shootout-reverse-complement.rs @@ -251,6 +251,6 @@ fn parallel<'a, I, T, F>(iter: I, f: F) fn main() { let mut data = read_to_end(&mut stdin_raw()).unwrap(); let tables = &Tables::new(); - parallel(mut_dna_seqs(data.as_mut_slice()), |seq| reverse_complement(seq, tables)); - stdout_raw().write(data.as_mut_slice()).unwrap(); + parallel(mut_dna_seqs(&mut data), |seq| reverse_complement(seq, tables)); + stdout_raw().write(&data).unwrap(); } diff --git a/src/test/bench/shootout-spectralnorm.rs b/src/test/bench/shootout-spectralnorm.rs index ec85ba18f90..24e11887065 100644 --- a/src/test/bench/shootout-spectralnorm.rs +++ b/src/test/bench/shootout-spectralnorm.rs @@ -69,10 +69,10 @@ fn spectralnorm(n: uint) -> f64 { let mut v = u.clone(); let mut tmp = v.clone(); for _ in 0u..10 { - mult_AtAv(u.as_slice(), v.as_mut_slice(), tmp.as_mut_slice()); - mult_AtAv(v.as_slice(), u.as_mut_slice(), tmp.as_mut_slice()); + mult_AtAv(&u, &mut v, &mut tmp); + mult_AtAv(&v, &mut u, &mut tmp); } - (dot(u.as_slice(), v.as_slice()) / dot(v.as_slice(), v.as_slice())).sqrt() + (dot(&u, &v) / dot(&v, &v)).sqrt() } fn mult_AtAv(v: &[f64], out: &mut [f64], tmp: &mut [f64]) { diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 75126973cd9..4a248384e10 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -63,7 +63,7 @@ impl Sudoku { .take(10).collect::<Vec<_>>(); for line in reader.lines() { let line = line.unwrap(); - let comps: Vec<&str> = line.as_slice() + let comps: Vec<&str> = line .trim() .split(',') .collect(); diff --git a/src/test/compile-fail/borrowck-assign-comp-idx.rs b/src/test/compile-fail/borrowck-assign-comp-idx.rs index 3a2c6f03851..b18df7f3db6 100644 --- a/src/test/compile-fail/borrowck-assign-comp-idx.rs +++ b/src/test/compile-fail/borrowck-assign-comp-idx.rs @@ -33,7 +33,7 @@ fn b() { let mut p = vec!(1); borrow( - p.as_slice(), + &p, || p[0] = 5); //~ ERROR cannot borrow `p` as mutable } @@ -41,7 +41,7 @@ fn c() { // Legal because the scope of the borrow does not include the // modification: let mut p = vec!(1); - borrow(p.as_slice(), ||{}); + borrow(&p, ||{}); p[0] = 5; } diff --git a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs index d983c5d5087..99ac8672269 100644 --- a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs +++ b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs @@ -30,7 +30,7 @@ fn defer<'r>(x: &'r [&'r str]) -> defer<'r> { } fn main() { - let x = defer(vec!("Goodbye", "world!").as_slice()); + let x = defer(&vec!("Goodbye", "world!")); //~^ ERROR borrowed value does not live long enough x.x[0]; } diff --git a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs index 4e7d81a1cb0..f9d24130e47 100644 --- a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs +++ b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs @@ -21,7 +21,7 @@ pub fn main() { Foo { string: "bar".to_string() }, Foo { string: "baz".to_string() } ); - let x: &[Foo] = x.as_slice(); + let x: &[Foo] = &x; match x { [_, tail..] => { match tail { diff --git a/src/test/compile-fail/borrowck-mut-slice-of-imm-vec.rs b/src/test/compile-fail/borrowck-mut-slice-of-imm-vec.rs index b8a92db4e42..9341758afd8 100644 --- a/src/test/compile-fail/borrowck-mut-slice-of-imm-vec.rs +++ b/src/test/compile-fail/borrowck-mut-slice-of-imm-vec.rs @@ -14,5 +14,5 @@ fn write(v: &mut [isize]) { fn main() { let v = vec!(1, 2, 3); - write(v.as_mut_slice()); //~ ERROR cannot borrow + write(&mut v); //~ ERROR cannot borrow } diff --git a/src/test/compile-fail/borrowck-overloaded-index-autoderef.rs b/src/test/compile-fail/borrowck-overloaded-index-autoderef.rs index 9193a28511e..977c67b1c7d 100644 --- a/src/test/compile-fail/borrowck-overloaded-index-autoderef.rs +++ b/src/test/compile-fail/borrowck-overloaded-index-autoderef.rs @@ -22,7 +22,7 @@ impl Index<String> for Foo { type Output = isize; fn index<'a>(&'a self, z: &String) -> &'a isize { - if z.as_slice() == "x" { + if *z == "x" { &self.x } else { &self.y @@ -34,7 +34,7 @@ impl IndexMut<String> for Foo { type Output = isize; fn index_mut<'a>(&'a mut self, z: &String) -> &'a mut isize { - if z.as_slice() == "x" { + if *z == "x" { &mut self.x } else { &mut self.y diff --git a/src/test/compile-fail/borrowck-overloaded-index.rs b/src/test/compile-fail/borrowck-overloaded-index.rs index 7259ca8971d..9e79154eb0c 100644 --- a/src/test/compile-fail/borrowck-overloaded-index.rs +++ b/src/test/compile-fail/borrowck-overloaded-index.rs @@ -19,7 +19,7 @@ impl Index<String> for Foo { type Output = isize; fn index<'a>(&'a self, z: &String) -> &'a isize { - if z.as_slice() == "x" { + if *z == "x" { &self.x } else { &self.y @@ -31,7 +31,7 @@ impl IndexMut<String> for Foo { type Output = isize; fn index_mut<'a>(&'a mut self, z: &String) -> &'a mut isize { - if z.as_slice() == "x" { + if *z == "x" { &mut self.x } else { &mut self.y diff --git a/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs b/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs index 577334cce95..2d6a4b7d2c9 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs @@ -12,7 +12,7 @@ fn a<'a>() -> &'a [isize] { let vec = vec!(1, 2, 3, 4); - let vec: &[isize] = vec.as_slice(); //~ ERROR does not live long enough + let vec: &[isize] = &vec; //~ ERROR does not live long enough let tail = match vec { [_, tail..] => tail, _ => panic!("a") @@ -22,7 +22,7 @@ fn a<'a>() -> &'a [isize] { fn b<'a>() -> &'a [isize] { let vec = vec!(1, 2, 3, 4); - let vec: &[isize] = vec.as_slice(); //~ ERROR does not live long enough + let vec: &[isize] = &vec; //~ ERROR does not live long enough let init = match vec { [init.., _] => init, _ => panic!("b") @@ -32,7 +32,7 @@ fn b<'a>() -> &'a [isize] { fn c<'a>() -> &'a [isize] { let vec = vec!(1, 2, 3, 4); - let vec: &[isize] = vec.as_slice(); //~ ERROR does not live long enough + let vec: &[isize] = &vec; //~ ERROR does not live long enough let slice = match vec { [_, slice.., _] => slice, _ => panic!("c") diff --git a/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs b/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs index 565b8ca2f68..c1906758a5a 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs @@ -10,7 +10,7 @@ fn a() { let mut v = vec!(1, 2, 3); - let vb: &mut [isize] = v.as_mut_slice(); + let vb: &mut [isize] = &mut v; match vb { [_a, tail..] => { v.push(tail[0] + tail[1]); //~ ERROR cannot borrow diff --git a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs index e125d777371..b5745070817 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs @@ -22,7 +22,7 @@ fn a() { fn b() { let mut vec = vec!(box 1, box 2, box 3); - let vec: &mut [Box<isize>] = vec.as_mut_slice(); + let vec: &mut [Box<isize>] = &mut vec; match vec { [_b..] => { vec[0] = box 4; //~ ERROR cannot assign @@ -32,7 +32,7 @@ fn b() { fn c() { let mut vec = vec!(box 1, box 2, box 3); - let vec: &mut [Box<isize>] = vec.as_mut_slice(); + let vec: &mut [Box<isize>] = &mut vec; match vec { [_a, //~ ERROR cannot move out _b..] => { //~^ NOTE attempting to move value to here @@ -50,7 +50,7 @@ fn c() { fn d() { let mut vec = vec!(box 1, box 2, box 3); - let vec: &mut [Box<isize>] = vec.as_mut_slice(); + let vec: &mut [Box<isize>] = &mut vec; match vec { [_a.., //~ ERROR cannot move out _b] => {} //~ NOTE attempting to move value to here @@ -61,7 +61,7 @@ fn d() { fn e() { let mut vec = vec!(box 1, box 2, box 3); - let vec: &mut [Box<isize>] = vec.as_mut_slice(); + let vec: &mut [Box<isize>] = &mut vec; match vec { [_a, _b, _c] => {} //~ ERROR cannot move out //~^ NOTE attempting to move value to here diff --git a/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs b/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs index bcd1aa81d4c..df0fee437b9 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs @@ -10,7 +10,7 @@ fn a<'a>() -> &'a isize { let vec = vec!(1, 2, 3, 4); - let vec: &[isize] = vec.as_slice(); //~ ERROR `vec` does not live long enough + let vec: &[isize] = &vec; //~ ERROR `vec` does not live long enough let tail = match vec { [_a, tail..] => &tail[0], _ => panic!("foo") diff --git a/src/test/compile-fail/estr-subtyping.rs b/src/test/compile-fail/estr-subtyping.rs index 5335fa1206d..6e64e01d741 100644 --- a/src/test/compile-fail/estr-subtyping.rs +++ b/src/test/compile-fail/estr-subtyping.rs @@ -13,12 +13,12 @@ fn wants_slice(x: &str) { } fn has_uniq(x: String) { wants_uniq(x); - wants_slice(x.as_slice()); + wants_slice(&*x); } fn has_slice(x: &str) { wants_uniq(x); //~ ERROR mismatched types - wants_slice(x); + wants_slice(x.as_slice()); } fn main() { diff --git a/src/test/compile-fail/integral-indexing.rs b/src/test/compile-fail/integral-indexing.rs index ef651dd9ce7..88dd63384b7 100644 --- a/src/test/compile-fail/integral-indexing.rs +++ b/src/test/compile-fail/integral-indexing.rs @@ -11,15 +11,15 @@ pub fn main() { let v: Vec<isize> = vec!(0, 1, 2, 3, 4, 5); let s: String = "abcdef".to_string(); - v.as_slice()[3us]; - v.as_slice()[3]; - v.as_slice()[3u8]; //~ERROR the trait `core::ops::Index<u8>` is not implemented + v[3us]; + v[3]; + v[3u8]; //~ERROR the trait `core::ops::Index<u8>` is not implemented //~^ ERROR the trait `core::ops::Index<u8>` is not implemented - v.as_slice()[3i8]; //~ERROR the trait `core::ops::Index<i8>` is not implemented + v[3i8]; //~ERROR the trait `core::ops::Index<i8>` is not implemented //~^ ERROR the trait `core::ops::Index<i8>` is not implemented - v.as_slice()[3u32]; //~ERROR the trait `core::ops::Index<u32>` is not implemented + v[3u32]; //~ERROR the trait `core::ops::Index<u32>` is not implemented //~^ ERROR the trait `core::ops::Index<u32>` is not implemented - v.as_slice()[3i32]; //~ERROR the trait `core::ops::Index<i32>` is not implemented + v[3i32]; //~ERROR the trait `core::ops::Index<i32>` is not implemented //~^ ERROR the trait `core::ops::Index<i32>` is not implemented s.as_bytes()[3us]; s.as_bytes()[3]; diff --git a/src/test/compile-fail/issue-11374.rs b/src/test/compile-fail/issue-11374.rs index aa2a71ca2db..6dbea33d7d5 100644 --- a/src/test/compile-fail/issue-11374.rs +++ b/src/test/compile-fail/issue-11374.rs @@ -33,5 +33,5 @@ pub fn for_stdin<'a>() -> Container<'a> { fn main() { let mut c = for_stdin(); let mut v = Vec::new(); - c.read_to(v.as_mut_slice()); + c.read_to(v); } diff --git a/src/test/compile-fail/issue-12369.rs b/src/test/compile-fail/issue-12369.rs index 0587bdf6136..9a471a4341f 100644 --- a/src/test/compile-fail/issue-12369.rs +++ b/src/test/compile-fail/issue-12369.rs @@ -10,7 +10,7 @@ fn main() { let sl = vec![1,2,3]; - let v: isize = match sl.as_slice() { + let v: isize = match &*sl { [] => 0, [a,b,c] => 3, [a, rest..] => a, diff --git a/src/test/compile-fail/issue-15783.rs b/src/test/compile-fail/issue-15783.rs index 7080db23d42..13a5fa4b8af 100644 --- a/src/test/compile-fail/issue-15783.rs +++ b/src/test/compile-fail/issue-15783.rs @@ -14,7 +14,7 @@ pub fn foo(params: Option<&[&str]>) -> usize { fn main() { let name = "Foo"; - let x = Some(&[name.as_slice()]); + let x = Some(&[name]); let msg = foo(x); //~^ ERROR mismatched types //~| expected `core::option::Option<&[&str]>` diff --git a/src/test/compile-fail/issue-17728.rs b/src/test/compile-fail/issue-17728.rs index 9c708bdeaa8..83e52216be2 100644 --- a/src/test/compile-fail/issue-17728.rs +++ b/src/test/compile-fail/issue-17728.rs @@ -100,7 +100,7 @@ impl TraversesWorld for Player { impl Debug for Player { fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> { formatter.write_str("Player{ name:"); - formatter.write_str(self.name.as_slice()); + formatter.write_str(&self.name); formatter.write_str(" }"); Ok(()) } diff --git a/src/test/compile-fail/lub-if.rs b/src/test/compile-fail/lub-if.rs index 6dcf1fdee83..06af8ac8719 100644 --- a/src/test/compile-fail/lub-if.rs +++ b/src/test/compile-fail/lub-if.rs @@ -16,14 +16,14 @@ pub fn opt_str0<'a>(maybestr: &'a Option<String>) -> &'a str { if maybestr.is_none() { "(none)" } else { - let s: &'a str = maybestr.as_ref().unwrap().as_slice(); + let s: &'a str = maybestr.as_ref().unwrap(); s } } pub fn opt_str1<'a>(maybestr: &'a Option<String>) -> &'a str { if maybestr.is_some() { - let s: &'a str = maybestr.as_ref().unwrap().as_slice(); + let s: &'a str = maybestr.as_ref().unwrap(); s } else { "(none)" @@ -34,14 +34,14 @@ pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str { if maybestr.is_none() { "(none)" } else { - let s: &'a str = maybestr.as_ref().unwrap().as_slice(); + let s: &'a str = maybestr.as_ref().unwrap(); s //~ ERROR cannot infer an appropriate lifetime for automatic coercion due to conflicting } } pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str { if maybestr.is_some() { - let s: &'a str = maybestr.as_ref().unwrap().as_slice(); + let s: &'a str = maybestr.as_ref().unwrap(); s //~ ERROR cannot infer an appropriate lifetime for automatic coercion due to conflicting } else { "(none)" diff --git a/src/test/compile-fail/lub-match.rs b/src/test/compile-fail/lub-match.rs index 1939df2877b..1b5824964a8 100644 --- a/src/test/compile-fail/lub-match.rs +++ b/src/test/compile-fail/lub-match.rs @@ -15,7 +15,7 @@ pub fn opt_str0<'a>(maybestr: &'a Option<String>) -> &'a str { match *maybestr { Some(ref s) => { - let s: &'a str = s.as_slice(); + let s: &'a str = s; s } None => "(none)", @@ -26,7 +26,7 @@ pub fn opt_str1<'a>(maybestr: &'a Option<String>) -> &'a str { match *maybestr { None => "(none)", Some(ref s) => { - let s: &'a str = s.as_slice(); + let s: &'a str = s; s } } @@ -36,7 +36,7 @@ pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str { match *maybestr { None => "(none)", Some(ref s) => { - let s: &'a str = s.as_slice(); + let s: &'a str = s; s //~^ ERROR cannot infer an appropriate lifetime } @@ -46,7 +46,7 @@ pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str { pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str { match *maybestr { Some(ref s) => { - let s: &'a str = s.as_slice(); + let s: &'a str = s; s //~^ ERROR cannot infer an appropriate lifetime } diff --git a/src/test/compile-fail/match-vec-unreachable.rs b/src/test/compile-fail/match-vec-unreachable.rs index e2671552b43..2c63438cbf3 100644 --- a/src/test/compile-fail/match-vec-unreachable.rs +++ b/src/test/compile-fail/match-vec-unreachable.rs @@ -11,7 +11,7 @@ fn main() { let x: Vec<(isize, isize)> = Vec::new(); - let x: &[(isize, isize)] = x.as_slice(); + let x: &[(isize, isize)] = &x; match x { [a, (2, 3), _] => (), [(1, 2), (2, 3), b] => (), //~ ERROR unreachable pattern @@ -21,7 +21,7 @@ fn main() { let x: Vec<String> = vec!["foo".to_string(), "bar".to_string(), "baz".to_string()]; - let x: &[String] = x.as_slice(); + let x: &[String] = &x; match x { [a, _, _, ..] => { println!("{}", a); } [_, _, _, _, _] => { } //~ ERROR unreachable pattern @@ -29,7 +29,7 @@ fn main() { } let x: Vec<char> = vec!('a', 'b', 'c'); - let x: &[char] = x.as_slice(); + let x: &[char] = &x; match x { ['a', 'b', 'c', _tail..] => {} ['a', 'b', 'c'] => {} //~ ERROR unreachable pattern diff --git a/src/test/compile-fail/moves-based-on-type-exprs.rs b/src/test/compile-fail/moves-based-on-type-exprs.rs index c9f73e86a2c..9ad44567a41 100644 --- a/src/test/compile-fail/moves-based-on-type-exprs.rs +++ b/src/test/compile-fail/moves-based-on-type-exprs.rs @@ -95,7 +95,7 @@ fn f110() { fn f120() { let mut x = vec!("hi".to_string(), "ho".to_string()); - x.as_mut_slice().swap(0, 1); + x.swap(0, 1); touch(&x[0]); touch(&x[1]); } diff --git a/src/test/compile-fail/non-exhaustive-match.rs b/src/test/compile-fail/non-exhaustive-match.rs index fce72f507b6..1dec049aed5 100644 --- a/src/test/compile-fail/non-exhaustive-match.rs +++ b/src/test/compile-fail/non-exhaustive-match.rs @@ -36,20 +36,20 @@ fn main() { (t::b, t::b) => {} } let vec = vec!(Some(42), None, Some(21)); - let vec: &[Option<isize>] = vec.as_slice(); + let vec: &[Option<isize>] = &vec; match vec { //~ ERROR non-exhaustive patterns: `[]` not covered [Some(..), None, tail..] => {} [Some(..), Some(..), tail..] => {} [None] => {} } let vec = vec!(1); - let vec: &[isize] = vec.as_slice(); + let vec: &[isize] = &vec; match vec { [_, tail..] => (), [] => () } let vec = vec!(0.5f32); - let vec: &[f32] = vec.as_slice(); + let vec: &[f32] = &vec; match vec { //~ ERROR non-exhaustive patterns: `[_, _, _, _]` not covered [0.1, 0.2, 0.3] => (), [0.1, 0.2] => (), @@ -57,7 +57,7 @@ fn main() { [] => () } let vec = vec!(Some(42), None, Some(21)); - let vec: &[Option<isize>] = vec.as_slice(); + let vec: &[Option<isize>] = &vec; match vec { [Some(..), None, tail..] => {} [Some(..), Some(..), tail..] => {} diff --git a/src/test/compile-fail/regions-glb-free-free.rs b/src/test/compile-fail/regions-glb-free-free.rs index f43d35c579e..323d5360029 100644 --- a/src/test/compile-fail/regions-glb-free-free.rs +++ b/src/test/compile-fail/regions-glb-free-free.rs @@ -35,5 +35,5 @@ mod argparse { fn main () { let f : argparse::Flag = argparse::flag("flag", "My flag"); let updated_flag = f.set_desc("My new flag"); - assert_eq!(updated_flag.desc.as_slice(), "My new flag"); + assert_eq!(updated_flag.desc, "My new flag"); } diff --git a/src/test/compile-fail/regions-pattern-typing-issue-19552.rs b/src/test/compile-fail/regions-pattern-typing-issue-19552.rs index 3f722c9433b..57ea607cbf6 100644 --- a/src/test/compile-fail/regions-pattern-typing-issue-19552.rs +++ b/src/test/compile-fail/regions-pattern-typing-issue-19552.rs @@ -12,7 +12,7 @@ fn assert_send<T: Send>(_t: T) {} fn main() { let line = String::new(); - match [line.as_slice()] { //~ ERROR `line` does not live long enough + match [&*line] { //~ ERROR `line` does not live long enough [ word ] => { assert_send(word); } } } diff --git a/src/test/compile-fail/trait-coercion-generic-regions.rs b/src/test/compile-fail/trait-coercion-generic-regions.rs index 9c78d7ea243..7b426a4c033 100644 --- a/src/test/compile-fail/trait-coercion-generic-regions.rs +++ b/src/test/compile-fail/trait-coercion-generic-regions.rs @@ -26,7 +26,7 @@ impl Trait<&'static str> for Struct { fn main() { let person = "Fred".to_string(); - let person: &str = person.as_slice(); //~ ERROR `person` does not live long enough + let person: &str = &person; //~ ERROR `person` does not live long enough let s: Box<Trait<&'static str>> = box Struct { person: person }; } diff --git a/src/test/debuginfo/type-names.rs b/src/test/debuginfo/type-names.rs index e41c69fa65d..adc4711b49a 100644 --- a/src/test/debuginfo/type-names.rs +++ b/src/test/debuginfo/type-names.rs @@ -283,9 +283,9 @@ fn main() { let fixed_size_vec2 = ([0u, 1u, 2u], 0i16); let vec1 = vec![0u, 2u, 3u]; - let slice1 = vec1.as_slice(); + let slice1 = &*vec1; let vec2 = vec![Mod1::Variant2_2(Struct1)]; - let slice2 = vec2.as_slice(); + let slice2 = &*vec2; // Trait Objects let box_trait = (box 0) as Box<Trait1>; diff --git a/src/test/run-fail/bug-2470-bounds-check-overflow-3.rs b/src/test/run-fail/bug-2470-bounds-check-overflow-3.rs index 0cb73bc98a4..72e9c4849c6 100644 --- a/src/test/run-fail/bug-2470-bounds-check-overflow-3.rs +++ b/src/test/run-fail/bug-2470-bounds-check-overflow-3.rs @@ -29,12 +29,12 @@ fn main() { idx as uint); // This should panic. - println!("ov3 0x%x", x.as_slice()[idx]); + println!("ov3 0x%x", x[idx]); } #[cfg(any(target_arch="x86_64", target_arch = "aarch64"))] fn main() { // This version just panics anyways, for symmetry on 64-bit hosts. let x = vec!(1u,2u,3u); - error!("ov3 0x%x", x.as_slice()[200]); + error!("ov3 0x%x", x[200]); } diff --git a/src/test/run-make/cannot-read-embedded-idents/create_and_compile.rs b/src/test/run-make/cannot-read-embedded-idents/create_and_compile.rs index f7c581172e2..c8156b95dcf 100644 --- a/src/test/run-make/cannot-read-embedded-idents/create_and_compile.rs +++ b/src/test/run-make/cannot-read-embedded-idents/create_and_compile.rs @@ -17,8 +17,8 @@ use std::old_io::{File, Command}; fn main() { let args = os::args(); - let rustc = args[1].as_slice(); - let tmpdir = Path::new(args[2].as_slice()); + let rustc = &args[1]; + let tmpdir = Path::new(&args[2]); let main_file = tmpdir.join("broken.rs"); let _ = File::create(&main_file).unwrap() @@ -31,12 +31,12 @@ fn main() { // can't exec it directly let result = Command::new("sh") .arg("-c") - .arg(format!("{} {}", - rustc, - main_file.as_str() - .unwrap()).as_slice()) + .arg(&format!("{} {}", + rustc, + main_file.as_str() + .unwrap())) .output().unwrap(); - let err = String::from_utf8_lossy(result.error.as_slice()); + let err = String::from_utf8_lossy(&result.error); // positive test so that this test will be updated when the // compiler changes. diff --git a/src/test/run-make/issue-19371/foo.rs b/src/test/run-make/issue-19371/foo.rs index 867008cd259..808417d6521 100644 --- a/src/test/run-make/issue-19371/foo.rs +++ b/src/test/run-make/issue-19371/foo.rs @@ -28,9 +28,9 @@ fn main() { panic!("expected rustc path"); } - let tmpdir = Path::new(args[1].as_slice()); + let tmpdir = Path::new(&args[1]); - let mut sysroot = Path::new(args[3].as_slice()); + let mut sysroot = Path::new(&args[3]); sysroot.pop(); sysroot.pop(); diff --git a/src/test/run-make/save-analysis/foo.rs b/src/test/run-make/save-analysis/foo.rs index 25f7c64b5ab..3ede775b119 100644 --- a/src/test/run-make/save-analysis/foo.rs +++ b/src/test/run-make/save-analysis/foo.rs @@ -106,7 +106,7 @@ trait SomeTrait: SuperTrait { fn Method(&self, x: u32) -> u32; fn prov(&self, x: u32) -> u32 { - println(x.to_string().as_slice()); + println(&x.to_string()); 42 } fn provided_method(&self) -> u32 { @@ -122,7 +122,7 @@ trait SubTrait: SomeTrait { impl SomeTrait for some_fields { fn Method(&self, x: u32) -> u32 { - println(x.to_string().as_slice()); + println(&x.to_string()); self.field1 } } @@ -134,7 +134,7 @@ impl SubTrait for some_fields {} impl some_fields { fn stat(x: u32) -> u32 { - println(x.to_string().as_slice()); + println(&x.to_string()); 42 } fn stat2(x: &some_fields) -> u32 { @@ -194,20 +194,20 @@ enum SomeStructEnum { fn matchSomeEnum(val: SomeEnum) { match val { - SomeEnum::Ints(int1, int2) => { println((int1+int2).to_string().as_slice()); } - SomeEnum::Floats(float1, float2) => { println((float2*float1).to_string().as_slice()); } + SomeEnum::Ints(int1, int2) => { println(&(int1+int2).to_string()); } + SomeEnum::Floats(float1, float2) => { println(&(float2*float1).to_string()); } SomeEnum::Strings(_, _, s3) => { println(s3); } SomeEnum::MyTypes(mt1, mt2) => { - println((mt1.field1 - mt2.field1).to_string().as_slice()); + println(&(mt1.field1 - mt2.field1).to_string()); } } } fn matchSomeStructEnum(se: SomeStructEnum) { match se { - SomeStructEnum::EnumStruct{a:a, ..} => println(a.to_string().as_slice()), - SomeStructEnum::EnumStruct2{f1:f1, f2:f_2} => println(f_2.field1.to_string().as_slice()), - SomeStructEnum::EnumStruct3{f1, ..} => println(f1.field1.to_string().as_slice()), + SomeStructEnum::EnumStruct{a:a, ..} => println(&a.to_string()), + SomeStructEnum::EnumStruct2{f1:f1, f2:f_2} => println(&f_2.field1.to_string()), + SomeStructEnum::EnumStruct3{f1, ..} => println(&f1.field1.to_string()), } } @@ -215,9 +215,9 @@ fn matchSomeStructEnum(se: SomeStructEnum) { fn matchSomeStructEnum2(se: SomeStructEnum) { use SomeStructEnum::*; match se { - EnumStruct{a: ref aaa, ..} => println(aaa.to_string().as_slice()), - EnumStruct2{f1, f2: f2} => println(f1.field1.to_string().as_slice()), - EnumStruct3{f1, f3: SomeEnum::Ints(_, _), f2} => println(f1.field1.to_string().as_slice()), + EnumStruct{a: ref aaa, ..} => println(&aaa.to_string()), + EnumStruct2{f1, f2: f2} => println(&f1.field1.to_string()), + EnumStruct3{f1, f3: SomeEnum::Ints(_, _), f2} => println(&f1.field1.to_string()), _ => {}, } } @@ -233,12 +233,12 @@ fn matchSomeOtherEnum(val: SomeOtherEnum) { fn hello<X: SomeTrait>((z, a) : (u32, String), ex: X) { SameDir2::hello(43); - println(yy.to_string().as_slice()); + println(&yy.to_string()); let (x, y): (u32, u32) = (5, 3); - println(x.to_string().as_slice()); - println(z.to_string().as_slice()); + println(&x.to_string()); + println(&z.to_string()); let x: u32 = x; - println(x.to_string().as_slice()); + println(&x.to_string()); let x = "hello"; println(x); @@ -311,7 +311,7 @@ fn main() { // foo let s3: some_fields = some_fields{ field1: 55}; let s4: msalias::nested_struct = sub::sub2::nested_struct{ field2: 55}; let s4: msalias::nested_struct = sub2::nested_struct{ field2: 55}; - println(s2.field1.to_string().as_slice()); + println(&s2.field1.to_string()); let s5: MyType = box some_fields{ field1: 55}; let s = SameDir::SameStruct{name: "Bob".to_string()}; let s = SubDir::SubStruct{name:"Bob".to_string()}; diff --git a/src/test/run-make/unicode-input/multiple_files.rs b/src/test/run-make/unicode-input/multiple_files.rs index f9ffdffb464..be67e5a066a 100644 --- a/src/test/run-make/unicode-input/multiple_files.rs +++ b/src/test/run-make/unicode-input/multiple_files.rs @@ -34,8 +34,8 @@ fn random_char() -> char { fn main() { let args = os::args(); - let rustc = args[1].as_slice(); - let tmpdir = Path::new(args[2].as_slice()); + let rustc = &args[1]; + let tmpdir = Path::new(&args[2]); let main_file = tmpdir.join("unicode_input_multiple_files_main.rs"); { @@ -56,12 +56,12 @@ fn main() { // can't exec it directly let result = Command::new("sh") .arg("-c") - .arg(format!("{} {}", - rustc, - main_file.as_str() - .unwrap()).as_slice()) + .arg(&format!("{} {}", + rustc, + main_file.as_str() + .unwrap())) .output().unwrap(); - let err = String::from_utf8_lossy(result.error.as_slice()); + let err = String::from_utf8_lossy(&result.error); // positive test so that this test will be updated when the // compiler changes. diff --git a/src/test/run-make/unicode-input/span_length.rs b/src/test/run-make/unicode-input/span_length.rs index 9ee7516c7ba..95ce57da4e1 100644 --- a/src/test/run-make/unicode-input/span_length.rs +++ b/src/test/run-make/unicode-input/span_length.rs @@ -34,8 +34,8 @@ fn random_char() -> char { fn main() { let args = os::args(); - let rustc = args[1].as_slice(); - let tmpdir = Path::new(args[2].as_slice()); + let rustc = &args[1]; + let tmpdir = Path::new(&args[2]); let main_file = tmpdir.join("span_main.rs"); for _ in 0u..100 { @@ -52,18 +52,18 @@ fn main() { // can't exec it directly let result = Command::new("sh") .arg("-c") - .arg(format!("{} {}", - rustc, - main_file.as_str() - .unwrap()).as_slice()) + .arg(&format!("{} {}", + rustc, + main_file.as_str() + .unwrap())) .output().unwrap(); - let err = String::from_utf8_lossy(result.error.as_slice()); + let err = String::from_utf8_lossy(&result.error); // the span should end the line (e.g no extra ~'s) let expected_span = format!("^{}\n", repeat("~").take(n - 1) .collect::<String>()); - assert!(err.contains(expected_span.as_slice())); + assert!(err.contains(&expected_span)); } // Test multi-column characters and tabs diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs index b7e3480c076..57c50511604 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -47,7 +47,7 @@ pub fn main() { assert_eq!(length(x.clone()), x.len()); // Call a parameterized function, with type arguments that require // a borrow - assert_eq!(length::<int, &[int]>(x.as_slice()), x.len()); + assert_eq!(length::<int, &[int]>(&*x), x.len()); // Now try it with a type that *needs* to be borrowed let z = [0,1,2,3]; diff --git a/src/test/run-pass/associated-types-conditional-dispatch.rs b/src/test/run-pass/associated-types-conditional-dispatch.rs index 6d59161ff93..f21b7183d70 100644 --- a/src/test/run-pass/associated-types-conditional-dispatch.rs +++ b/src/test/run-pass/associated-types-conditional-dispatch.rs @@ -36,7 +36,7 @@ impl<'a, A, B, Lhs> MyEq<[B; 0]> for Lhs where A: MyEq<B>, Lhs: Deref<Target=[A]> { fn eq(&self, other: &[B; 0]) -> bool { - MyEq::eq(&**self, other.as_slice()) + MyEq::eq(&**self, other) } } diff --git a/src/test/run-pass/backtrace.rs b/src/test/run-pass/backtrace.rs index e9a3ab6be35..2cb6cf99d66 100644 --- a/src/test/run-pass/backtrace.rs +++ b/src/test/run-pass/backtrace.rs @@ -48,7 +48,7 @@ fn runtest(me: &str) { let p = template.clone().arg("fail").env("RUST_BACKTRACE", "1").spawn().unwrap(); let out = p.wait_with_output().unwrap(); assert!(!out.status.success()); - let s = str::from_utf8(out.error.as_slice()).unwrap(); + let s = str::from_utf8(&out.error).unwrap(); assert!(s.contains("stack backtrace") && s.contains("foo::h"), "bad output: {}", s); @@ -56,7 +56,7 @@ fn runtest(me: &str) { let p = template.clone().arg("fail").spawn().unwrap(); let out = p.wait_with_output().unwrap(); assert!(!out.status.success()); - let s = str::from_utf8(out.error.as_slice()).unwrap(); + let s = str::from_utf8(&out.error).unwrap(); assert!(!s.contains("stack backtrace") && !s.contains("foo::h"), "bad output2: {}", s); @@ -64,7 +64,7 @@ fn runtest(me: &str) { let p = template.clone().arg("double-fail").spawn().unwrap(); let out = p.wait_with_output().unwrap(); assert!(!out.status.success()); - let s = str::from_utf8(out.error.as_slice()).unwrap(); + let s = str::from_utf8(&out.error).unwrap(); // loosened the following from double::h to double:: due to // spurious failures on mac, 32bit, optimized assert!(s.contains("stack backtrace") && s.contains("double::"), @@ -75,7 +75,7 @@ fn runtest(me: &str) { .env("RUST_BACKTRACE", "1").spawn().unwrap(); let out = p.wait_with_output().unwrap(); assert!(!out.status.success()); - let s = str::from_utf8(out.error.as_slice()).unwrap(); + let s = str::from_utf8(&out.error).unwrap(); let mut i = 0; for _ in 0..2 { i += s[i + 10..].find_str("stack backtrace").unwrap() + 10; @@ -86,12 +86,12 @@ fn runtest(me: &str) { fn main() { let args = os::args(); - let args = args.as_slice(); - if args.len() >= 2 && args[1].as_slice() == "fail" { + let args = args; + if args.len() >= 2 && args[1] == "fail" { foo(); - } else if args.len() >= 2 && args[1].as_slice() == "double-fail" { + } else if args.len() >= 2 && args[1] == "double-fail" { double(); } else { - runtest(args[0].as_slice()); + runtest(&args[0]); } } diff --git a/src/test/run-pass/bare-fn-implements-fn-mut.rs b/src/test/run-pass/bare-fn-implements-fn-mut.rs index fae83d4aa65..758776298e1 100644 --- a/src/test/run-pass/bare-fn-implements-fn-mut.rs +++ b/src/test/run-pass/bare-fn-implements-fn-mut.rs @@ -26,13 +26,13 @@ fn call_g<G:FnMut(String,String) -> String>(mut g: G, x: String, y: String) } fn g(mut x: String, y: String) -> String { - x.push_str(y.as_slice()); + x.push_str(&y); x } fn main() { call_f(f); - assert_eq!(call_g(g, "foo".to_string(), "bar".to_string()).as_slice(), + assert_eq!(call_g(g, "foo".to_string(), "bar".to_string()), "foobar"); } diff --git a/src/test/run-pass/bool.rs b/src/test/run-pass/bool.rs index b3c4802530e..edf6b397ff8 100644 --- a/src/test/run-pass/bool.rs +++ b/src/test/run-pass/bool.rs @@ -53,9 +53,9 @@ fn main() { assert_eq!(!false, true); let s = false.to_string(); - assert_eq!(s.as_slice(), "false"); + assert_eq!(s, "false"); let s = true.to_string(); - assert_eq!(s.as_slice(), "true"); + assert_eq!(s, "true"); assert!(true > false); assert!(!(false > true)); diff --git a/src/test/run-pass/borrowck-binding-mutbl.rs b/src/test/run-pass/borrowck-binding-mutbl.rs index 6624136544d..34ad2b2def0 100644 --- a/src/test/run-pass/borrowck-binding-mutbl.rs +++ b/src/test/run-pass/borrowck-binding-mutbl.rs @@ -19,7 +19,7 @@ pub fn main() { match x { F {f: ref mut v} => { - impure(v.as_slice()); + impure(v); } } } diff --git a/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs b/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs index 94c7c2b13ce..092d7c13170 100644 --- a/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs +++ b/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs @@ -16,7 +16,7 @@ fn want_slice(v: &[int]) -> int { } fn has_mut_vec(v: Vec<int> ) -> int { - want_slice(v.as_slice()) + want_slice(&v) } pub fn main() { diff --git a/src/test/run-pass/borrowed-ptr-pattern-2.rs b/src/test/run-pass/borrowed-ptr-pattern-2.rs index 75b54b1af86..efd932933db 100644 --- a/src/test/run-pass/borrowed-ptr-pattern-2.rs +++ b/src/test/run-pass/borrowed-ptr-pattern-2.rs @@ -9,7 +9,7 @@ // except according to those terms. fn foo(s: &String) -> bool { - match s.as_slice() { + match &**s { "kitty" => true, _ => false } diff --git a/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs b/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs index 04ab0d881a8..edb3d72483b 100644 --- a/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs +++ b/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs @@ -44,7 +44,7 @@ fn get_bar(x: uint) -> Vec<uint> { vec!(x * 2) } pub fn fails() { let x = 2; let mut y = Vec::new(); - y.push(box Conzabble::Bickwick(do_it(get_bar(x).as_slice()))); + y.push(box Conzabble::Bickwick(do_it(&get_bar(x)))); } pub fn main() { diff --git a/src/test/run-pass/cleanup-shortcircuit.rs b/src/test/run-pass/cleanup-shortcircuit.rs index 7dd46e7b017..b776f098b1d 100644 --- a/src/test/run-pass/cleanup-shortcircuit.rs +++ b/src/test/run-pass/cleanup-shortcircuit.rs @@ -24,7 +24,7 @@ use std::os; pub fn main() { let args = os::args(); - let args = args.as_slice(); + let args = args; // Here, the rvalue `"signal".to_string()` requires cleanup. Older versions // of the code had a problem that the cleanup scope for this @@ -32,7 +32,7 @@ pub fn main() { // expression was never evaluated, we wound up trying to clean // uninitialized memory. - if args.len() >= 2 && args[1].as_slice() == "signal" { + if args.len() >= 2 && args[1] == "signal" { // Raise a segfault. unsafe { *(0 as *mut int) = 0; } } diff --git a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs index 646eed5de75..69bb3579720 100644 --- a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs @@ -19,6 +19,6 @@ fn bip(v: &[uint]) -> Vec<uint> { pub fn main() { let mut the_vec = vec!(1u, 2, 3, 100); - assert_eq!(the_vec.clone(), bar(the_vec.as_mut_slice())); - assert_eq!(the_vec.clone(), bip(the_vec.as_slice())); + assert_eq!(the_vec.clone(), bar(&mut the_vec)); + assert_eq!(the_vec.clone(), bip(&the_vec)); } diff --git a/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs b/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs index 10d747bf414..f87f2e07c9d 100644 --- a/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs +++ b/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs @@ -21,6 +21,6 @@ fn bar(v: &mut [uint]) { pub fn main() { let mut the_vec = vec!(1, 2, 3, 100); - bar(the_vec.as_mut_slice()); + bar(&mut the_vec); assert_eq!(the_vec, vec!(100, 3, 2, 1)); } diff --git a/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs b/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs index 6820aa4d186..4f97e6a2081 100644 --- a/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs @@ -17,6 +17,6 @@ fn bar(v: &mut [uint]) { pub fn main() { let mut the_vec = vec!(1, 2, 3, 100); - bar(the_vec.as_mut_slice()); + bar(&mut the_vec); assert_eq!(the_vec, vec!(100, 3, 2, 1)); } diff --git a/src/test/run-pass/deriving-encodable-decodable-box.rs b/src/test/run-pass/deriving-encodable-decodable-box.rs index a0888850aaf..838d05cf0d5 100644 --- a/src/test/run-pass/deriving-encodable-decodable-box.rs +++ b/src/test/run-pass/deriving-encodable-decodable-box.rs @@ -25,6 +25,6 @@ struct A { fn main() { let obj = A { foo: box [true, false] }; let s = json::encode(&obj).unwrap(); - let obj2: A = json::decode(s.as_slice()).unwrap(); + let obj2: A = json::decode(&s).unwrap(); assert!(obj.foo == obj2.foo); } diff --git a/src/test/run-pass/deriving-encodable-decodable-cell-refcell.rs b/src/test/run-pass/deriving-encodable-decodable-cell-refcell.rs index a5453d26170..7d581927c30 100644 --- a/src/test/run-pass/deriving-encodable-decodable-cell-refcell.rs +++ b/src/test/run-pass/deriving-encodable-decodable-cell-refcell.rs @@ -36,7 +36,7 @@ fn main() { bar: RefCell::new( A { baz: 2 } ) }; let s = json::encode(&obj).unwrap(); - let obj2: B = json::decode(s.as_slice()).unwrap(); + let obj2: B = json::decode(&s).unwrap(); assert!(obj.foo.get() == obj2.foo.get()); assert!(obj.bar.borrow().baz == obj2.bar.borrow().baz); } diff --git a/src/test/run-pass/getopts_ref.rs b/src/test/run-pass/getopts_ref.rs index a3df98afcb0..3c89900fe49 100644 --- a/src/test/run-pass/getopts_ref.rs +++ b/src/test/run-pass/getopts_ref.rs @@ -16,7 +16,7 @@ pub fn main() { let args = Vec::new(); let opts = vec!(optopt("b", "", "something", "SMTHNG")); - match getopts(args.as_slice(), opts.as_slice()) { + match getopts(&args, &opts) { Ok(ref m) => assert!(!m.opt_present("b")), Err(ref f) => panic!("{}", *f) diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index 651ac632439..677038af9a9 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -84,8 +84,7 @@ mod map_reduce { ctrl_proto::mapper_done => { num_mappers -= 1; } ctrl_proto::find_reducer(k, cc) => { let mut c; - match reducers.get(&str::from_utf8( - k.as_slice()).unwrap().to_string()) { + match reducers.get(&str::from_utf8(&k).unwrap().to_string()) { Some(&_c) => { c = _c; } None => { c = 0; } } diff --git a/src/test/run-pass/if-let.rs b/src/test/run-pass/if-let.rs index 5d97b886e8e..06294696bc9 100644 --- a/src/test/run-pass/if-let.rs +++ b/src/test/run-pass/if-let.rs @@ -50,7 +50,7 @@ pub fn main() { } else if let Foo::Two(_x) = foo { panic!("bad pattern match"); } else if let Foo::Three(s, _) = foo { - assert_eq!(s.as_slice(), "three"); + assert_eq!(s, "three"); } else { panic!("bad else"); } diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index ce628668996..5d157d875fa 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -39,7 +39,7 @@ impl fmt::Display for C { } macro_rules! t { - ($a:expr, $b:expr) => { assert_eq!($a.as_slice(), $b) } + ($a:expr, $b:expr) => { assert_eq!($a, $b) } } pub fn main() { diff --git a/src/test/run-pass/inconsistent-lifetime-mismatch.rs b/src/test/run-pass/inconsistent-lifetime-mismatch.rs index b30583c6668..d87b59537df 100644 --- a/src/test/run-pass/inconsistent-lifetime-mismatch.rs +++ b/src/test/run-pass/inconsistent-lifetime-mismatch.rs @@ -15,7 +15,7 @@ fn bad(a: &str, b: &str) { } fn good(a: &str, b: &str) { - foo(&[a.as_slice(), b.as_slice()]); + foo(&[a, b]); } fn main() {} diff --git a/src/test/run-pass/issue-10626.rs b/src/test/run-pass/issue-10626.rs index 79a0a54f834..9150920cf2c 100644 --- a/src/test/run-pass/issue-10626.rs +++ b/src/test/run-pass/issue-10626.rs @@ -17,8 +17,8 @@ use std::old_io::process; pub fn main () { let args = os::args(); - let args = args.as_slice(); - if args.len() > 1 && args[1].as_slice() == "child" { + let args = args; + if args.len() > 1 && args[1] == "child" { for _ in 0..1000 { println!("hello?"); } @@ -28,7 +28,7 @@ pub fn main () { return; } - let mut p = process::Command::new(args[0].as_slice()); + let mut p = process::Command::new(&args[0]); p.arg("child").stdout(process::Ignored).stderr(process::Ignored); println!("{:?}", p.spawn().unwrap().wait()); } diff --git a/src/test/run-pass/issue-10683.rs b/src/test/run-pass/issue-10683.rs index 26ee65fa565..a01d2e6f1a9 100644 --- a/src/test/run-pass/issue-10683.rs +++ b/src/test/run-pass/issue-10683.rs @@ -13,7 +13,7 @@ use std::ascii::AsciiExt; static NAME: &'static str = "hello world"; fn main() { - match NAME.to_ascii_lowercase().as_slice() { + match &*NAME.to_ascii_lowercase() { "foo" => {} _ => {} } diff --git a/src/test/run-pass/issue-11869.rs b/src/test/run-pass/issue-11869.rs index c75d02c6328..12a6d9a82c7 100644 --- a/src/test/run-pass/issue-11869.rs +++ b/src/test/run-pass/issue-11869.rs @@ -13,7 +13,7 @@ struct A { } fn borrow<'a>(binding: &'a A) -> &'a str { - match binding.a.as_slice() { + match &*binding.a { "in" => "in_", "ref" => "ref_", ident => ident diff --git a/src/test/run-pass/issue-13027.rs b/src/test/run-pass/issue-13027.rs index 649cf63e84a..056c86b01f7 100644 --- a/src/test/run-pass/issue-13027.rs +++ b/src/test/run-pass/issue-13027.rs @@ -179,7 +179,7 @@ fn misc() { // This test basically mimics how trace_macros! macro is implemented, // which is a rare combination of vector patterns, multiple wild-card // patterns and guard functions. - let r = match [Foo::Bar(0, false)].as_slice() { + let r = match [Foo::Bar(0, false)] { [Foo::Bar(_, pred)] if pred => 1, [Foo::Bar(_, pred)] if !pred => 2, _ => 0, diff --git a/src/test/run-pass/issue-13304.rs b/src/test/run-pass/issue-13304.rs index f2a8bc47db8..f979235da71 100644 --- a/src/test/run-pass/issue-13304.rs +++ b/src/test/run-pass/issue-13304.rs @@ -16,8 +16,8 @@ use std::str; fn main() { let args = os::args(); - let args = args.as_slice(); - if args.len() > 1 && args[1].as_slice() == "child" { + let args = args; + if args.len() > 1 && args[1] == "child" { child(); } else { parent(); @@ -26,13 +26,13 @@ fn main() { fn parent() { let args = os::args(); - let args = args.as_slice(); - let mut p = old_io::process::Command::new(args[0].as_slice()) + let args = args; + let mut p = old_io::process::Command::new(&args[0]) .arg("child").spawn().unwrap(); p.stdin.as_mut().unwrap().write_str("test1\ntest2\ntest3").unwrap(); let out = p.wait_with_output().unwrap(); assert!(out.status.success()); - let s = str::from_utf8(out.output.as_slice()).unwrap(); + let s = str::from_utf8(&out.output).unwrap(); assert_eq!(s, "test1\n\ntest2\n\ntest3\n"); } diff --git a/src/test/run-pass/issue-13323.rs b/src/test/run-pass/issue-13323.rs index 75d3c6f334d..44167ad2096 100644 --- a/src/test/run-pass/issue-13323.rs +++ b/src/test/run-pass/issue-13323.rs @@ -21,7 +21,7 @@ impl StrWrap { } fn get_s<'a>(&'a self) -> &'a str { - self.s.as_slice() + &self.s } } diff --git a/src/test/run-pass/issue-14021.rs b/src/test/run-pass/issue-14021.rs index ab085be9bc3..e850ecbba6e 100644 --- a/src/test/run-pass/issue-14021.rs +++ b/src/test/run-pass/issue-14021.rs @@ -22,7 +22,7 @@ pub fn main() { let obj = UnitLikeStruct; let json_str: String = json::encode(&obj).unwrap(); - let json_object = json::from_str(json_str.as_slice()); + let json_object = json::from_str(&json_str); let mut decoder = json::Decoder::new(json_object.unwrap()); let mut decoded_obj: UnitLikeStruct = Decodable::decode(&mut decoder).unwrap(); diff --git a/src/test/run-pass/issue-14456.rs b/src/test/run-pass/issue-14456.rs index a41e57f1002..5f44eb7dcd2 100644 --- a/src/test/run-pass/issue-14456.rs +++ b/src/test/run-pass/issue-14456.rs @@ -16,7 +16,7 @@ use std::os; fn main() { let args = os::args(); - if args.len() > 1 && args[1].as_slice() == "child" { + if args.len() > 1 && args[1] == "child" { return child() } @@ -32,7 +32,7 @@ fn child() { fn test() { let args = os::args(); - let mut p = Command::new(args[0].as_slice()).arg("child") + let mut p = Command::new(&args[0]).arg("child") .stdin(process::Ignored) .stdout(process::Ignored) .stderr(process::Ignored) diff --git a/src/test/run-pass/issue-14936.rs b/src/test/run-pass/issue-14936.rs index a441729e2d0..ace1f00b023 100644 --- a/src/test/run-pass/issue-14936.rs +++ b/src/test/run-pass/issue-14936.rs @@ -31,7 +31,7 @@ macro_rules! demo { } assert_eq!((x,y), (1,1)); let b: &[_] = &["out", "in"]; - assert_eq!(history.as_slice(), b); + assert_eq!(history, b); } } } diff --git a/src/test/run-pass/issue-14940.rs b/src/test/run-pass/issue-14940.rs index 5ae0ad6c3e9..e5fead72beb 100644 --- a/src/test/run-pass/issue-14940.rs +++ b/src/test/run-pass/issue-14940.rs @@ -17,7 +17,7 @@ fn main() { let mut out = stdio::stdout(); out.write(&['a' as u8; 128 * 1024]).unwrap(); } else { - let out = Command::new(args[0].as_slice()).arg("child").output(); + let out = Command::new(&args[0]).arg("child").output(); let out = out.unwrap(); assert!(out.status.success()); } diff --git a/src/test/run-pass/issue-15149.rs b/src/test/run-pass/issue-15149.rs index b37c71bc326..24f7a6af782 100644 --- a/src/test/run-pass/issue-15149.rs +++ b/src/test/run-pass/issue-15149.rs @@ -17,7 +17,7 @@ use std::rand::random; fn main() { // If we're the child, make sure we were invoked correctly let args = os::args(); - if args.len() > 1 && args[1].as_slice() == "child" { + if args.len() > 1 && args[1] == "child" { // FIXME: This should check the whole `args[0]` instead of just // checking that it ends_with the executable name. This // is needed because of Windows, which has a different behavior. @@ -45,9 +45,9 @@ fn test() { // Append the new directory to our own PATH. let mut path = os::split_paths(os::getenv("PATH").unwrap_or(String::new())); path.push(child_dir.clone()); - let path = os::join_paths(path.as_slice()).unwrap(); + let path = os::join_paths(&path).unwrap(); - let child_output = Command::new("mytest").env("PATH", path.as_slice()) + let child_output = Command::new("mytest").env("PATH", path) .arg("child") .output().unwrap(); diff --git a/src/test/run-pass/issue-16783.rs b/src/test/run-pass/issue-16783.rs index cb12d138a5f..c2bcbe045c0 100644 --- a/src/test/run-pass/issue-16783.rs +++ b/src/test/run-pass/issue-16783.rs @@ -10,5 +10,5 @@ pub fn main() { let x = [1, 2, 3]; - let y = x.as_slice(); + let y = x; } diff --git a/src/test/run-pass/issue-17734.rs b/src/test/run-pass/issue-17734.rs index e58fbe0b4c2..3cff16409cb 100644 --- a/src/test/run-pass/issue-17734.rs +++ b/src/test/run-pass/issue-17734.rs @@ -21,6 +21,6 @@ fn main() { // There is currently no safe way to construct a `Box<str>`, so improvise let box_arr: Box<[u8]> = box ['h' as u8, 'e' as u8, 'l' as u8, 'l' as u8, 'o' as u8]; let box_str: Box<str> = unsafe { std::mem::transmute(box_arr) }; - assert_eq!(box_str.as_slice(), "hello"); + assert_eq!(&*box_str, "hello"); f(box_str); } diff --git a/src/test/run-pass/issue-18352.rs b/src/test/run-pass/issue-18352.rs index 7878d698e52..e5532b4550b 100644 --- a/src/test/run-pass/issue-18352.rs +++ b/src/test/run-pass/issue-18352.rs @@ -11,7 +11,7 @@ const X: &'static str = "12345"; fn test(s: String) -> bool { - match s.as_slice() { + match &*s { X => true, _ => false } diff --git a/src/test/run-pass/issue-3559.rs b/src/test/run-pass/issue-3559.rs index 69a148d4108..754412ea949 100644 --- a/src/test/run-pass/issue-3559.rs +++ b/src/test/run-pass/issue-3559.rs @@ -24,6 +24,6 @@ pub fn main() { let mut table = HashMap::new(); table.insert("one".to_string(), 1); table.insert("two".to_string(), 2); - assert!(check_strs(format!("{:?}", table).as_slice(), "HashMap {\"one\": 1, \"two\": 2}") || - check_strs(format!("{:?}", table).as_slice(), "HashMap {\"two\": 2, \"one\": 1}")); + assert!(check_strs(&format!("{:?}", table), "HashMap {\"one\": 1, \"two\": 2}") || + check_strs(&format!("{:?}", table), "HashMap {\"two\": 2, \"one\": 1}")); } diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs index 5d02a1b2bd2..f4b85e03eae 100644 --- a/src/test/run-pass/issue-3563-3.rs +++ b/src/test/run-pass/issue-3563-3.rs @@ -162,7 +162,7 @@ pub fn check_strs(actual: &str, expected: &str) -> bool { fn test_ascii_art_ctor() { let art = AsciiArt(3, 3, '*'); - assert!(check_strs(art.to_string().as_slice(), "...\n...\n...")); + assert!(check_strs(&art.to_string(), "...\n...\n...")); } @@ -171,7 +171,7 @@ fn test_add_pt() { art.add_pt(0, 0); art.add_pt(0, -10); art.add_pt(1, 2); - assert!(check_strs(art.to_string().as_slice(), "*..\n...\n.*.")); + assert!(check_strs(&art.to_string(), "*..\n...\n.*.")); } @@ -179,7 +179,7 @@ fn test_shapes() { let mut art = AsciiArt(4, 4, '*'); art.add_rect(Rect {top_left: Point {x: 0, y: 0}, size: Size {width: 4, height: 4}}); art.add_point(Point {x: 2, y: 2}); - assert!(check_strs(art.to_string().as_slice(), "****\n*..*\n*.**\n****")); + assert!(check_strs(&art.to_string(), "****\n*..*\n*.**\n****")); } pub fn main() { diff --git a/src/test/run-pass/issue-4541.rs b/src/test/run-pass/issue-4541.rs index c9baab3cfa4..f10303e8d84 100644 --- a/src/test/run-pass/issue-4541.rs +++ b/src/test/run-pass/issue-4541.rs @@ -10,11 +10,11 @@ fn parse_args() -> String { let args = ::std::os::args(); - let args = args.as_slice(); + let args = args; let mut n = 0; while n < args.len() { - match args[n].as_slice() { + match &*args[n] { "-v" => (), s => { return s.to_string(); diff --git a/src/test/run-pass/issue-5550.rs b/src/test/run-pass/issue-5550.rs index 7f56e42a483..f87f1d8af76 100644 --- a/src/test/run-pass/issue-5550.rs +++ b/src/test/run-pass/issue-5550.rs @@ -12,6 +12,6 @@ pub fn main() { let s: String = "foobar".to_string(); - let mut t: &str = s.as_slice(); + let mut t: &str = &s; t = &t[0..3]; // for master: str::view(t, 0, 3) maybe } diff --git a/src/test/run-pass/issue-9259.rs b/src/test/run-pass/issue-9259.rs index 0fe520e59d6..da5338b8c3c 100644 --- a/src/test/run-pass/issue-9259.rs +++ b/src/test/run-pass/issue-9259.rs @@ -19,5 +19,5 @@ pub fn main() { a: &["test".to_string()], b: Some(b), }; - assert_eq!(a.b.as_ref().unwrap()[0].as_slice(), "foo"); + assert_eq!(a.b.as_ref().unwrap()[0], "foo"); } diff --git a/src/test/run-pass/issue-9382.rs b/src/test/run-pass/issue-9382.rs index 07212237305..c501420fa61 100644 --- a/src/test/run-pass/issue-9382.rs +++ b/src/test/run-pass/issue-9382.rs @@ -34,7 +34,7 @@ pub fn main() { bar: box 32, }; Thing1 { - baz: Vec::new().as_slice(), + baz: &Vec::new(), bar: box 32, }; let _t2_fixed = Thing2 { @@ -42,7 +42,7 @@ pub fn main() { bar: 32, }; Thing2 { - baz: Vec::new().as_slice(), + baz: &Vec::new(), bar: 32, }; } diff --git a/src/test/run-pass/istr.rs b/src/test/run-pass/istr.rs index af60f18e542..15195482ed6 100644 --- a/src/test/run-pass/istr.rs +++ b/src/test/run-pass/istr.rs @@ -37,19 +37,19 @@ fn test_heap_log() { fn test_append() { let mut s = String::new(); s.push_str("a"); - assert_eq!(s.as_slice(), "a"); + assert_eq!(s, "a"); let mut s = String::from_str("a"); s.push_str("b"); println!("{}", s.clone()); - assert_eq!(s.as_slice(), "ab"); + assert_eq!(s, "ab"); let mut s = String::from_str("c"); s.push_str("offee"); - assert!(s.as_slice() == "coffee"); + assert!(s == "coffee"); s.push_str("&tea"); - assert!(s.as_slice() == "coffee&tea"); + assert!(s == "coffee&tea"); } pub fn main() { diff --git a/src/test/run-pass/lambda-infer-unresolved.rs b/src/test/run-pass/lambda-infer-unresolved.rs index 009dc562d56..3c2a3f355b4 100644 --- a/src/test/run-pass/lambda-infer-unresolved.rs +++ b/src/test/run-pass/lambda-infer-unresolved.rs @@ -17,6 +17,6 @@ struct Refs { refs: Vec<int> , n: int } pub fn main() { let mut e = Refs{refs: vec!(), n: 0}; let _f = || println!("{}", e.n); - let x: &[int] = e.refs.as_slice(); + let x: &[int] = &e.refs; assert_eq!(x.len(), 0); } diff --git a/src/test/run-pass/logging-separate-lines.rs b/src/test/run-pass/logging-separate-lines.rs index 44daa52886c..1be0ee4a285 100644 --- a/src/test/run-pass/logging-separate-lines.rs +++ b/src/test/run-pass/logging-separate-lines.rs @@ -21,18 +21,18 @@ use std::str; fn main() { let args = os::args(); - let args = args.as_slice(); - if args.len() > 1 && args[1].as_slice() == "child" { + let args = args; + if args.len() > 1 && args[1] == "child" { debug!("foo"); debug!("bar"); return } - let p = Command::new(args[0].as_slice()) + let p = Command::new(&args[0]) .arg("child") .spawn().unwrap().wait_with_output().unwrap(); assert!(p.status.success()); - let mut lines = str::from_utf8(p.error.as_slice()).unwrap().lines(); + let mut lines = str::from_utf8(&p.error).unwrap().lines(); assert!(lines.next().unwrap().contains("foo")); assert!(lines.next().unwrap().contains("bar")); } diff --git a/src/test/run-pass/match-str.rs b/src/test/run-pass/match-str.rs index 60a5904cff3..301d99a7e20 100644 --- a/src/test/run-pass/match-str.rs +++ b/src/test/run-pass/match-str.rs @@ -18,8 +18,8 @@ pub fn main() { match t::tag1("test".to_string()) { t::tag2 => panic!(), - t::tag1(ref s) if "test" != s.as_slice() => panic!(), - t::tag1(ref s) if "test" == s.as_slice() => (), + t::tag1(ref s) if "test" != &**s => panic!(), + t::tag1(ref s) if "test" == &**s => (), _ => panic!() } diff --git a/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs b/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs index 76895af099d..0ad600dd85d 100644 --- a/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs +++ b/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs @@ -41,7 +41,7 @@ fn main() { let mut buf = [0_u8; 6]; { - let mut writer = buf.as_mut_slice(); + let mut writer: &mut [_] = &mut buf; writer.my_write(&[0, 1, 2]).unwrap(); writer.my_write(&[3, 4, 5]).unwrap(); } diff --git a/src/test/run-pass/move-out-of-field.rs b/src/test/run-pass/move-out-of-field.rs index 92c5e025b9b..cb487a34f33 100644 --- a/src/test/run-pass/move-out-of-field.rs +++ b/src/test/run-pass/move-out-of-field.rs @@ -31,5 +31,5 @@ pub fn main() { sb.append("Hello, "); sb.append("World!"); let str = to_string(sb); - assert_eq!(str.as_slice(), "Hello, World!"); + assert_eq!(str, "Hello, World!"); } diff --git a/src/test/run-pass/new-unicode-escapes.rs b/src/test/run-pass/new-unicode-escapes.rs index 2888389bcce..7430f730f3b 100644 --- a/src/test/run-pass/new-unicode-escapes.rs +++ b/src/test/run-pass/new-unicode-escapes.rs @@ -18,5 +18,5 @@ pub fn main() { let s = "\\{20}"; let mut correct_s = String::from_str("\\"); correct_s.push_str("{20}"); - assert_eq!(s, correct_s.as_slice()); + assert_eq!(s, correct_s); } diff --git a/src/test/run-pass/order-drop-with-match.rs b/src/test/run-pass/order-drop-with-match.rs index a866be43a05..3710f1b9d30 100644 --- a/src/test/run-pass/order-drop-with-match.rs +++ b/src/test/run-pass/order-drop-with-match.rs @@ -60,6 +60,6 @@ fn main() { } unsafe { let expected: &[_] = &[1, 2, 3]; - assert_eq!(expected, ORDER.as_slice()); + assert_eq!(expected, ORDER); } } diff --git a/src/test/run-pass/out-of-stack-new-thread-no-split.rs b/src/test/run-pass/out-of-stack-new-thread-no-split.rs index c9e2f893c0f..ca9ee469e38 100644 --- a/src/test/run-pass/out-of-stack-new-thread-no-split.rs +++ b/src/test/run-pass/out-of-stack-new-thread-no-split.rs @@ -35,13 +35,13 @@ fn recurse() { fn main() { let args = os::args(); - let args = args.as_slice(); - if args.len() > 1 && args[1].as_slice() == "recurse" { + let args = args; + if args.len() > 1 && args[1] == "recurse" { let _t = Thread::scoped(recurse); } else { - let recurse = Command::new(args[0].as_slice()).arg("recurse").output().unwrap(); + let recurse = Command::new(&args[0]).arg("recurse").output().unwrap(); assert!(!recurse.status.success()); - let error = String::from_utf8_lossy(recurse.error.as_slice()); + let error = String::from_utf8_lossy(&recurse.error); println!("wut"); println!("`{}`", error); assert!(error.contains("has overflowed its stack")); diff --git a/src/test/run-pass/out-of-stack-no-split.rs b/src/test/run-pass/out-of-stack-no-split.rs index 846fbd477e0..fba86d74816 100644 --- a/src/test/run-pass/out-of-stack-no-split.rs +++ b/src/test/run-pass/out-of-stack-no-split.rs @@ -35,13 +35,12 @@ fn recurse() { fn main() { let args = os::args(); - let args = args.as_slice(); - if args.len() > 1 && args[1].as_slice() == "recurse" { + if args.len() > 1 && args[1] == "recurse" { recurse(); } else { - let recurse = Command::new(args[0].as_slice()).arg("recurse").output().unwrap(); + let recurse = Command::new(&args[0]).arg("recurse").output().unwrap(); assert!(!recurse.status.success()); - let error = String::from_utf8_lossy(recurse.error.as_slice()); + let error = String::from_utf8_lossy(&recurse.error); assert!(error.contains("has overflowed its stack")); } } diff --git a/src/test/run-pass/out-of-stack.rs b/src/test/run-pass/out-of-stack.rs index 97539a076ff..7dfd46fb995 100644 --- a/src/test/run-pass/out-of-stack.rs +++ b/src/test/run-pass/out-of-stack.rs @@ -35,20 +35,20 @@ fn loud_recurse() { fn main() { let args = os::args(); - let args = args.as_slice(); - if args.len() > 1 && args[1].as_slice() == "silent" { + let args = args; + if args.len() > 1 && args[1] == "silent" { silent_recurse(); - } else if args.len() > 1 && args[1].as_slice() == "loud" { + } else if args.len() > 1 && args[1] == "loud" { loud_recurse(); } else { - let silent = Command::new(args[0].as_slice()).arg("silent").output().unwrap(); + let silent = Command::new(&args[0]).arg("silent").output().unwrap(); assert!(!silent.status.success()); - let error = String::from_utf8_lossy(silent.error.as_slice()); + let error = String::from_utf8_lossy(&silent.error); assert!(error.contains("has overflowed its stack")); - let loud = Command::new(args[0].as_slice()).arg("loud").output().unwrap(); + let loud = Command::new(&args[0]).arg("loud").output().unwrap(); assert!(!loud.status.success()); - let error = String::from_utf8_lossy(silent.error.as_slice()); + let error = String::from_utf8_lossy(&silent.error); assert!(error.contains("has overflowed its stack")); } } diff --git a/src/test/run-pass/overloaded-autoderef.rs b/src/test/run-pass/overloaded-autoderef.rs index baa9709eb76..fcf0feb6e30 100644 --- a/src/test/run-pass/overloaded-autoderef.rs +++ b/src/test/run-pass/overloaded-autoderef.rs @@ -34,13 +34,13 @@ pub fn main() { assert_eq!((i_value, *i.borrow()), (2, 5)); let s = Rc::new("foo".to_string()); - assert_eq!(s.as_slice(), "foo"); + assert_eq!(&**s, "foo"); let mut_s = Rc::new(RefCell::new(String::from_str("foo"))); mut_s.borrow_mut().push_str("bar"); // HACK assert_eq! would panic here because it stores the LHS and RHS in two locals. - assert!(mut_s.borrow().as_slice() == "foobar"); - assert!(mut_s.borrow_mut().as_slice() == "foobar"); + assert!(&**mut_s.borrow() == "foobar"); + assert!(&**mut_s.borrow_mut() == "foobar"); let p = Rc::new(RefCell::new(Point {x: 1, y: 2})); p.borrow_mut().x = 3; diff --git a/src/test/run-pass/overloaded-deref-count.rs b/src/test/run-pass/overloaded-deref-count.rs index 03fa64fb87f..f3091b53e8b 100644 --- a/src/test/run-pass/overloaded-deref-count.rs +++ b/src/test/run-pass/overloaded-deref-count.rs @@ -82,5 +82,5 @@ pub fn main() { // Check the final states. assert_eq!(*n, 2); let expected: &[_] = &[1, 2]; - assert_eq!((*v).as_slice(), expected); + assert_eq!((*v), expected); } diff --git a/src/test/run-pass/overloaded-deref.rs b/src/test/run-pass/overloaded-deref.rs index fdaddca091f..f56e7d56fe1 100644 --- a/src/test/run-pass/overloaded-deref.rs +++ b/src/test/run-pass/overloaded-deref.rs @@ -33,13 +33,13 @@ pub fn main() { let s = Rc::new("foo".to_string()); assert_eq!(*s, "foo".to_string()); - assert_eq!((*s).as_slice(), "foo"); + assert_eq!((*s), "foo"); let mut_s = Rc::new(RefCell::new(String::from_str("foo"))); (*(*mut_s).borrow_mut()).push_str("bar"); // assert_eq! would panic here because it stores the LHS and RHS in two locals. - assert!((*(*mut_s).borrow()).as_slice() == "foobar"); - assert!((*(*mut_s).borrow_mut()).as_slice() == "foobar"); + assert!((*(*mut_s).borrow()) == "foobar"); + assert!((*(*mut_s).borrow_mut()) == "foobar"); let p = Rc::new(RefCell::new(Point {x: 1, y: 2})); (*(*p).borrow_mut()).x = 3; diff --git a/src/test/run-pass/process-remove-from-env.rs b/src/test/run-pass/process-remove-from-env.rs index dcaca667fbb..8b99e8a947c 100644 --- a/src/test/run-pass/process-remove-from-env.rs +++ b/src/test/run-pass/process-remove-from-env.rs @@ -41,12 +41,12 @@ fn main() { // restore original environment match old_env { None => os::unsetenv("RUN_TEST_NEW_ENV"), - Some(val) => os::setenv("RUN_TEST_NEW_ENV", val.as_slice()) + Some(val) => os::setenv("RUN_TEST_NEW_ENV", val) } let prog = cmd.spawn().unwrap(); let result = prog.wait_with_output().unwrap(); - let output = String::from_utf8_lossy(result.output.as_slice()); + let output = String::from_utf8_lossy(&result.output); assert!(!output.contains("RUN_TEST_NEW_ENV"), "found RUN_TEST_NEW_ENV inside of:\n\n{}", output); diff --git a/src/test/run-pass/process-spawn-with-unicode-params.rs b/src/test/run-pass/process-spawn-with-unicode-params.rs index c6fd5527261..15cc128d380 100644 --- a/src/test/run-pass/process-spawn-with-unicode-params.rs +++ b/src/test/run-pass/process-spawn-with-unicode-params.rs @@ -58,12 +58,12 @@ fn main() { let p = Command::new(&child_path) .arg(arg) .cwd(&cwd) - .env_set_all(my_env.as_slice()) + .env_set_all(&my_env) .spawn().unwrap().wait_with_output().unwrap(); // display the output - assert!(old_io::stdout().write(p.output.as_slice()).is_ok()); - assert!(old_io::stderr().write(p.error.as_slice()).is_ok()); + assert!(old_io::stdout().write(&p.output).is_ok()); + assert!(old_io::stderr().write(&p.error).is_ok()); // make sure the child succeeded assert!(p.status.success()); @@ -74,7 +74,7 @@ fn main() { assert!(my_cwd.ends_with_path(&Path::new(child_dir))); // check arguments - assert_eq!(my_args[1].as_slice(), arg); + assert_eq!(&*my_args[1], arg); // check environment variable assert!(my_env.contains(&env)); diff --git a/src/test/run-pass/rcvr-borrowed-to-slice.rs b/src/test/run-pass/rcvr-borrowed-to-slice.rs index 8682d18185f..6a5da014994 100644 --- a/src/test/run-pass/rcvr-borrowed-to-slice.rs +++ b/src/test/run-pass/rcvr-borrowed-to-slice.rs @@ -24,7 +24,7 @@ fn call_sum(x: &[int]) -> int { x.sum_() } pub fn main() { let x = vec!(1, 2, 3); - let y = call_sum(x.as_slice()); + let y = call_sum(&x); println!("y=={}", y); assert_eq!(y, 6); diff --git a/src/test/run-pass/realloc-16687.rs b/src/test/run-pass/realloc-16687.rs index c932116243b..441c9d79e79 100644 --- a/src/test/run-pass/realloc-16687.rs +++ b/src/test/run-pass/realloc-16687.rs @@ -28,7 +28,7 @@ fn main() { unsafe fn test_triangle() -> bool { static COUNT : uint = 16; let mut ascend = repeat(ptr::null_mut()).take(COUNT).collect::<Vec<_>>(); - let ascend = ascend.as_mut_slice(); + let ascend = &mut *ascend; static ALIGN : uint = 1; // Checks that `ascend` forms triangle of ascending size formed @@ -103,7 +103,7 @@ unsafe fn test_triangle() -> bool { } } - sanity_check(ascend.as_slice()); + sanity_check(&*ascend); test_1(ascend); // triangle -> square test_2(ascend); // square -> triangle test_3(ascend); // triangle -> square @@ -128,10 +128,10 @@ unsafe fn test_triangle() -> bool { assert!(old_size < new_size); ascend[2*i] = reallocate(p0, old_size, new_size, ALIGN); - sanity_check(ascend.as_slice()); + sanity_check(&*ascend); ascend[2*i+1] = reallocate(p1, old_size, new_size, ALIGN); - sanity_check(ascend.as_slice()); + sanity_check(&*ascend); } } @@ -143,10 +143,10 @@ unsafe fn test_triangle() -> bool { assert!(new_size < old_size); ascend[2*i] = reallocate(p0, old_size, new_size, ALIGN); - sanity_check(ascend.as_slice()); + sanity_check(&*ascend); ascend[2*i+1] = reallocate(p1, old_size, new_size, ALIGN); - sanity_check(ascend.as_slice()); + sanity_check(&*ascend); } } @@ -158,10 +158,10 @@ unsafe fn test_triangle() -> bool { assert!(old_size < new_size); ascend[2*i+1] = reallocate(p1, old_size, new_size, ALIGN); - sanity_check(ascend.as_slice()); + sanity_check(&*ascend); ascend[2*i] = reallocate(p0, old_size, new_size, ALIGN); - sanity_check(ascend.as_slice()); + sanity_check(&*ascend); } } @@ -173,10 +173,10 @@ unsafe fn test_triangle() -> bool { assert!(new_size < old_size); ascend[2*i+1] = reallocate(p1, old_size, new_size, ALIGN); - sanity_check(ascend.as_slice()); + sanity_check(&*ascend); ascend[2*i] = reallocate(p0, old_size, new_size, ALIGN); - sanity_check(ascend.as_slice()); + sanity_check(&*ascend); } } } diff --git a/src/test/run-pass/regions-borrow-evec-uniq.rs b/src/test/run-pass/regions-borrow-evec-uniq.rs index f5d46d4ce7c..16eeb99982e 100644 --- a/src/test/run-pass/regions-borrow-evec-uniq.rs +++ b/src/test/run-pass/regions-borrow-evec-uniq.rs @@ -15,10 +15,10 @@ fn foo(x: &[int]) -> int { pub fn main() { let p = vec!(1,2,3,4,5); - let r = foo(p.as_slice()); + let r = foo(&p); assert_eq!(r, 1); let p = vec!(5,4,3,2,1); - let r = foo(p.as_slice()); + let r = foo(&p); assert_eq!(r, 5); } diff --git a/src/test/run-pass/regions-dependent-autoslice.rs b/src/test/run-pass/regions-dependent-autoslice.rs index 2cee2ac58b3..bcf74729fdb 100644 --- a/src/test/run-pass/regions-dependent-autoslice.rs +++ b/src/test/run-pass/regions-dependent-autoslice.rs @@ -20,5 +20,5 @@ fn both<'r>(v: &'r [uint]) -> &'r [uint] { pub fn main() { let v = vec!(1,2,3); - both(v.as_slice()); + both(&v); } diff --git a/src/test/run-pass/regions-infer-borrow-scope-view.rs b/src/test/run-pass/regions-infer-borrow-scope-view.rs index d247f864571..1fdf3a92a3f 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-view.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-view.rs @@ -13,7 +13,7 @@ fn view<T>(x: &[T]) -> &[T] {x} pub fn main() { let v = vec!(1, 2, 3); - let x = view(v.as_slice()); - let y = view(x.as_slice()); + let x = view(&v); + let y = view(x); assert!((v[0] == x[0]) && (v[0] == y[0])); } diff --git a/src/test/run-pass/running-with-no-runtime.rs b/src/test/run-pass/running-with-no-runtime.rs index efc1913a205..ec033b74dd1 100644 --- a/src/test/run-pass/running-with-no-runtime.rs +++ b/src/test/run-pass/running-with-no-runtime.rs @@ -41,7 +41,7 @@ fn start(argc: int, argv: *const *const u8) -> int { ffi::c_str_to_bytes(&ptr).to_vec() }).collect::<Vec<_>>() }; - let me = args[0].as_slice(); + let me = &*args[0]; let x: &[u8] = &[1u8]; pass(Command::new(me).arg(x).output().unwrap()); @@ -59,7 +59,7 @@ fn start(argc: int, argv: *const *const u8) -> int { fn pass(output: ProcessOutput) { if !output.status.success() { - println!("{:?}", str::from_utf8(output.output.as_slice())); - println!("{:?}", str::from_utf8(output.error.as_slice())); + println!("{:?}", str::from_utf8(&output.output)); + println!("{:?}", str::from_utf8(&output.error)); } } diff --git a/src/test/run-pass/rust-log-filter.rs b/src/test/run-pass/rust-log-filter.rs index f7fa204d453..5d6657c7e12 100644 --- a/src/test/run-pass/rust-log-filter.rs +++ b/src/test/run-pass/rust-log-filter.rs @@ -48,8 +48,8 @@ pub fn main() { info!("bar foo"); }); - assert_eq!(rx.recv().unwrap().as_slice(), "foo"); - assert_eq!(rx.recv().unwrap().as_slice(), "foo bar"); - assert_eq!(rx.recv().unwrap().as_slice(), "bar foo"); + assert_eq!(rx.recv().unwrap(), "foo"); + assert_eq!(rx.recv().unwrap(), "foo bar"); + assert_eq!(rx.recv().unwrap(), "bar foo"); assert!(rx.recv().is_err()); } diff --git a/src/test/run-pass/segfault-no-out-of-stack.rs b/src/test/run-pass/segfault-no-out-of-stack.rs index 2b2539fac0e..a2706dca7d3 100644 --- a/src/test/run-pass/segfault-no-out-of-stack.rs +++ b/src/test/run-pass/segfault-no-out-of-stack.rs @@ -13,13 +13,12 @@ use std::os; fn main() { let args = os::args(); - let args = args.as_slice(); - if args.len() > 1 && args[1].as_slice() == "segfault" { + if args.len() > 1 && args[1] == "segfault" { unsafe { *(0 as *mut int) = 1 }; // trigger a segfault } else { - let segfault = Command::new(args[0].as_slice()).arg("segfault").output().unwrap(); + let segfault = Command::new(&args[0]).arg("segfault").output().unwrap(); assert!(!segfault.status.success()); - let error = String::from_utf8_lossy(segfault.error.as_slice()); + let error = String::from_utf8_lossy(&segfault.error); assert!(!error.contains("has overflowed its stack")); } } diff --git a/src/test/run-pass/signal-exit-status.rs b/src/test/run-pass/signal-exit-status.rs index bf500bf0417..856eb241add 100644 --- a/src/test/run-pass/signal-exit-status.rs +++ b/src/test/run-pass/signal-exit-status.rs @@ -15,12 +15,12 @@ use std::old_io::process::{Command, ExitSignal, ExitStatus}; pub fn main() { let args = os::args(); - let args = args.as_slice(); - if args.len() >= 2 && args[1].as_slice() == "signal" { + let args = args; + if args.len() >= 2 && args[1] == "signal" { // Raise a segfault. unsafe { *(0 as *mut int) = 0; } } else { - let status = Command::new(args[0].as_slice()).arg("signal").status().unwrap(); + let status = Command::new(&args[0]).arg("signal").status().unwrap(); // Windows does not have signal, so we get exit status 0xC0000028 (STATUS_BAD_STACK). match status { ExitSignal(_) if cfg!(unix) => {}, diff --git a/src/test/run-pass/sigpipe-should-be-ignored.rs b/src/test/run-pass/sigpipe-should-be-ignored.rs index 23a92857176..de8f76518fc 100644 --- a/src/test/run-pass/sigpipe-should-be-ignored.rs +++ b/src/test/run-pass/sigpipe-should-be-ignored.rs @@ -26,12 +26,12 @@ fn test() { fn main() { let args = os::args(); - let args = args.as_slice(); - if args.len() > 1 && args[1].as_slice() == "test" { + let args = args; + if args.len() > 1 && args[1] == "test" { return test(); } - let mut p = Command::new(args[0].as_slice()) + let mut p = Command::new(&args[0]) .arg("test").spawn().unwrap(); assert!(p.wait().unwrap().success()); } diff --git a/src/test/run-pass/small-enums-with-fields.rs b/src/test/run-pass/small-enums-with-fields.rs index fc45e107bb0..475af8f2b8e 100644 --- a/src/test/run-pass/small-enums-with-fields.rs +++ b/src/test/run-pass/small-enums-with-fields.rs @@ -20,8 +20,8 @@ macro_rules! check { static S: $t = $e; let v: $t = $e; assert_eq!(S, v); - assert_eq!(format!("{:?}", v).as_slice(), $s); - assert_eq!(format!("{:?}", S).as_slice(), $s); + assert_eq!(format!("{:?}", v), $s); + assert_eq!(format!("{:?}", S), $s); });* }} } diff --git a/src/test/run-pass/swap-2.rs b/src/test/run-pass/swap-2.rs index 3c0f9505736..1dbd29a781e 100644 --- a/src/test/run-pass/swap-2.rs +++ b/src/test/run-pass/swap-2.rs @@ -12,7 +12,7 @@ use std::mem::swap; pub fn main() { let mut a: Vec<int> = vec!(0, 1, 2, 3, 4, 5, 6); - a.as_mut_slice().swap(2, 4); + a.swap(2, 4); assert_eq!(a[2], 4); assert_eq!(a[4], 2); let mut n = 42; diff --git a/src/test/run-pass/trait-bounds-in-arc.rs b/src/test/run-pass/trait-bounds-in-arc.rs index 0b650d97e4f..26772a5b22c 100644 --- a/src/test/run-pass/trait-bounds-in-arc.rs +++ b/src/test/run-pass/trait-bounds-in-arc.rs @@ -44,19 +44,19 @@ struct Goldfyshe { } impl Pet for Catte { - fn name(&self, mut blk: Box<FnMut(&str)>) { blk(self.name.as_slice()) } + fn name(&self, mut blk: Box<FnMut(&str)>) { blk(&self.name) } fn num_legs(&self) -> uint { 4 } fn of_good_pedigree(&self) -> bool { self.num_whiskers >= 4 } } impl Pet for Dogge { - fn name(&self, mut blk: Box<FnMut(&str)>) { blk(self.name.as_slice()) } + fn name(&self, mut blk: Box<FnMut(&str)>) { blk(&self.name) } fn num_legs(&self) -> uint { 4 } fn of_good_pedigree(&self) -> bool { self.bark_decibels < 70 || self.tricks_known > 20 } } impl Pet for Goldfyshe { - fn name(&self, mut blk: Box<FnMut(&str)>) { blk(self.name.as_slice()) } + fn name(&self, mut blk: Box<FnMut(&str)>) { blk(&self.name) } fn num_legs(&self) -> uint { 0 } fn of_good_pedigree(&self) -> bool { self.swim_speed >= 500 } } diff --git a/src/test/run-pass/typeck_type_placeholder_1.rs b/src/test/run-pass/typeck_type_placeholder_1.rs index b2f6dad9988..d7748f24774 100644 --- a/src/test/run-pass/typeck_type_placeholder_1.rs +++ b/src/test/run-pass/typeck_type_placeholder_1.rs @@ -23,10 +23,10 @@ static CONSTEXPR: TestStruct = TestStruct{x: &413 as *const _}; pub fn main() { let x: Vec<_> = (0u..5).collect(); let expected: &[uint] = &[0,1,2,3,4]; - assert_eq!(x.as_slice(), expected); + assert_eq!(x, expected); let x = (0u..5).collect::<Vec<_>>(); - assert_eq!(x.as_slice(), expected); + assert_eq!(x, expected); let y: _ = "hello"; assert_eq!(y.len(), 5); diff --git a/src/test/run-pass/unit-like-struct-drop-run.rs b/src/test/run-pass/unit-like-struct-drop-run.rs index 3c50712b464..0acf736e2ab 100644 --- a/src/test/run-pass/unit-like-struct-drop-run.rs +++ b/src/test/run-pass/unit-like-struct-drop-run.rs @@ -27,5 +27,5 @@ pub fn main() { }).join(); let s = x.err().unwrap().downcast::<&'static str>().ok().unwrap(); - assert_eq!(s.as_slice(), "This panic should happen."); + assert_eq!(&**s, "This panic should happen."); } diff --git a/src/test/run-pass/vec-concat.rs b/src/test/run-pass/vec-concat.rs index 02a791e7975..64c4c17386b 100644 --- a/src/test/run-pass/vec-concat.rs +++ b/src/test/run-pass/vec-concat.rs @@ -14,7 +14,7 @@ pub fn main() { let a: Vec<int> = vec!(1, 2, 3, 4, 5); let b: Vec<int> = vec!(6, 7, 8, 9, 0); let mut v: Vec<int> = a; - v.push_all(b.as_slice()); + v.push_all(&b); println!("{}", v[9]); assert_eq!(v[0], 1); assert_eq!(v[7], 8); diff --git a/src/test/run-pass/vector-sort-panic-safe.rs b/src/test/run-pass/vector-sort-panic-safe.rs index 9d83c0b0079..d13369b1f52 100644 --- a/src/test/run-pass/vector-sort-panic-safe.rs +++ b/src/test/run-pass/vector-sort-panic-safe.rs @@ -68,7 +68,7 @@ pub fn main() { // work out the total number of comparisons required to sort // this array... let mut count = 0us; - main.clone().as_mut_slice().sort_by(|a, b| { count += 1; a.cmp(b) }); + main.clone().sort_by(|a, b| { count += 1; a.cmp(b) }); // ... and then panic on each and every single one. for panic_countdown in 0..count { @@ -82,7 +82,7 @@ pub fn main() { let _ = Thread::scoped(move|| { let mut v = v; let mut panic_countdown = panic_countdown; - v.as_mut_slice().sort_by(|a, b| { + v.sort_by(|a, b| { if panic_countdown == 0 { panic!() } diff --git a/src/test/run-pass/wait-forked-but-failed-child.rs b/src/test/run-pass/wait-forked-but-failed-child.rs index 12de40129fd..dcbecb859e5 100644 --- a/src/test/run-pass/wait-forked-but-failed-child.rs +++ b/src/test/run-pass/wait-forked-but-failed-child.rs @@ -35,7 +35,7 @@ fn find_zombies() { // http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html let ps_cmd_output = Command::new("ps").args(&["-A", "-o", "pid,ppid,args"]).output().unwrap(); - let ps_output = String::from_utf8_lossy(ps_cmd_output.output.as_slice()); + let ps_output = String::from_utf8_lossy(&ps_cmd_output.output); for (line_no, line) in ps_output.split('\n').enumerate() { if 0 < line_no && 0 < line.len() && @@ -56,7 +56,7 @@ fn main() { let too_long = format!("/NoSuchCommand{:0300}", 0u8); let _failures = (0..100).map(|_| { - let cmd = Command::new(too_long.as_slice()); + let cmd = Command::new(&too_long); let failed = cmd.spawn(); assert!(failed.is_err(), "Make sure the command fails to spawn(): {:?}", cmd); failed |
