Remove some internal ~[] from several libraries.

Some straggling instances of `~[]` across a few different libs. Also,
remove some public ones from workcache.
This commit is contained in:
Huon Wilson 2014-04-09 20:02:26 +10:00 committed by Alex Crichton
parent 32cf4a188c
commit 6e63b12f5f
12 changed files with 34 additions and 31 deletions

View File

@ -451,7 +451,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
let options_to_remove = [~"-O", ~"-g", ~"--debuginfo"]; let options_to_remove = [~"-O", ~"-g", ~"--debuginfo"];
let new_options = split_maybe_args(options).move_iter() let new_options = split_maybe_args(options).move_iter()
.filter(|x| !options_to_remove.contains(x)) .filter(|x| !options_to_remove.contains(x))
.collect::<~[~str]>() .collect::<Vec<~str>>()
.connect(" "); .connect(" ");
Some(new_options) Some(new_options)
} }

View File

@ -117,13 +117,13 @@ mod tests {
words.push(r.gen_vec::<u8>(range)); words.push(r.gen_vec::<u8>(range));
} }
for _ in range(0, 20) { for _ in range(0, 20) {
let mut input = ~[]; let mut input = vec![];
for _ in range(0, 2000) { for _ in range(0, 2000) {
input.push_all(r.choose(words.as_slice()).as_slice()); input.push_all(r.choose(words.as_slice()).as_slice());
} }
debug!("de/inflate of {} bytes of random word-sequences", debug!("de/inflate of {} bytes of random word-sequences",
input.len()); input.len());
let cmp = deflate_bytes(input).expect("deflation failed"); let cmp = deflate_bytes(input.as_slice()).expect("deflation failed");
let out = inflate_bytes(cmp.as_slice()).expect("inflation failed"); let out = inflate_bytes(cmp.as_slice()).expect("inflation failed");
debug!("{} bytes deflated to {} ({:.1f}% size)", debug!("{} bytes deflated to {} ({:.1f}% size)",
input.len(), cmp.len(), input.len(), cmp.len(),

View File

@ -53,7 +53,7 @@
//! //!
//! let program = args[0].clone(); //! let program = args[0].clone();
//! //!
//! let opts = ~[ //! let opts = [
//! optopt("o", "", "set output file name", "NAME"), //! optopt("o", "", "set output file name", "NAME"),
//! optflag("h", "help", "print this help menu") //! optflag("h", "help", "print this help menu")
//! ]; //! ];

View File

@ -31,6 +31,8 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://static.rust-lang.org/doc/master")] html_root_url = "http://static.rust-lang.org/doc/master")]
#![deny(deprecated_owned_vector)]
use std::cell::Cell; use std::cell::Cell;
use std::{cmp, os, path}; use std::{cmp, os, path};
use std::io::fs; use std::io::fs;
@ -245,26 +247,26 @@ impl Pattern {
*/ */
pub fn new(pattern: &str) -> Pattern { pub fn new(pattern: &str) -> Pattern {
let chars = pattern.chars().collect::<~[_]>(); let chars = pattern.chars().collect::<Vec<_>>();
let mut tokens = Vec::new(); let mut tokens = Vec::new();
let mut i = 0; let mut i = 0;
while i < chars.len() { while i < chars.len() {
match chars[i] { match *chars.get(i) {
'?' => { '?' => {
tokens.push(AnyChar); tokens.push(AnyChar);
i += 1; i += 1;
} }
'*' => { '*' => {
// *, **, ***, ****, ... are all equivalent // *, **, ***, ****, ... are all equivalent
while i < chars.len() && chars[i] == '*' { while i < chars.len() && *chars.get(i) == '*' {
i += 1; i += 1;
} }
tokens.push(AnySequence); tokens.push(AnySequence);
} }
'[' => { '[' => {
if i <= chars.len() - 4 && chars[i + 1] == '!' { if i <= chars.len() - 4 && *chars.get(i + 1) == '!' {
match chars.slice_from(i + 3).position_elem(&']') { match chars.slice_from(i + 3).position_elem(&']') {
None => (), None => (),
Some(j) => { Some(j) => {
@ -276,7 +278,7 @@ impl Pattern {
} }
} }
} }
else if i <= chars.len() - 3 && chars[i + 1] != '!' { else if i <= chars.len() - 3 && *chars.get(i + 1) != '!' {
match chars.slice_from(i + 2).position_elem(&']') { match chars.slice_from(i + 2).position_elem(&']') {
None => (), None => (),
Some(j) => { Some(j) => {

View File

@ -190,7 +190,7 @@ fn visit_item(e: &Env, i: &ast::Item) {
} else { } else {
None None
}) })
.collect::<~[&ast::Attribute]>(); .collect::<Vec<&ast::Attribute>>();
for m in link_args.iter() { for m in link_args.iter() {
match m.value_str() { match m.value_str() {
Some(linkarg) => e.sess.cstore.add_used_link_args(linkarg.get()), Some(linkarg) => e.sess.cstore.add_used_link_args(linkarg.get()),
@ -205,7 +205,7 @@ fn visit_item(e: &Env, i: &ast::Item) {
} else { } else {
None None
}) })
.collect::<~[&ast::Attribute]>(); .collect::<Vec<&ast::Attribute>>();
for m in link_args.iter() { for m in link_args.iter() {
match m.meta_item_list() { match m.meta_item_list() {
Some(items) => { Some(items) => {

View File

@ -133,7 +133,7 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result {
slice::raw::buf_as_slice((*text).data, (*text).size as uint, |text| { slice::raw::buf_as_slice((*text).data, (*text).size as uint, |text| {
let text = str::from_utf8(text).unwrap(); let text = str::from_utf8(text).unwrap();
let mut lines = text.lines().filter(|l| stripped_filtered_line(*l).is_none()); let mut lines = text.lines().filter(|l| stripped_filtered_line(*l).is_none());
let text = lines.collect::<~[&str]>().connect("\n"); let text = lines.collect::<Vec<&str>>().connect("\n");
let buf = buf { let buf = buf {
data: text.as_bytes().as_ptr(), data: text.as_bytes().as_ptr(),
@ -186,7 +186,7 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result {
Some(s) => s.to_lower().into_str(), Some(s) => s.to_lower().into_str(),
None => s.to_owned() None => s.to_owned()
} }
}).collect::<~[~str]>().connect("-"); }).collect::<Vec<~str>>().connect("-");
let opaque = unsafe {&mut *(opaque as *mut my_opaque)}; let opaque = unsafe {&mut *(opaque as *mut my_opaque)};
@ -285,7 +285,7 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
let tests = &mut *(opaque as *mut ::test::Collector); let tests = &mut *(opaque as *mut ::test::Collector);
let text = str::from_utf8(text).unwrap(); let text = str::from_utf8(text).unwrap();
let mut lines = text.lines().map(|l| stripped_filtered_line(l).unwrap_or(l)); let mut lines = text.lines().map(|l| stripped_filtered_line(l).unwrap_or(l));
let text = lines.collect::<~[&str]>().connect("\n"); let text = lines.collect::<Vec<&str>>().connect("\n");
tests.add_test(text, should_fail, no_run, ignore); tests.add_test(text, should_fail, no_run, ignore);
}) })
} }

View File

@ -1205,8 +1205,8 @@ fn item_trait(w: &mut Writer, it: &clean::Item,
it.name.get_ref().as_slice(), it.name.get_ref().as_slice(),
t.generics, t.generics,
parents)); parents));
let required = t.methods.iter().filter(|m| m.is_req()).collect::<~[&clean::TraitMethod]>(); let required = t.methods.iter().filter(|m| m.is_req()).collect::<Vec<&clean::TraitMethod>>();
let provided = t.methods.iter().filter(|m| !m.is_req()).collect::<~[&clean::TraitMethod]>(); let provided = t.methods.iter().filter(|m| !m.is_req()).collect::<Vec<&clean::TraitMethod>>();
if t.methods.len() == 0 { if t.methods.len() == 0 {
try!(write!(w, "\\{ \\}")); try!(write!(w, "\\{ \\}"));
@ -1502,11 +1502,11 @@ fn render_methods(w: &mut Writer, it: &clean::Item) -> fmt::Result {
let mut non_trait = v.iter().filter(|p| { let mut non_trait = v.iter().filter(|p| {
p.ref0().trait_.is_none() p.ref0().trait_.is_none()
}); });
let non_trait = non_trait.collect::<~[&(clean::Impl, Option<~str>)]>(); let non_trait = non_trait.collect::<Vec<&(clean::Impl, Option<~str>)>>();
let mut traits = v.iter().filter(|p| { let mut traits = v.iter().filter(|p| {
p.ref0().trait_.is_some() p.ref0().trait_.is_some()
}); });
let traits = traits.collect::<~[&(clean::Impl, Option<~str>)]>(); let traits = traits.collect::<Vec<&(clean::Impl, Option<~str>)>>();
if non_trait.len() > 0 { if non_trait.len() > 0 {
try!(write!(w, "<h2 id='methods'>Methods</h2>")); try!(write!(w, "<h2 id='methods'>Methods</h2>"));

View File

@ -161,12 +161,12 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches) -> int
} }
/// Run any tests/code examples in the markdown file `input`. /// Run any tests/code examples in the markdown file `input`.
pub fn test(input: &str, libs: HashSet<Path>, mut test_args: ~[~str]) -> int { pub fn test(input: &str, libs: HashSet<Path>, mut test_args: Vec<~str>) -> int {
let input_str = load_or_return!(input, 1, 2); let input_str = load_or_return!(input, 1, 2);
let mut collector = Collector::new(input.to_owned(), libs, true, true); let mut collector = Collector::new(input.to_owned(), libs, true, true);
find_testable_code(input_str, &mut collector); find_testable_code(input_str, &mut collector);
test_args.unshift(~"rustdoctest"); test_args.unshift(~"rustdoctest");
testing::test_main(test_args, collector.tests); testing::test_main(test_args.as_slice(), collector.tests);
0 0
} }

View File

@ -31,7 +31,7 @@ pub struct Guard<'a> {
} }
struct Inner { struct Inner {
queue: ~[BlockedTask], queue: Vec<BlockedTask>,
held: bool, held: bool,
} }
@ -39,7 +39,7 @@ impl Access {
pub fn new() -> Access { pub fn new() -> Access {
Access { Access {
inner: UnsafeArc::new(Inner { inner: UnsafeArc::new(Inner {
queue: ~[], queue: vec![],
held: false, held: false,
}) })
} }

View File

@ -170,14 +170,14 @@ impl<'a> Stats for &'a [f64] {
// FIXME #11059 handle NaN, inf and overflow // FIXME #11059 handle NaN, inf and overflow
#[allow(deprecated_owned_vector)] #[allow(deprecated_owned_vector)]
fn sum(self) -> f64 { fn sum(self) -> f64 {
let mut partials : ~[f64] = ~[]; let mut partials = vec![];
for &mut x in self.iter() { for &mut x in self.iter() {
let mut j = 0; let mut j = 0;
// This inner loop applies `hi`/`lo` summation to each // This inner loop applies `hi`/`lo` summation to each
// partial so that the list of partial sums remains exact. // partial so that the list of partial sums remains exact.
for i in range(0, partials.len()) { for i in range(0, partials.len()) {
let mut y = partials[i]; let mut y = *partials.get(i);
if num::abs(x) < num::abs(y) { if num::abs(x) < num::abs(y) {
mem::swap(&mut x, &mut y); mem::swap(&mut x, &mut y);
} }
@ -186,7 +186,7 @@ impl<'a> Stats for &'a [f64] {
let hi = x + y; let hi = x + y;
let lo = y - (hi - x); let lo = y - (hi - x);
if lo != 0f64 { if lo != 0f64 {
partials[j] = lo; *partials.get_mut(j) = lo;
j += 1; j += 1;
} }
x = hi; x = hi;
@ -194,7 +194,7 @@ impl<'a> Stats for &'a [f64] {
if j >= partials.len() { if j >= partials.len() {
partials.push(x); partials.push(x);
} else { } else {
partials[j] = x; *partials.get_mut(j) = x;
partials.truncate(j+1); partials.truncate(j+1);
} }
} }

View File

@ -17,6 +17,7 @@
html_root_url = "http://static.rust-lang.org/doc/master")] html_root_url = "http://static.rust-lang.org/doc/master")]
#![feature(phase)] #![feature(phase)]
#![allow(visible_private_types)] #![allow(visible_private_types)]
#![deny(deprecated_owned_vector)]
#[phase(syntax, link)] extern crate log; #[phase(syntax, link)] extern crate log;
extern crate serialize; extern crate serialize;
@ -319,8 +320,8 @@ impl Exec {
} }
// returns pairs of (kind, name) // returns pairs of (kind, name)
pub fn lookup_discovered_inputs(&self) -> ~[(~str, ~str)] { pub fn lookup_discovered_inputs(&self) -> Vec<(~str, ~str)> {
let mut rs = ~[]; let mut rs = vec![];
let WorkMap(ref discovered_inputs) = self.discovered_inputs; let WorkMap(ref discovered_inputs) = self.discovered_inputs;
for (k, v) in discovered_inputs.iter() { for (k, v) in discovered_inputs.iter() {
let KindMap(ref vmap) = *v; let KindMap(ref vmap) = *v;
@ -341,8 +342,8 @@ impl<'a> Prep<'a> {
} }
} }
pub fn lookup_declared_inputs(&self) -> ~[~str] { pub fn lookup_declared_inputs(&self) -> Vec<~str> {
let mut rs = ~[]; let mut rs = vec![];
let WorkMap(ref declared_inputs) = self.declared_inputs; let WorkMap(ref declared_inputs) = self.declared_inputs;
for (_, v) in declared_inputs.iter() { for (_, v) in declared_inputs.iter() {
let KindMap(ref vmap) = *v; let KindMap(ref vmap) = *v;

View File

@ -76,7 +76,7 @@ fn main() {
format!("{}\t trees of depth {}\t check: {}", format!("{}\t trees of depth {}\t check: {}",
iterations * 2, depth, chk) iterations * 2, depth, chk)
}) })
}).collect::<~[Future<~str>]>(); }).collect::<Vec<Future<~str>>>();
for message in messages.mut_iter() { for message in messages.mut_iter() {
println!("{}", *message.get_ref()); println!("{}", *message.get_ref());