Skip to content

Commit 9cd40f6

Browse files
committed
---
yaml --- r: 140735 b: refs/heads/try2 c: 7dc94b8 h: refs/heads/master i: 140733: e2ea1be 140731: d6fd8ac 140727: 71e6a24 140719: aadab54 140703: 9ae0c1d 140671: d49bf29 v: v3
1 parent 8402eed commit 9cd40f6

File tree

187 files changed

+3921
-1135
lines changed

Some content is hidden

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

187 files changed

+3921
-1135
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: 0acb6abb86125a1db878c256fbcf1a94b2577feb
8+
refs/heads/try2: 7dc94b87686ffd78a71442304158eb91d43885b0
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,35 +1946,6 @@ fn avg(v: &[float]) -> float {
19461946
}
19471947
~~~~
19481948

1949-
#### Swap expressions
1950-
1951-
A _swap expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) followed by a bi-directional arrow (`<->`) and another [lvalue](#lvalues-rvalues-and-temporaries).
1952-
1953-
Evaluating a swap expression causes, as a side effect, the values held in the left-hand-side and right-hand-side [lvalues](#lvalues-rvalues-and-temporaries) to be exchanged indivisibly.
1954-
1955-
Evaluating a swap expression neither changes reference counts,
1956-
nor deeply copies any owned structure pointed to by the moved [rvalue](#lvalues-rvalues-and-temporaries).
1957-
Instead, the swap expression represents an indivisible *exchange of ownership*,
1958-
between the right-hand-side and the left-hand-side of the expression.
1959-
No allocation or destruction is entailed.
1960-
1961-
An example of three different swap expressions:
1962-
1963-
~~~~~~~~
1964-
# let mut x = &mut [0];
1965-
# let mut a = &mut [0];
1966-
# let i = 0;
1967-
# struct S1 { z: int };
1968-
# struct S2 { c: int };
1969-
# let mut y = S1{z: 0};
1970-
# let mut b = S2{c: 0};
1971-
1972-
x <-> a;
1973-
x[i] <-> a[i];
1974-
y.z <-> b.c;
1975-
~~~~~~~~
1976-
1977-
19781949
#### Assignment expressions
19791950

19801951
An _assignment expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) expression followed by an
@@ -2015,7 +1986,7 @@ as
20151986
== !=
20161987
&&
20171988
||
2018-
= <->
1989+
=
20191990
~~~~
20201991

20211992
Operators at the same precedence level are evaluated left-to-right.

branches/try2/doc/tutorial-ffi.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ wrapping `malloc` and `free`:
151151
~~~~
152152
use core::libc::{c_void, size_t, malloc, free};
153153
use core::unstable::intrinsics;
154+
use core::util;
154155
155156
// a wrapper around the handle returned by the foreign code
156157
pub struct Unique<T> {
@@ -184,7 +185,8 @@ impl<T: Owned> Drop for Unique<T> {
184185
fn finalize(&self) {
185186
unsafe {
186187
let mut x = intrinsics::init(); // dummy value to swap in
187-
x <-> *self.ptr; // moving the object out is needed to call the destructor
188+
// moving the object out is needed to call the destructor
189+
util::replace_ptr(self.ptr, x);
188190
free(self.ptr as *c_void)
189191
}
190192
}

branches/try2/doc/tutorial.md

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ we have a file `hello.rs` containing this program:
129129

130130
~~~~
131131
fn main() {
132-
io::println("hello?");
132+
println("hello?");
133133
}
134134
~~~~
135135

@@ -139,12 +139,12 @@ Windows) which, upon running, will likely do exactly what you expect.
139139

140140
The Rust compiler tries to provide useful information when it encounters an
141141
error. If you introduce an error into the program (for example, by changing
142-
`io::println` to some nonexistent function), and then compile it, you'll see
142+
`println` to some nonexistent function), and then compile it, you'll see
143143
an error message like this:
144144

145145
~~~~ {.notrust}
146-
hello.rs:2:4: 2:16 error: unresolved name: io::print_with_unicorns
147-
hello.rs:2 io::print_with_unicorns("hello?");
146+
hello.rs:2:4: 2:16 error: unresolved name: print_with_unicorns
147+
hello.rs:2 print_with_unicorns("hello?");
148148
^~~~~~~~~~~~~~~~~~~~~~~
149149
~~~~
150150

@@ -227,7 +227,7 @@ let hi = "hi";
227227
let mut count = 0;
228228
229229
while count < 10 {
230-
io::println(fmt!("count: %?", count));
230+
println(fmt!("count: %?", count));
231231
count += 1;
232232
}
233233
~~~~
@@ -400,10 +400,10 @@ don't match the types of the arguments.
400400
~~~~
401401
# let mystery_object = ();
402402
403-
io::println(fmt!("%s is %d", "the answer", 43));
403+
println(fmt!("%s is %d", "the answer", 43));
404404
405405
// %? will conveniently print any type
406-
io::println(fmt!("what is this thing: %?", mystery_object));
406+
println(fmt!("what is this thing: %?", mystery_object));
407407
~~~~
408408

409409
[pf]: http://en.cppreference.com/w/cpp/io/c/fprintf
@@ -422,11 +422,11 @@ compulsory, an `if` can have an optional `else` clause, and multiple
422422

423423
~~~~
424424
if false {
425-
io::println("that's odd");
425+
println("that's odd");
426426
} else if true {
427-
io::println("right");
427+
println("right");
428428
} else {
429-
io::println("neither true nor false");
429+
println("neither true nor false");
430430
}
431431
~~~~
432432

@@ -454,10 +454,10 @@ executes its corresponding arm.
454454
~~~~
455455
# let my_number = 1;
456456
match my_number {
457-
0 => io::println("zero"),
458-
1 | 2 => io::println("one or two"),
459-
3..10 => io::println("three to ten"),
460-
_ => io::println("something else")
457+
0 => println("zero"),
458+
1 | 2 => println("one or two"),
459+
3..10 => println("three to ten"),
460+
_ => println("something else")
461461
}
462462
~~~~
463463

@@ -483,8 +483,8 @@ commas are optional.
483483
~~~
484484
# let my_number = 1;
485485
match my_number {
486-
0 => { io::println("zero") }
487-
_ => { io::println("something else") }
486+
0 => { println("zero") }
487+
_ => { println("something else") }
488488
}
489489
~~~
490490

@@ -560,7 +560,7 @@ let mut x = 5;
560560
loop {
561561
x += x - 3;
562562
if x % 5 == 0 { break; }
563-
io::println(int::to_str(x));
563+
println(int::to_str(x));
564564
}
565565
~~~~
566566

@@ -614,8 +614,8 @@ origin.y += 1.0; // ERROR: assigning to immutable field
614614
# struct Point { x: float, y: float }
615615
# let mypoint = Point { x: 0.0, y: 0.0 };
616616
match mypoint {
617-
Point { x: 0.0, y: yy } => { io::println(yy.to_str()); }
618-
Point { x: xx, y: yy } => { io::println(xx.to_str() + " " + yy.to_str()); }
617+
Point { x: 0.0, y: yy } => { println(yy.to_str()); }
618+
Point { x: xx, y: yy } => { println(xx.to_str() + " " + yy.to_str()); }
619619
}
620620
~~~~
621621

@@ -630,7 +630,7 @@ reuses the field name as the binding name.
630630
# struct Point { x: float, y: float }
631631
# let mypoint = Point { x: 0.0, y: 0.0 };
632632
match mypoint {
633-
Point { x, _ } => { io::println(x.to_str()) }
633+
Point { x, _ } => { println(x.to_str()) }
634634
}
635635
~~~
636636

@@ -1231,7 +1231,7 @@ something silly like
12311231
~~~
12321232
# struct Point { x: float, y: float }
12331233
let point = &@~Point { x: 10f, y: 20f };
1234-
io::println(fmt!("%f", point.x));
1234+
println(fmt!("%f", point.x));
12351235
~~~
12361236
12371237
The indexing operator (`[]`) also auto-dereferences.
@@ -1373,7 +1373,6 @@ and [`core::str`]. Here are some examples.
13731373
[`core::str`]: core/str.html
13741374

13751375
~~~
1376-
# use core::io::println;
13771376
# enum Crayon {
13781377
# Almond, AntiqueBrass, Apricot,
13791378
# Aquamarine, Asparagus, AtomicTangerine,
@@ -1428,7 +1427,6 @@ Rust also supports _closures_, functions that can access variables in
14281427
the enclosing scope.
14291428

14301429
~~~~
1431-
# use println = core::io::println;
14321430
fn call_closure_with_ten(b: &fn(int)) { b(10); }
14331431
14341432
let captured_var = 20;
@@ -1490,7 +1488,7 @@ fn mk_appender(suffix: ~str) -> @fn(~str) -> ~str {
14901488
14911489
fn main() {
14921490
let shout = mk_appender(~"!");
1493-
io::println(shout(~"hey ho, let's go"));
1491+
println(shout(~"hey ho, let's go"));
14941492
}
14951493
~~~~
14961494

@@ -1632,7 +1630,6 @@ And using this function to iterate over a vector:
16321630

16331631
~~~~
16341632
# use each = core::vec::each;
1635-
# use println = core::io::println;
16361633
each([2, 4, 8, 5, 16], |n| {
16371634
if *n % 2 != 0 {
16381635
println("found odd number!");
@@ -1649,7 +1646,6 @@ to the next iteration, write `loop`.
16491646

16501647
~~~~
16511648
# use each = core::vec::each;
1652-
# use println = core::io::println;
16531649
for each([2, 4, 8, 5, 16]) |n| {
16541650
if *n % 2 != 0 {
16551651
println("found odd number!");
@@ -1982,7 +1978,7 @@ struct TimeBomb {
19821978
impl Drop for TimeBomb {
19831979
fn finalize(&self) {
19841980
for old_iter::repeat(self.explosivity) {
1985-
io::println("blam!");
1981+
println("blam!");
19861982
}
19871983
}
19881984
}
@@ -2014,11 +2010,11 @@ and `~str`.
20142010
~~~~
20152011
# trait Printable { fn print(&self); }
20162012
impl Printable for int {
2017-
fn print(&self) { io::println(fmt!("%d", *self)) }
2013+
fn print(&self) { println(fmt!("%d", *self)) }
20182014
}
20192015
20202016
impl Printable for ~str {
2021-
fn print(&self) { io::println(*self) }
2017+
fn print(&self) { println(*self) }
20222018
}
20232019
20242020
# 1.print();
@@ -2307,7 +2303,7 @@ mod farm {
23072303
}
23082304
23092305
fn main() {
2310-
io::println(farm::chicken());
2306+
println(farm::chicken());
23112307
}
23122308
~~~~
23132309

@@ -2507,7 +2503,7 @@ pub fn explore() -> &str { "world" }
25072503
~~~~ {.xfail-test}
25082504
// main.rs
25092505
extern mod world;
2510-
fn main() { io::println(~"hello " + world::explore()); }
2506+
fn main() { println(~"hello " + world::explore()); }
25112507
~~~~
25122508

25132509
Now compile and run like this (adjust to your platform if necessary):

branches/try2/src/compiletest/compiletest.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#[allow(vecs_implicitly_copyable)];
1414
#[allow(non_camel_case_types)];
15-
#[allow(deprecated_mode)];
1615
#[allow(deprecated_pattern)];
1716

1817
extern mod std(vers = "0.7-pre");

branches/try2/src/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn is_test_ignored(config: config, testfile: &Path) -> bool {
9191
return false;
9292

9393
fn xfail_target() -> ~str {
94-
~"xfail-" + str::from_slice(os::SYSNAME)
94+
~"xfail-" + str::to_owned(os::SYSNAME)
9595
}
9696
}
9797

branches/try2/src/compiletest/runtest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
371371
was_expected = true;
372372
}
373373

374-
if !was_expected && is_compiler_error_or_warning(str::from_slice(line)) {
374+
if !was_expected && is_compiler_error_or_warning(str::to_owned(line)) {
375375
fatal_ProcRes(fmt!("unexpected compiler error or warning: '%s'",
376376
line),
377377
ProcRes);
@@ -596,7 +596,7 @@ fn make_lib_name(config: config, auxfile: &Path, testfile: &Path) -> Path {
596596

597597
fn make_exe_name(config: config, testfile: &Path) -> Path {
598598
Path(output_base_name(config, testfile).to_str() +
599-
str::from_slice(os::EXE_SUFFIX))
599+
str::to_owned(os::EXE_SUFFIX))
600600
}
601601

602602
fn make_run_args(config: config, _props: TestProps, testfile: &Path) ->

branches/try2/src/libcore/cell.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1313
use cast::transmute_mut;
1414
use prelude::*;
15+
use util::replace;
1516

1617
/*
1718
A dynamic, mutable location.
@@ -48,9 +49,7 @@ pub impl<T> Cell<T> {
4849
fail!(~"attempt to take an empty cell");
4950
}
5051
51-
let mut value = None;
52-
value <-> self.value;
53-
value.unwrap()
52+
replace(&mut self.value, None).unwrap()
5453
}
5554
5655
/// Returns the value, failing if the cell is full.

branches/try2/src/libcore/cleanup.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ struct AnnihilateStats {
127127
n_bytes_freed: uint
128128
}
129129

130+
#[cfg(stage0)]
130131
unsafe fn each_live_alloc(read_next_before: bool,
131132
f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) {
132133
//! Walks the internal list of allocations
@@ -141,8 +142,8 @@ unsafe fn each_live_alloc(read_next_before: bool,
141142
let uniq =
142143
(*box).header.ref_count == managed::raw::RC_MANAGED_UNIQUE;
143144

144-
if ! f(box, uniq) {
145-
break
145+
if !f(box, uniq) {
146+
return;
146147
}
147148

148149
if read_next_before {
@@ -152,6 +153,33 @@ unsafe fn each_live_alloc(read_next_before: bool,
152153
}
153154
}
154155
}
156+
#[cfg(not(stage0))]
157+
unsafe fn each_live_alloc(read_next_before: bool,
158+
f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) -> bool {
159+
//! Walks the internal list of allocations
160+
161+
use managed;
162+
163+
let task: *Task = transmute(rustrt::rust_get_task());
164+
let box = (*task).boxed_region.live_allocs;
165+
let mut box: *mut BoxRepr = transmute(copy box);
166+
while box != mut_null() {
167+
let next_before = transmute(copy (*box).header.next);
168+
let uniq =
169+
(*box).header.ref_count == managed::raw::RC_MANAGED_UNIQUE;
170+
171+
if !f(box, uniq) {
172+
return false;
173+
}
174+
175+
if read_next_before {
176+
box = next_before;
177+
} else {
178+
box = transmute(copy (*box).header.next);
179+
}
180+
}
181+
return true;
182+
}
155183

156184
#[cfg(unix)]
157185
fn debug_mem() -> bool {

0 commit comments

Comments
 (0)