Skip to content

Commit 1b19cd0

Browse files
committed
---
yaml --- r: 36707 b: refs/heads/try2 c: 55c9cf7 h: refs/heads/master i: 36705: f60e86f 36703: 2f6d3d0 v: v3
1 parent 6c32e35 commit 1b19cd0

File tree

113 files changed

+1087
-842
lines changed

Some content is hidden

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

113 files changed

+1087
-842
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: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 08b1c841daa401afb9516987ceb07906615c4a1d
8+
refs/heads/try2: 55c9cf72e34676df449d64f35d972f34634b240b
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/RELEASES.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Version 0.5 (December 2012)
22
---------------------------
33

4-
* ~700 changes, numerous bugfixes
4+
* ~800 changes, numerous bugfixes
55

66
* Syntax changes
77
* Removed `<-` move operator
@@ -13,6 +13,7 @@ Version 0.5 (December 2012)
1313
* `Eq` and `IterBytes` implementations can be automatically generated
1414
with `#[deriving_eq]` and `#[deriving_iter_bytes]` respectively
1515
* Removed the special crate language for `.rc` files
16+
* Function arguments may consist of any irrefutable pattern
1617

1718
* Semantic changes
1819
* `&` and `~` pointers may point to objects
@@ -24,13 +25,15 @@ Version 0.5 (December 2012)
2425
without writing `move` explicitly
2526
* `&T` may now be coerced to `*T`
2627
* Coercions happen in `let` statements as well as function calls
28+
* `use` statements now take crate-relative paths
2729

2830
* Improved support for language features
2931
* Trait inheritance is much more complete
30-
* Traits may declare default methods for the implementations to use
3132
* More support for explicit self arguments in methods - `self`, `&self`
3233
`@self`, and `~self` all generally work as expected
3334
* Static methods work in more situations
35+
* Experimental: Traits may declare default methods for the implementations
36+
to use
3437

3538
* Libraries
3639
* New condition handling system in `core::condition`

branches/try2/doc/rust.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2740,11 +2740,11 @@ The kinds are:
27402740
`Const`
27412741
: Types of this kind are deeply immutable;
27422742
they contain no mutable memory locations directly or indirectly via pointers.
2743-
`Send`
2743+
`Owned`
27442744
: Types of this kind can be safely sent between tasks.
27452745
This kind includes scalars, owning pointers, owned closures, and
2746-
structural types containing only other sendable types.
2747-
`Owned`
2746+
structural types containing only other owned types. All `Owned` types are `Static`.
2747+
`Static`
27482748
: Types of this kind do not contain any borrowed pointers;
27492749
this can be a useful guarantee for code that breaks borrowing assumptions using [`unsafe` operations](#unsafe-functions).
27502750
`Copy`
@@ -2833,10 +2833,10 @@ frame they are allocated within.
28332833
A task owns all memory it can *safely* reach through local variables,
28342834
as well as managed, owning and borrowed pointers.
28352835

2836-
When a task sends a value that has the `Send` trait to another task,
2836+
When a task sends a value that has the `Owned` trait to another task,
28372837
it loses ownership of the value sent and can no longer refer to it.
28382838
This is statically guaranteed by the combined use of "move semantics",
2839-
and the compiler-checked _meaning_ of the `Send` trait:
2839+
and the compiler-checked _meaning_ of the `Owned` trait:
28402840
it is only instantiated for (transitively) sendable kinds of data constructor and pointers,
28412841
never including managed or borrowed pointers.
28422842

@@ -2971,7 +2971,7 @@ These include:
29712971
- read-only and read-write shared variables with various safe mutual exclusion patterns
29722972
- simple locks and semaphores
29732973

2974-
When such facilities carry values, the values are restricted to the [`Send` type-kind](#type-kinds).
2974+
When such facilities carry values, the values are restricted to the [`Owned` type-kind](#type-kinds).
29752975
Restricting communication interfaces to this kind ensures that no borrowed or managed pointers move between tasks.
29762976
Thus access to an entire data structure can be mediated through its owning "root" value;
29772977
no further locking or copying is required to avoid data races within the substructure of such a value.

branches/try2/doc/tutorial.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,9 +1914,9 @@ types by the compiler, and may not be overridden:
19141914
`copy` operator. All types are copyable unless they have destructors or
19151915
contain types with destructors.
19161916

1917-
* `Send` - Sendable (owned) types. All types are sendable unless they
1918-
contain managed boxes, managed closures, or otherwise managed
1919-
types. Sendable types may or may not be copyable.
1917+
* `Owned` - Owned types. Types are owned unless they contain managed
1918+
boxes, managed closures, or borrowed pointers. Owned types may or
1919+
may not be copyable.
19201920

19211921
* `Const` - Constant (immutable) types. These are types that do not contain
19221922
mutable fields.
@@ -1949,7 +1949,7 @@ may call it.
19491949
## Declaring and implementing traits
19501950

19511951
A trait consists of a set of methods, without bodies, or may be empty,
1952-
as is the case with `Copy`, `Send`, and `Const`. For example, we could
1952+
as is the case with `Copy`, `Owned`, and `Const`. For example, we could
19531953
declare the trait `Printable` for things that can be printed to the
19541954
console, with a single method:
19551955

branches/try2/mk/clean.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ clean-misc:
4949
$(Q)rm -Rf $(DOCS)
5050
$(Q)rm -Rf $(GENERATED)
5151
$(Q)rm -f tmp/*.log tmp/*.rc tmp/*.rs
52-
$(Q)rm -Rf $(PKG_NAME)-*.tar.gz dist
52+
$(Q)rm -Rf rust-stage0-*.tar.bz2 $(PKG_NAME)-*.tar.gz dist
5353
$(Q)rm -Rf $(foreach ext, \
5454
html aux cp fn ky log pdf pg toc tp vr cps, \
5555
$(wildcard doc/*.$(ext) \

branches/try2/src/libcore/comm.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use libc::size_t;
5757
* transmitted. If a port value is copied, both copies refer to the same
5858
* port. Ports may be associated with multiple `chan`s.
5959
*/
60-
pub enum Port<T: Send> {
60+
pub enum Port<T: Owned> {
6161
Port_(@PortPtr<T>)
6262
}
6363

@@ -73,16 +73,16 @@ pub enum Port<T: Send> {
7373
* data will be silently dropped. Channels may be duplicated and
7474
* themselves transmitted over other channels.
7575
*/
76-
pub enum Chan<T: Send> {
76+
pub enum Chan<T: Owned> {
7777
Chan_(port_id)
7878
}
7979

8080
/// Constructs a port
81-
pub fn Port<T: Send>() -> Port<T> {
81+
pub fn Port<T: Owned>() -> Port<T> {
8282
Port_(@PortPtr(rustrt::new_port(sys::size_of::<T>() as size_t)))
8383
}
8484

85-
impl<T: Send> Port<T> {
85+
impl<T: Owned> Port<T> {
8686

8787
fn chan() -> Chan<T> { Chan(&self) }
8888
fn send(v: T) { self.chan().send(move v) }
@@ -91,7 +91,7 @@ impl<T: Send> Port<T> {
9191

9292
}
9393

94-
impl<T: Send> Chan<T> {
94+
impl<T: Owned> Chan<T> {
9595

9696
fn chan() -> Chan<T> { self }
9797
fn send(v: T) { send(self, move v) }
@@ -101,12 +101,12 @@ impl<T: Send> Chan<T> {
101101
}
102102

103103
/// Open a new receiving channel for the duration of a function
104-
pub fn listen<T: Send, U>(f: fn(Chan<T>) -> U) -> U {
104+
pub fn listen<T: Owned, U>(f: fn(Chan<T>) -> U) -> U {
105105
let po = Port();
106106
f(po.chan())
107107
}
108108

109-
struct PortPtr<T:Send> {
109+
struct PortPtr<T:Owned> {
110110
po: *rust_port,
111111
drop unsafe {
112112
do task::unkillable {
@@ -130,7 +130,7 @@ struct PortPtr<T:Send> {
130130
}
131131
}
132132

133-
fn PortPtr<T: Send>(po: *rust_port) -> PortPtr<T> {
133+
fn PortPtr<T: Owned>(po: *rust_port) -> PortPtr<T> {
134134
PortPtr {
135135
po: po
136136
}
@@ -144,7 +144,7 @@ fn PortPtr<T: Send>(po: *rust_port) -> PortPtr<T> {
144144
* Fails if the port is detached or dead. Fails if the port
145145
* is owned by a different task.
146146
*/
147-
fn as_raw_port<T: Send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
147+
fn as_raw_port<T: Owned, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
148148

149149
struct PortRef {
150150
p: *rust_port,
@@ -176,15 +176,15 @@ fn as_raw_port<T: Send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
176176
* Constructs a channel. The channel is bound to the port used to
177177
* construct it.
178178
*/
179-
pub fn Chan<T: Send>(p: &Port<T>) -> Chan<T> {
179+
pub fn Chan<T: Owned>(p: &Port<T>) -> Chan<T> {
180180
Chan_(rustrt::get_port_id((**p).po))
181181
}
182182

183183
/**
184184
* Sends data over a channel. The sent data is moved into the channel,
185185
* whereupon the caller loses access to it.
186186
*/
187-
pub fn send<T: Send>(ch: Chan<T>, data: T) {
187+
pub fn send<T: Owned>(ch: Chan<T>, data: T) {
188188
let Chan_(p) = ch;
189189
let data_ptr = ptr::addr_of(&data) as *();
190190
let res = rustrt::rust_port_id_send(p, data_ptr);
@@ -199,22 +199,22 @@ pub fn send<T: Send>(ch: Chan<T>, data: T) {
199199
* Receive from a port. If no data is available on the port then the
200200
* task will block until data becomes available.
201201
*/
202-
pub fn recv<T: Send>(p: Port<T>) -> T { recv_((**p).po) }
202+
pub fn recv<T: Owned>(p: Port<T>) -> T { recv_((**p).po) }
203203

204204
/// Returns true if there are messages available
205-
pub fn peek<T: Send>(p: Port<T>) -> bool { peek_((**p).po) }
205+
pub fn peek<T: Owned>(p: Port<T>) -> bool { peek_((**p).po) }
206206

207207
#[doc(hidden)]
208-
pub fn recv_chan<T: Send>(ch: comm::Chan<T>) -> T {
208+
pub fn recv_chan<T: Owned>(ch: comm::Chan<T>) -> T {
209209
as_raw_port(ch, |x|recv_(x))
210210
}
211211

212-
fn peek_chan<T: Send>(ch: comm::Chan<T>) -> bool {
212+
fn peek_chan<T: Owned>(ch: comm::Chan<T>) -> bool {
213213
as_raw_port(ch, |x|peek_(x))
214214
}
215215

216216
/// Receive on a raw port pointer
217-
fn recv_<T: Send>(p: *rust_port) -> T {
217+
fn recv_<T: Owned>(p: *rust_port) -> T {
218218
let yield = 0;
219219
let yieldp = ptr::addr_of(&yield);
220220
let mut res;
@@ -240,7 +240,7 @@ fn peek_(p: *rust_port) -> bool {
240240
}
241241

242242
/// Receive on one of two ports
243-
pub fn select2<A: Send, B: Send>(p_a: Port<A>, p_b: Port<B>)
243+
pub fn select2<A: Owned, B: Owned>(p_a: Port<A>, p_b: Port<B>)
244244
-> Either<A, B> {
245245
let ports = ~[(**p_a).po, (**p_b).po];
246246
let yield = 0, yieldp = ptr::addr_of(&yield);

branches/try2/src/libcore/core.rc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub mod util;
167167

168168
/* Reexported core operators */
169169

170-
pub use kinds::{Const, Copy, Send, Owned};
170+
pub use kinds::{Const, Copy, Owned, Durable};
171171
pub use ops::{Drop};
172172
pub use ops::{Add, Sub, Mul, Div, Modulo, Neg};
173173
pub use ops::{BitAnd, BitOr, BitXor};
@@ -240,6 +240,8 @@ mod core {
240240
pub const warn : u32 = 2_u32;
241241
pub const info : u32 = 3_u32;
242242
pub const debug : u32 = 4_u32;
243+
244+
pub use cmp;
243245
}
244246

245247

branches/try2/src/libcore/either.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use cmp::Eq;
1818
use result::Result;
1919

2020
/// The either type
21+
#[deriving_eq]
2122
pub enum Either<T, U> {
2223
Left(T),
2324
Right(U)
@@ -141,26 +142,6 @@ pub pure fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
141142
}
142143
}
143144

144-
impl<T:Eq,U:Eq> Either<T,U> : Eq {
145-
pure fn eq(&self, other: &Either<T,U>) -> bool {
146-
match (*self) {
147-
Left(ref a) => {
148-
match (*other) {
149-
Left(ref b) => (*a).eq(b),
150-
Right(_) => false
151-
}
152-
}
153-
Right(ref a) => {
154-
match (*other) {
155-
Left(_) => false,
156-
Right(ref b) => (*a).eq(b)
157-
}
158-
}
159-
}
160-
}
161-
pure fn ne(&self, other: &Either<T,U>) -> bool { !(*self).eq(other) }
162-
}
163-
164145
#[test]
165146
fn test_either_left() {
166147
let val = Left(10);

branches/try2/src/libcore/extfmt.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -445,24 +445,9 @@ pub mod rt {
445445
};
446446
}
447447

448+
#[deriving_eq]
448449
pub enum PadMode { PadSigned, PadUnsigned, PadNozero, PadFloat }
449450

450-
pub impl PadMode : Eq {
451-
pure fn eq(&self, other: &PadMode) -> bool {
452-
match ((*self), (*other)) {
453-
(PadSigned, PadSigned) => true,
454-
(PadUnsigned, PadUnsigned) => true,
455-
(PadNozero, PadNozero) => true,
456-
(PadFloat, PadFloat) => true,
457-
(PadSigned, _) => false,
458-
(PadUnsigned, _) => false,
459-
(PadNozero, _) => false,
460-
(PadFloat, _) => false
461-
}
462-
}
463-
pure fn ne(&self, other: &PadMode) -> bool { !(*self).eq(other) }
464-
}
465-
466451
pub fn pad(cv: Conv, s: ~str, mode: PadMode) -> ~str {
467452
let mut s = move s; // sadtimes
468453
let uwidth : uint = match cv.width {

branches/try2/src/libcore/float.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub use f64::{modf, pow, round, sinh, tanh, tgamma, trunc};
3636
pub use f64::signbit;
3737
pub use f64::{j0, j1, jn, y0, y1, yn};
3838
use cmp::{Eq, Ord};
39-
use num::from_int;
39+
use num::Num::from_int;
4040

4141
pub const NaN: float = 0.0/0.0;
4242

branches/try2/src/libcore/int-template.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use T = self::inst::T;
2020

2121
use cmp::{Eq, Ord};
2222
use from_str::FromStr;
23-
use num::from_int;
23+
use num::Num::from_int;
2424

2525
pub const bits : uint = inst::bits;
2626
pub const bytes : uint = (inst::bits / 8);

branches/try2/src/libcore/io.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -523,18 +523,9 @@ pub pure fn with_str_reader<T>(s: &str, f: fn(Reader) -> T) -> T {
523523
pub enum FileFlag { Append, Create, Truncate, NoFlag, }
524524
525525
// What type of writer are we?
526+
#[deriving_eq]
526527
pub enum WriterType { Screen, File }
527528
528-
pub impl WriterType : Eq {
529-
pure fn eq(&self, other: &WriterType) -> bool {
530-
match ((*self), (*other)) {
531-
(Screen, Screen) | (File, File) => true,
532-
(Screen, _) | (File, _) => false
533-
}
534-
}
535-
pure fn ne(&self, other: &WriterType) -> bool { !(*self).eq(other) }
536-
}
537-
538529
// FIXME (#2004): Seekable really should be orthogonal.
539530
// FIXME (#2004): eventually u64
540531
/// The raw underlying writer trait. All writers must implement this.

branches/try2/src/libcore/iter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ pub pure fn find<A: Copy,IA:BaseIter<A>>(self: &IA,
244244
#[inline(always)]
245245
pub pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(v: A)))
246246
-> B {
247-
build_sized(4, builder)
247+
Buildable::build_sized(4, builder)
248248
}
249249

250250
/**
@@ -265,7 +265,7 @@ pub pure fn build_sized_opt<A,B: Buildable<A>>(
265265
size: Option<uint>,
266266
builder: fn(push: pure fn(v: A))) -> B {
267267

268-
build_sized(size.get_default(4), builder)
268+
Buildable::build_sized(size.get_default(4), builder)
269269
}
270270

271271
// Functions that combine iteration and building
@@ -288,7 +288,7 @@ pub fn map<T,IT: BaseIter<T>,U,BU: Buildable<U>>(v: &IT, f: fn(&T) -> U)
288288
*/
289289
pub pure fn from_fn<T,BT: Buildable<T>>(n_elts: uint,
290290
op: InitOp<T>) -> BT {
291-
do build_sized(n_elts) |push| {
291+
do Buildable::build_sized(n_elts) |push| {
292292
let mut i: uint = 0u;
293293
while i < n_elts { push(op(i)); i += 1u; }
294294
}
@@ -302,7 +302,7 @@ pub pure fn from_fn<T,BT: Buildable<T>>(n_elts: uint,
302302
*/
303303
pub pure fn from_elem<T: Copy,BT: Buildable<T>>(n_elts: uint,
304304
t: T) -> BT {
305-
do build_sized(n_elts) |push| {
305+
do Buildable::build_sized(n_elts) |push| {
306306
let mut i: uint = 0;
307307
while i < n_elts { push(t); i += 1; }
308308
}

0 commit comments

Comments
 (0)