Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove some internal ~[] from several libraries.
Some straggling instances of `~[]` across a few different libs. Also,
remove some public ones from workcache.
  • Loading branch information
huonw authored and alexcrichton committed Apr 10, 2014
1 parent 32cf4a1 commit 6e63b12
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/compiletest/runtest.rs
Expand Up @@ -451,7 +451,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
let options_to_remove = [~"-O", ~"-g", ~"--debuginfo"];
let new_options = split_maybe_args(options).move_iter()
.filter(|x| !options_to_remove.contains(x))
.collect::<~[~str]>()
.collect::<Vec<~str>>()
.connect(" ");
Some(new_options)
}
Expand Down
4 changes: 2 additions & 2 deletions src/libflate/lib.rs
Expand Up @@ -117,13 +117,13 @@ mod tests {
words.push(r.gen_vec::<u8>(range));
}
for _ in range(0, 20) {
let mut input = ~[];
let mut input = vec![];
for _ in range(0, 2000) {
input.push_all(r.choose(words.as_slice()).as_slice());
}
debug!("de/inflate of {} bytes of random word-sequences",
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");
debug!("{} bytes deflated to {} ({:.1f}% size)",
input.len(), cmp.len(),
Expand Down
2 changes: 1 addition & 1 deletion src/libgetopts/lib.rs
Expand Up @@ -53,7 +53,7 @@
//!
//! let program = args[0].clone();
//!
//! let opts = ~[
//! let opts = [
//! optopt("o", "", "set output file name", "NAME"),
//! optflag("h", "help", "print this help menu")
//! ];
Expand Down
12 changes: 7 additions & 5 deletions src/libglob/lib.rs
Expand Up @@ -31,6 +31,8 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://static.rust-lang.org/doc/master")]

#![deny(deprecated_owned_vector)]

use std::cell::Cell;
use std::{cmp, os, path};
use std::io::fs;
Expand Down Expand Up @@ -245,26 +247,26 @@ impl 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 i = 0;

while i < chars.len() {
match chars[i] {
match *chars.get(i) {
'?' => {
tokens.push(AnyChar);
i += 1;
}
'*' => {
// *, **, ***, ****, ... are all equivalent
while i < chars.len() && chars[i] == '*' {
while i < chars.len() && *chars.get(i) == '*' {
i += 1;
}
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(&']') {
None => (),
Some(j) => {
Expand All @@ -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(&']') {
None => (),
Some(j) => {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/creader.rs
Expand Up @@ -190,7 +190,7 @@ fn visit_item(e: &Env, i: &ast::Item) {
} else {
None
})
.collect::<~[&ast::Attribute]>();
.collect::<Vec<&ast::Attribute>>();
for m in link_args.iter() {
match m.value_str() {
Some(linkarg) => e.sess.cstore.add_used_link_args(linkarg.get()),
Expand All @@ -205,7 +205,7 @@ fn visit_item(e: &Env, i: &ast::Item) {
} else {
None
})
.collect::<~[&ast::Attribute]>();
.collect::<Vec<&ast::Attribute>>();
for m in link_args.iter() {
match m.meta_item_list() {
Some(items) => {
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/markdown.rs
Expand Up @@ -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| {
let text = str::from_utf8(text).unwrap();
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 {
data: text.as_bytes().as_ptr(),
Expand Down Expand Up @@ -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(),
None => s.to_owned()
}
}).collect::<~[~str]>().connect("-");
}).collect::<Vec<~str>>().connect("-");

let opaque = unsafe {&mut *(opaque as *mut my_opaque)};

Expand Down Expand Up @@ -285,7 +285,7 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
let tests = &mut *(opaque as *mut ::test::Collector);
let text = str::from_utf8(text).unwrap();
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);
})
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustdoc/html/render.rs
Expand Up @@ -1205,8 +1205,8 @@ fn item_trait(w: &mut Writer, it: &clean::Item,
it.name.get_ref().as_slice(),
t.generics,
parents));
let required = t.methods.iter().filter(|m| m.is_req()).collect::<~[&clean::TraitMethod]>();
let provided = 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::<Vec<&clean::TraitMethod>>();

if t.methods.len() == 0 {
try!(write!(w, "\\{ \\}"));
Expand Down Expand Up @@ -1502,11 +1502,11 @@ fn render_methods(w: &mut Writer, it: &clean::Item) -> fmt::Result {
let mut non_trait = v.iter().filter(|p| {
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| {
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 {
try!(write!(w, "<h2 id='methods'>Methods</h2>"));
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/markdown.rs
Expand Up @@ -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`.
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 mut collector = Collector::new(input.to_owned(), libs, true, true);
find_testable_code(input_str, &mut collector);
test_args.unshift(~"rustdoctest");
testing::test_main(test_args, collector.tests);
testing::test_main(test_args.as_slice(), collector.tests);
0
}
4 changes: 2 additions & 2 deletions src/librustuv/access.rs
Expand Up @@ -31,15 +31,15 @@ pub struct Guard<'a> {
}

struct Inner {
queue: ~[BlockedTask],
queue: Vec<BlockedTask>,
held: bool,
}

impl Access {
pub fn new() -> Access {
Access {
inner: UnsafeArc::new(Inner {
queue: ~[],
queue: vec![],
held: false,
})
}
Expand Down
8 changes: 4 additions & 4 deletions src/libtest/stats.rs
Expand Up @@ -170,14 +170,14 @@ impl<'a> Stats for &'a [f64] {
// FIXME #11059 handle NaN, inf and overflow
#[allow(deprecated_owned_vector)]
fn sum(self) -> f64 {
let mut partials : ~[f64] = ~[];
let mut partials = vec![];

for &mut x in self.iter() {
let mut j = 0;
// This inner loop applies `hi`/`lo` summation to each
// partial so that the list of partial sums remains exact.
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) {
mem::swap(&mut x, &mut y);
}
Expand All @@ -186,15 +186,15 @@ impl<'a> Stats for &'a [f64] {
let hi = x + y;
let lo = y - (hi - x);
if lo != 0f64 {
partials[j] = lo;
*partials.get_mut(j) = lo;
j += 1;
}
x = hi;
}
if j >= partials.len() {
partials.push(x);
} else {
partials[j] = x;
*partials.get_mut(j) = x;
partials.truncate(j+1);
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/libworkcache/lib.rs
Expand Up @@ -17,6 +17,7 @@
html_root_url = "http://static.rust-lang.org/doc/master")]
#![feature(phase)]
#![allow(visible_private_types)]
#![deny(deprecated_owned_vector)]

#[phase(syntax, link)] extern crate log;
extern crate serialize;
Expand Down Expand Up @@ -319,8 +320,8 @@ impl Exec {
}

// returns pairs of (kind, name)
pub fn lookup_discovered_inputs(&self) -> ~[(~str, ~str)] {
let mut rs = ~[];
pub fn lookup_discovered_inputs(&self) -> Vec<(~str, ~str)> {
let mut rs = vec![];
let WorkMap(ref discovered_inputs) = self.discovered_inputs;
for (k, v) in discovered_inputs.iter() {
let KindMap(ref vmap) = *v;
Expand All @@ -341,8 +342,8 @@ impl<'a> Prep<'a> {
}
}

pub fn lookup_declared_inputs(&self) -> ~[~str] {
let mut rs = ~[];
pub fn lookup_declared_inputs(&self) -> Vec<~str> {
let mut rs = vec![];
let WorkMap(ref declared_inputs) = self.declared_inputs;
for (_, v) in declared_inputs.iter() {
let KindMap(ref vmap) = *v;
Expand Down
2 changes: 1 addition & 1 deletion src/test/bench/shootout-binarytrees.rs
Expand Up @@ -76,7 +76,7 @@ fn main() {
format!("{}\t trees of depth {}\t check: {}",
iterations * 2, depth, chk)
})
}).collect::<~[Future<~str>]>();
}).collect::<Vec<Future<~str>>>();

for message in messages.mut_iter() {
println!("{}", *message.get_ref());
Expand Down

0 comments on commit 6e63b12

Please sign in to comment.