Skip to content

Commit 470ed54

Browse files
committed
---
yaml --- r: 47373 b: refs/heads/try c: 95bc9ea h: refs/heads/master i: 47371: 888bb41 v: v3
1 parent e8125a7 commit 470ed54

Some content is hidden

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

51 files changed

+131
-395
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
5-
refs/heads/try: 10929ed1ca422eeefee133ab39373947551aa62b
5+
refs/heads/try: 95bc9ea26df56b29f74583317ab080fdc7b99757
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/doc/rust.md

Lines changed: 14 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,19 +1285,22 @@ An _implementation_ is an item that implements a [trait](#traits) for a specific
12851285
Implementations are defined with the keyword `impl`.
12861286

12871287
~~~~
1288-
# type Point = {x: float, y: float};
1288+
# struct Point {x: float, y: float};
12891289
# type Surface = int;
1290-
# type BoundingBox = {x: float, y: float, width: float, height: float};
1290+
# struct BoundingBox {x: float, y: float, width: float, height: float};
12911291
# trait Shape { fn draw(Surface); fn bounding_box() -> BoundingBox; }
12921292
# fn do_draw_circle(s: Surface, c: Circle) { }
12931293
1294-
type Circle = {radius: float, center: Point};
1294+
struct Circle {
1295+
radius: float,
1296+
center: Point,
1297+
}
12951298
12961299
impl Shape for Circle {
12971300
fn draw(s: Surface) { do_draw_circle(s, self); }
12981301
fn bounding_box() -> BoundingBox {
12991302
let r = self.radius;
1300-
{x: self.center.x - r, y: self.center.y - r,
1303+
BoundingBox{x: self.center.x - r, y: self.center.y - r,
13011304
width: 2.0 * r, height: 2.0 * r}
13021305
}
13031306
}
@@ -1637,38 +1640,6 @@ rec_expr : '{' ident ':' expr
16371640
[ ".." expr ] '}'
16381641
~~~~~~~~
16391642

1640-
> **Note:** In future versions of Rust, record expressions and [record types](#record-types) will be removed.
1641-
1642-
A [_record_](#record-types) _expression_ is one or more comma-separated
1643-
name-value pairs enclosed by braces. A fieldname can be any identifier,
1644-
and is separated from its value expression by a
1645-
colon. To indicate that a field is mutable, the `mut` keyword is
1646-
written before its name.
1647-
1648-
~~~~
1649-
{x: 10f, y: 20f};
1650-
{name: "Joe", age: 35u, score: 100_000};
1651-
{ident: "X", mut count: 0u};
1652-
~~~~
1653-
1654-
The order of the fields in a record expression is significant, and
1655-
determines the type of the resulting value. `{a: u8, b: u8}` and `{b:
1656-
u8, a: u8}` are two different fields.
1657-
1658-
A record expression can terminate with the syntax `..` followed by an
1659-
expression to denote a functional update. The expression following
1660-
`..` (the base) must be of a record type that includes at least all the
1661-
fields mentioned in the record expression. A new record will be
1662-
created, of the same type as the base expression, with the given
1663-
values for the fields that were explicitly specified, and the values
1664-
in the base record for all other fields. The ordering of the fields in
1665-
such a record expression is not significant.
1666-
1667-
~~~~
1668-
let base = {x: 1, y: 2, z: 3};
1669-
{y: 0, z: 10, .. base};
1670-
~~~~
1671-
16721643
### Method-call expressions
16731644

16741645
~~~~~~~~{.ebnf .gram}
@@ -1689,7 +1660,7 @@ field_expr : expr '.' ident
16891660

16901661
A _field expression_ consists of an expression followed by a single dot and an identifier,
16911662
when not immediately followed by a parenthesized expression-list (the latter is a [method call expression](#method-call-expressions)).
1692-
A field expression denotes a field of a [structure](#structure-types) or [record](#record-types).
1663+
A field expression denotes a field of a [structure](#structure-types).
16931664

16941665
~~~~~~~~ {.field}
16951666
myrecord.myfield;
@@ -1905,8 +1876,10 @@ An example of three different swap expressions:
19051876
# let mut x = &mut [0];
19061877
# let mut a = &mut [0];
19071878
# let i = 0;
1908-
# let y = {mut z: 0};
1909-
# let b = {mut c: 0};
1879+
# struct S1 { z: int };
1880+
# struct S2 { c: int };
1881+
# let mut y = S1{z: 0};
1882+
# let mut b = S2{c: 0};
19101883
19111884
x <-> a;
19121885
x[i] <-> a[i];
@@ -2328,42 +2301,6 @@ match x {
23282301
}
23292302
~~~~
23302303

2331-
Records and structures can also be pattern-matched and their fields bound to variables.
2332-
When matching fields of a record,
2333-
the fields being matched are specified first,
2334-
then a placeholder (`_`) represents the remaining fields.
2335-
2336-
~~~~
2337-
# type options = {choose: bool, size: ~str};
2338-
# type player = {player: ~str, stats: (), options: options};
2339-
# fn load_stats() { }
2340-
# fn choose_player(r: &player) { }
2341-
# fn next_player() { }
2342-
2343-
fn main() {
2344-
let r = {
2345-
player: ~"ralph",
2346-
stats: load_stats(),
2347-
options: {
2348-
choose: true,
2349-
size: ~"small"
2350-
}
2351-
};
2352-
2353-
match r {
2354-
{options: {choose: true, _}, _} => {
2355-
choose_player(&r)
2356-
}
2357-
{player: ref p, options: {size: ~"small", _}, _} => {
2358-
log(info, (copy *p) + ~" is small");
2359-
}
2360-
_ => {
2361-
next_player();
2362-
}
2363-
}
2364-
}
2365-
~~~~
2366-
23672304
Patterns that bind variables default to binding to a copy of the matched value. This can be made
23682305
explicit using the ```copy``` keyword, changed to bind to a borrowed pointer by using the ```ref```
23692306
keyword, or to a mutable borrowed pointer using ```ref mut```, or the value can be moved into
@@ -2692,25 +2629,6 @@ let a: List<int> = Cons(7, @Cons(13, @Nil));
26922629
~~~~
26932630

26942631

2695-
### Record types
2696-
2697-
> **Note:** Records are not nominal types, thus do not directly support recursion, visibility control,
2698-
> out-of-order field initialization, or coherent trait implementation.
2699-
> Records are therefore deprecated and will be removed in future versions of Rust.
2700-
> [Structure types](#structure-types) should be used instead.
2701-
2702-
The record type-constructor forms a new heterogeneous product of values.
2703-
Fields of a record type are accessed by name and are arranged in memory in the order specified by the record type.
2704-
2705-
An example of a record type and its use:
2706-
2707-
~~~~
2708-
type Point = {x: int, y: int};
2709-
let p: Point = {x: 10, y: 11};
2710-
let px: int = p.x;
2711-
~~~~
2712-
2713-
27142632
### Pointer types
27152633

27162634
All pointers in Rust are explicit first-class values.
@@ -3040,7 +2958,8 @@ Some operations (such as field selection) implicitly dereference boxes. An
30402958
example of an _implicit dereference_ operation performed on box values:
30412959

30422960
~~~~~~~~
3043-
let x = @{y: 10};
2961+
struct Foo { y: int }
2962+
let x = @Foo{y: 10};
30442963
assert x.y == 10;
30452964
~~~~~~~~
30462965

branches/try/doc/tutorial-borrowed-ptr.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ operator. For example, I could write:
166166
# struct Point {x: float, y: float} // as before
167167
# struct Size {w: float, h: float} // as before
168168
# struct Rectangle {origin: Point, size: Size}
169-
# let rect_stack = &{origin: Point {x: 1f, y: 2f}, size: Size {w: 3f, h: 4f}};
170-
# let rect_managed = @{origin: Point {x: 3f, y: 4f}, size: Size {w: 3f, h: 4f}};
171-
# let rect_unique = ~{origin: Point {x: 5f, y: 6f}, size: Size {w: 3f, h: 4f}};
169+
# let rect_stack = &Rectangle {origin: Point {x: 1f, y: 2f}, size: Size {w: 3f, h: 4f}};
170+
# let rect_managed = @Rectangle {origin: Point {x: 3f, y: 4f}, size: Size {w: 3f, h: 4f}};
171+
# let rect_unique = ~Rectangle {origin: Point {x: 5f, y: 6f}, size: Size {w: 3f, h: 4f}};
172172
# fn compute_distance(p1: &Point, p2: &Point) -> float { 0f }
173173
compute_distance(&rect_stack.origin, &rect_managed.origin);
174174
~~~
@@ -274,13 +274,14 @@ the following function is legal:
274274

275275
~~~
276276
# fn some_condition() -> bool { true }
277+
# struct Foo { f: int }
277278
fn example3() -> int {
278-
let mut x = ~{f: 3};
279+
let mut x = ~Foo {f: 3};
279280
if some_condition() {
280281
let y = &x.f; // -+ L
281282
return *y; // |
282283
} // -+
283-
x = ~{f: 4};
284+
x = ~Foo {f: 4};
284285
...
285286
# return 0;
286287
}

branches/try/src/libcore/at_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub mod raw {
183183
use at_vec::{capacity, rustrt};
184184
use cast::transmute;
185185
use libc;
186-
use unstable::intrinsics::{move_val_init};
186+
use private::intrinsics::{move_val_init};
187187
use ptr::addr_of;
188188
use ptr;
189189
use sys;

branches/try/src/libcore/comm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use either::{Either, Left, Right};
1212
use kinds::Owned;
1313
use option;
1414
use option::{Option, Some, None, unwrap};
15-
use unstable;
15+
use private;
1616
use vec;
1717

1818
use pipes::{recv, try_recv, wait_many, peek, PacketHeader};
@@ -242,7 +242,7 @@ impl<T: Owned> Peekable<T> for PortSet<T> {
242242
}
243243
244244
/// A channel that can be shared between many senders.
245-
pub type SharedChan<T> = unstable::Exclusive<Chan<T>>;
245+
pub type SharedChan<T> = private::Exclusive<Chan<T>>;
246246
247247
impl<T: Owned> GenericChan<T> for SharedChan<T> {
248248
fn send(x: T) {
@@ -268,7 +268,7 @@ impl<T: Owned> GenericSmartChan<T> for SharedChan<T> {
268268
269269
/// Converts a `chan` into a `shared_chan`.
270270
pub fn SharedChan<T:Owned>(c: Chan<T>) -> SharedChan<T> {
271-
unstable::exclusive(c)
271+
private::exclusive(c)
272272
}
273273
274274
/// Receive a message from one of two endpoints.

branches/try/src/libcore/core.rc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,8 @@ pub const debug : u32 = 4_u32;
228228
// The runtime interface used by the compiler
229229
#[cfg(notest)] pub mod rt;
230230
// Private APIs
231-
pub mod unstable;
232-
// NOTE: Remove after snapshot
233-
#[cfg(stage0)]
234-
pub mod private {
235-
pub use super::unstable::extfmt;
236-
}
231+
pub mod private;
232+
237233

238234
/* For internal use, not exported */
239235

branches/try/src/libcore/dvec.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -62,17 +62,17 @@ pub struct DVec<A> {
6262

6363
/// Creates a new, empty dvec
6464
pub pure fn DVec<A>() -> DVec<A> {
65-
DVec {mut data: ~[]}
65+
DVec {data: ~[]}
6666
}
6767

6868
/// Creates a new dvec with a single element
6969
pub pure fn from_elem<A>(e: A) -> DVec<A> {
70-
DVec {mut data: ~[e]}
70+
DVec {data: ~[e]}
7171
}
7272

7373
/// Creates a new dvec with the contents of a vector
7474
pub pure fn from_vec<A>(v: ~[A]) -> DVec<A> {
75-
DVec {mut data: v}
75+
DVec {data: v}
7676
}
7777

7878
/// Consumes the vector and returns its contents

branches/try/src/libcore/num/f32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use num::strconv;
1818
use num;
1919
use ops;
2020
use option::Option;
21-
use unstable::intrinsics::floorf32;
21+
use private::intrinsics::floorf32;
2222
use from_str;
2323
use to_str;
2424

branches/try/src/libcore/num/f64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use num::strconv;
1919
use num;
2020
use ops;
2121
use option::Option;
22-
use unstable::intrinsics::floorf64;
22+
use private::intrinsics::floorf64;
2323
use to_str;
2424
use from_str;
2525

branches/try/src/libcore/os.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -35,6 +35,7 @@ use libc::{mode_t, pid_t, FILE};
3535
use option;
3636
use option::{Some, None};
3737
use prelude::*;
38+
use private;
3839
use ptr;
3940
use str;
4041
use task;
@@ -144,8 +145,8 @@ This uses a per-runtime lock to serialize access.
144145
FIXME #4726: It would probably be appropriate to make this a real global
145146
*/
146147
fn with_env_lock<T>(f: &fn() -> T) -> T {
147-
use unstable::global::global_data_clone_create;
148-
use unstable::{Exclusive, exclusive};
148+
use private::global::global_data_clone_create;
149+
use private::{Exclusive, exclusive};
149150

150151
struct SharedValue(());
151152
type ValueMutex = Exclusive<SharedValue>;
@@ -321,8 +322,8 @@ pub struct Pipe { mut in: c_int, mut out: c_int }
321322
#[cfg(unix)]
322323
pub fn pipe() -> Pipe {
323324
unsafe {
324-
let mut fds = Pipe {mut in: 0 as c_int,
325-
mut out: 0 as c_int };
325+
let mut fds = Pipe {in: 0 as c_int,
326+
out: 0 as c_int };
326327
assert (libc::pipe(&mut fds.in) == (0 as c_int));
327328
return Pipe {in: fds.in, out: fds.out};
328329
}
@@ -338,8 +339,8 @@ pub fn pipe() -> Pipe {
338339
// fully understand. Here we explicitly make the pipe non-inheritable,
339340
// which means to pass it to a subprocess they need to be duplicated
340341
// first, as in rust_run_program.
341-
let mut fds = Pipe { mut in: 0 as c_int,
342-
mut out: 0 as c_int };
342+
let mut fds = Pipe {in: 0 as c_int,
343+
out: 0 as c_int };
343344
let res = libc::pipe(&mut fds.in, 1024 as c_uint,
344345
(libc::O_BINARY | libc::O_NOINHERIT) as c_int);
345346
assert (res == 0 as c_int);
@@ -565,13 +566,17 @@ pub fn path_exists(p: &Path) -> bool {
565566
*
566567
* If the given path is relative, return it prepended with the current working
567568
* directory. If the given path is already an absolute path, return it
568-
* as is. This is a shortcut for calling os::getcwd().unsafe_join(p)
569+
* as is.
569570
*/
570571
// NB: this is here rather than in path because it is a form of environment
571572
// querying; what it does depends on the process working directory, not just
572573
// the input paths.
573574
pub fn make_absolute(p: &Path) -> Path {
574-
getcwd().unsafe_join(p)
575+
if p.is_absolute {
576+
copy *p
577+
} else {
578+
getcwd().push_many(p.components)
579+
}
575580
}
576581

577582

branches/try/src/libcore/pipes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ use libc;
9191
use option;
9292
use option::{None, Option, Some, unwrap};
9393
use pipes;
94-
use unstable::intrinsics;
94+
use private::intrinsics;
9595
use ptr;
96-
use unstable;
96+
use private;
9797
use task;
9898
use vec;
9999

branches/try/src/libcore/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub use option;
6969
pub use os;
7070
pub use path;
7171
pub use comm;
72-
pub use unstable;
72+
pub use private;
7373
pub use ptr;
7474
pub use rand;
7575
pub use result;

0 commit comments

Comments
 (0)