Skip to content

Commit 8bdb74e

Browse files
committed
---
yaml --- r: 150905 b: refs/heads/try2 c: 065c4a6 h: refs/heads/master i: 150903: 0dd0402 v: v3
1 parent 727cb8a commit 8bdb74e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1168
-484
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: d1d8497e53af86687e701eea0fe2a41b0c4313eb
8+
refs/heads/try2: 065c4a69676d74bb9fbe726719e36fb0673517da
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ documentation.
2525
* `perl` 5.0 or later
2626
* GNU `make` 3.81 or later
2727
* `curl`
28+
* `git`
2829
2. Download and build Rust:
2930

3031
You can either download a [tarball] or build directly from the [repo].

branches/try2/src/compiletest/runtest.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use std::os;
3333
use std::str;
3434
use std::strbuf::StrBuf;
3535
use std::task;
36+
use std::slice;
3637
use test::MetricMap;
3738

3839
pub fn run(config: config, testfile: ~str) {
@@ -508,7 +509,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
508509
proc_res: &ProcRes) {
509510
510511
// true if we found the error in question
511-
let mut found_flags = Vec::from_elem(
512+
let mut found_flags = slice::from_elem(
512513
expected_errors.len(), false);
513514
514515
if proc_res.status.success() {
@@ -553,13 +554,13 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
553554
for line in proc_res.stderr.lines() {
554555
let mut was_expected = false;
555556
for (i, ee) in expected_errors.iter().enumerate() {
556-
if !*found_flags.get(i) {
557+
if !found_flags[i] {
557558
debug!("prefix={} ee.kind={} ee.msg={} line={}",
558559
*prefixes.get(i), ee.kind, ee.msg, line);
559560
if prefix_matches(line, *prefixes.get(i)) &&
560561
line.contains(ee.kind) &&
561562
line.contains(ee.msg) {
562-
*found_flags.get_mut(i) = true;
563+
found_flags[i] = true;
563564
was_expected = true;
564565
break;
565566
}

branches/try2/src/doc/guide-tasks.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,10 @@ might look like the example below.
255255

256256
~~~
257257
# use std::task::spawn;
258+
# use std::slice;
258259
259260
// Create a vector of ports, one for each child task
260-
let rxs = Vec::from_fn(3, |init_val| {
261+
let rxs = slice::from_fn(3, |init_val| {
261262
let (tx, rx) = channel();
262263
spawn(proc() {
263264
tx.send(some_expensive_computation(init_val));
@@ -303,6 +304,7 @@ be distributed on the available cores.
303304

304305
~~~
305306
# extern crate sync;
307+
# use std::slice;
306308
fn partial_sum(start: uint) -> f64 {
307309
let mut local_sum = 0f64;
308310
for num in range(start*100000, (start+1)*100000) {
@@ -312,7 +314,7 @@ fn partial_sum(start: uint) -> f64 {
312314
}
313315
314316
fn main() {
315-
let mut futures = Vec::from_fn(1000, |ind| sync::Future::spawn( proc() { partial_sum(ind) }));
317+
let mut futures = slice::from_fn(1000, |ind| sync::Future::spawn( proc() { partial_sum(ind) }));
316318
317319
let mut final_res = 0f64;
318320
for ft in futures.mut_iter() {
@@ -340,24 +342,25 @@ a single large vector of floats. Each task needs the full vector to perform its
340342
extern crate rand;
341343
extern crate sync;
342344
345+
use std::slice;
343346
use sync::Arc;
344347
345-
fn pnorm(nums: &[f64], p: uint) -> f64 {
348+
fn pnorm(nums: &~[f64], p: uint) -> f64 {
346349
nums.iter().fold(0.0, |a,b| a+(*b).powf(&(p as f64)) ).powf(&(1.0 / (p as f64)))
347350
}
348351
349352
fn main() {
350-
let numbers = Vec::from_fn(1000000, |_| rand::random::<f64>());
353+
let numbers = slice::from_fn(1000000, |_| rand::random::<f64>());
351354
let numbers_arc = Arc::new(numbers);
352355
353356
for num in range(1u, 10) {
354357
let (tx, rx) = channel();
355358
tx.send(numbers_arc.clone());
356359
357360
spawn(proc() {
358-
let local_arc : Arc<Vec<f64>> = rx.recv();
361+
let local_arc : Arc<~[f64]> = rx.recv();
359362
let task_numbers = &*local_arc;
360-
println!("{}-norm = {}", num, pnorm(task_numbers.as_slice(), num));
363+
println!("{}-norm = {}", num, pnorm(task_numbers, num));
361364
});
362365
}
363366
}
@@ -371,8 +374,9 @@ created by the line
371374
# extern crate sync;
372375
# extern crate rand;
373376
# use sync::Arc;
377+
# use std::slice;
374378
# fn main() {
375-
# let numbers = Vec::from_fn(1000000, |_| rand::random::<f64>());
379+
# let numbers = slice::from_fn(1000000, |_| rand::random::<f64>());
376380
let numbers_arc=Arc::new(numbers);
377381
# }
378382
~~~
@@ -383,8 +387,9 @@ and a clone of it is sent to each task
383387
# extern crate sync;
384388
# extern crate rand;
385389
# use sync::Arc;
390+
# use std::slice;
386391
# fn main() {
387-
# let numbers=Vec::from_fn(1000000, |_| rand::random::<f64>());
392+
# let numbers=slice::from_fn(1000000, |_| rand::random::<f64>());
388393
# let numbers_arc = Arc::new(numbers);
389394
# let (tx, rx) = channel();
390395
tx.send(numbers_arc.clone());
@@ -399,12 +404,13 @@ Each task recovers the underlying data by
399404
# extern crate sync;
400405
# extern crate rand;
401406
# use sync::Arc;
407+
# use std::slice;
402408
# fn main() {
403-
# let numbers=Vec::from_fn(1000000, |_| rand::random::<f64>());
409+
# let numbers=slice::from_fn(1000000, |_| rand::random::<f64>());
404410
# let numbers_arc=Arc::new(numbers);
405411
# let (tx, rx) = channel();
406412
# tx.send(numbers_arc.clone());
407-
# let local_arc : Arc<Vec<f64>> = rx.recv();
413+
# let local_arc : Arc<~[f64]> = rx.recv();
408414
let task_numbers = &*local_arc;
409415
# }
410416
~~~

branches/try2/src/doc/tutorial.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,12 +1582,12 @@ the elements are mutable if the vector is mutable.
15821582
use std::strbuf::StrBuf;
15831583

15841584
// A dynamically sized vector (unique vector)
1585-
let mut numbers = vec![1, 2, 3];
1585+
let mut numbers = ~[1, 2, 3];
15861586
numbers.push(4);
15871587
numbers.push(5);
15881588

15891589
// The type of a unique vector is written as `~[int]`
1590-
let more_numbers: ~[int] = numbers.move_iter().collect();
1590+
let more_numbers: ~[int] = numbers;
15911591

15921592
// The original `numbers` value can no longer be used, due to move semantics.
15931593

@@ -1955,8 +1955,8 @@ vector consisting of the result of applying `function` to each element
19551955
of `vector`:
19561956
19571957
~~~~
1958-
fn map<T, U>(vector: &[T], function: |v: &T| -> U) -> Vec<U> {
1959-
let mut accumulator = Vec::new();
1958+
fn map<T, U>(vector: &[T], function: |v: &T| -> U) -> ~[U] {
1959+
let mut accumulator = ~[];
19601960
for element in vector.iter() {
19611961
accumulator.push(function(element));
19621962
}

branches/try2/src/libnative/io/addrinfo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl GetAddrInfoRequest {
5757
}
5858

5959
// Collect all the results we found
60-
let mut addrs = Vec::new();
60+
let mut addrs = ~[];
6161
let mut rp = res;
6262
while rp.is_not_null() {
6363
unsafe {
@@ -80,7 +80,7 @@ impl GetAddrInfoRequest {
8080

8181
unsafe { freeaddrinfo(res); }
8282

83-
Ok(addrs.move_iter().collect())
83+
Ok(addrs)
8484
}
8585
}
8686

branches/try2/src/libnative/io/file_unix.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use libc::{c_int, c_void};
1818
use libc;
1919
use std::mem;
2020
use std::rt::rtio;
21+
use std::slice;
2122

2223
use io::{IoResult, retry, keep_going};
2324

@@ -415,7 +416,7 @@ pub fn readlink(p: &CString) -> IoResult<Path> {
415416
if len == -1 {
416417
len = 1024; // FIXME: read PATH_MAX from C ffi?
417418
}
418-
let mut buf: Vec<u8> = Vec::with_capacity(len as uint);
419+
let mut buf = slice::with_capacity::<u8>(len as uint);
419420
match retry(|| unsafe {
420421
libc::readlink(p, buf.as_ptr() as *mut libc::c_char,
421422
len as libc::size_t) as libc::c_int

branches/try2/src/libnative/io/process.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl Process {
7474
return Err(super::unimpl());
7575
}
7676

77-
fn get_io(io: p::StdioContainer, ret: &mut Vec<Option<file::FileDesc>>)
77+
fn get_io(io: p::StdioContainer, ret: &mut ~[Option<file::FileDesc>])
7878
-> (Option<os::Pipe>, c_int)
7979
{
8080
match io {
@@ -93,7 +93,7 @@ impl Process {
9393
}
9494
}
9595

96-
let mut ret_io = Vec::new();
96+
let mut ret_io = ~[];
9797
let (in_pipe, in_fd) = get_io(config.stdin, &mut ret_io);
9898
let (out_pipe, out_fd) = get_io(config.stdout, &mut ret_io);
9999
let (err_pipe, err_fd) = get_io(config.stderr, &mut ret_io);
@@ -117,7 +117,7 @@ impl Process {
117117
exit_code: None,
118118
exit_signal: None,
119119
},
120-
ret_io.move_iter().collect()))
120+
ret_io))
121121
}
122122
Err(e) => Err(e)
123123
}
@@ -641,10 +641,12 @@ fn spawn_process_os(config: p::ProcessConfig,
641641

642642
#[cfg(unix)]
643643
fn with_argv<T>(prog: &str, args: &[~str], cb: proc(**libc::c_char) -> T) -> T {
644+
use std::slice;
645+
644646
// We can't directly convert `str`s into `*char`s, as someone needs to hold
645647
// a reference to the intermediary byte buffers. So first build an array to
646648
// hold all the ~[u8] byte strings.
647-
let mut tmps = Vec::with_capacity(args.len() + 1);
649+
let mut tmps = slice::with_capacity(args.len() + 1);
648650

649651
tmps.push(prog.to_c_str());
650652

@@ -665,12 +667,14 @@ fn with_argv<T>(prog: &str, args: &[~str], cb: proc(**libc::c_char) -> T) -> T {
665667

666668
#[cfg(unix)]
667669
fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: proc(*c_void) -> T) -> T {
670+
use std::slice;
671+
668672
// On posixy systems we can pass a char** for envp, which is a
669673
// null-terminated array of "k=v\n" strings. Like `with_argv`, we have to
670674
// have a temporary buffer to hold the intermediary `~[u8]` byte strings.
671675
match env {
672676
Some(env) => {
673-
let mut tmps = Vec::with_capacity(env.len());
677+
let mut tmps = slice::with_capacity(env.len());
674678

675679
for pair in env.iter() {
676680
let kv = format!("{}={}", *pair.ref0(), *pair.ref1());
@@ -696,7 +700,7 @@ fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: |*mut c_void| -> T) -> T {
696700
// \0 to terminate.
697701
match env {
698702
Some(env) => {
699-
let mut blk = Vec::new();
703+
let mut blk = ~[];
700704

701705
for pair in env.iter() {
702706
let kv = format!("{}={}", *pair.ref0(), *pair.ref1());

branches/try2/src/librustc/back/rpath.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ pub fn minimize_rpaths(rpaths: &[~str]) -> Vec<~str> {
156156

157157
#[cfg(unix, test)]
158158
mod test {
159+
use std::os;
160+
159161
use back::rpath::get_install_prefix_rpath;
160162
use back::rpath::{minimize_rpaths, rpaths_to_flags, get_rpath_relative_to_output};
161163
use syntax::abi;

branches/try2/src/librustc/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,13 @@ pub fn describe_codegen_flags() {
223223
}
224224

225225
pub fn run_compiler(args: &[~str]) {
226-
let mut args = Vec::from_slice(args);
226+
let mut args = args.to_owned();
227227
let binary = args.shift().unwrap();
228228

229229
if args.is_empty() { usage(binary); return; }
230230

231231
let matches =
232-
&match getopts::getopts(args.as_slice(), d::optgroups().as_slice()) {
232+
&match getopts::getopts(args, d::optgroups().as_slice()) {
233233
Ok(m) => m,
234234
Err(f) => {
235235
d::early_error(f.to_err_msg());

branches/try2/src/librustc/middle/dataflow.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919

2020
use std::io;
21+
use std::slice;
2122
use std::strbuf::StrBuf;
2223
use std::uint;
2324
use syntax::ast;
@@ -307,13 +308,13 @@ impl<'a, O:DataFlowOperator+Clone+'static> DataFlowContext<'a, O> {
307308
changed: true
308309
};
309310

310-
let mut temp = Vec::from_elem(self.words_per_id, 0u);
311+
let mut temp = slice::from_elem(self.words_per_id, 0u);
311312
let mut loop_scopes = Vec::new();
312313

313314
while propcx.changed {
314315
propcx.changed = false;
315-
propcx.reset(temp.as_mut_slice());
316-
propcx.walk_block(blk, temp.as_mut_slice(), &mut loop_scopes);
316+
propcx.reset(temp);
317+
propcx.walk_block(blk, temp, &mut loop_scopes);
317318
}
318319
}
319320

branches/try2/src/librustc/middle/trans/callee.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* closure.
1717
*/
1818

19+
use std::slice;
20+
1921
use back::abi;
2022
use driver::session;
2123
use lib::llvm::{ValueRef, NoAliasAttribute, StructRetAttribute, NoCaptureAttribute};
@@ -219,12 +221,11 @@ fn resolve_default_method_vtables(bcx: &Block,
219221
Some(vtables) => {
220222
let num_impl_type_parameters =
221223
vtables.len() - num_method_vtables;
222-
Vec::from_slice(vtables.tailn(num_impl_type_parameters))
224+
vtables.tailn(num_impl_type_parameters).to_owned()
223225
},
224-
None => Vec::from_elem(num_method_vtables, @Vec::new())
226+
None => slice::from_elem(num_method_vtables, @Vec::new())
225227
};
226228

227-
let method_vtables = method_vtables.as_slice();
228229
let param_vtables = @((*trait_vtables_fixed).clone().append(method_vtables));
229230

230231
let self_vtables = resolve_param_vtables_under_param_substs(

branches/try2/src/librustc/middle/trans/consts.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,11 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
593593
const_eval::const_uint(i) => i as uint,
594594
_ => cx.sess().span_bug(count.span, "count must be integral const expression.")
595595
};
596-
let vs = Vec::from_elem(n, const_expr(cx, elem, is_local).val0());
596+
let vs = slice::from_elem(n, const_expr(cx, elem, is_local).val0());
597597
let v = if vs.iter().any(|vi| val_ty(*vi) != llunitty) {
598-
C_struct(cx, vs.as_slice(), false)
598+
C_struct(cx, vs, false)
599599
} else {
600-
C_array(llunitty, vs.as_slice())
600+
C_array(llunitty, vs)
601601
};
602602
(v, true)
603603
}

0 commit comments

Comments
 (0)