Skip to content

Commit 32b175a

Browse files
committed
---
yaml --- r: 96222 b: refs/heads/dist-snap c: 93a0dec h: refs/heads/master v: v3
1 parent c8ecb41 commit 32b175a

File tree

168 files changed

+1454
-1777
lines changed

Some content is hidden

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

168 files changed

+1454
-1777
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: d3cb24b1fe3fd0e31cccf8ca3c53470f747bae0c
9+
refs/heads/dist-snap: 93a0dec2029f5c0658478187984eddf3afcc84b3
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/configure

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -520,20 +520,14 @@ then
520520
fi
521521
fi
522522

523-
BIN_SUF=
524-
if [ $CFG_OSTYPE = "pc-mingw32" ]
525-
then
526-
BIN_SUF=.exe
527-
fi
528-
529523
if [ ! -z "$CFG_ENABLE_LOCAL_RUST" ]
530524
then
531-
if [ ! -f ${CFG_LOCAL_RUST_ROOT}/bin/rustc${BIN_SUF} ]
525+
if [ ! -f ${CFG_LOCAL_RUST_ROOT}/bin/rustc ]
532526
then
533527
err "no local rust to use"
534528
else
535-
LRV=`${CFG_LOCAL_RUST_ROOT}/bin/rustc${BIN_SUF} --version`
536-
step_msg "using rustc at: ${CFG_LOCAL_RUST_ROOT} with version: $LRV"
529+
LRV=`${CFG_LOCAL_RUST_ROOT}/bin/rustc --version`
530+
step_msg "using rustc at: ${CFG_LOCAL_RUST_ROOT} with version: " $LRV
537531
fi
538532
fi
539533

branches/dist-snap/doc/rust.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,8 +1131,9 @@ block.
11311131
let fptr: extern "C" fn() -> ~[int] = new_vec;
11321132
~~~~
11331133

1134-
Extern functions may be called directly from Rust code as Rust uses large,
1135-
contiguous stack segments like C.
1134+
Extern functions may be called from Rust code, but
1135+
caution must be taken with respect to the size of the stack
1136+
segment, just as when calling an extern function normally.
11361137

11371138
### Type definitions
11381139

@@ -3161,7 +3162,7 @@ Borrowed pointers (`&`)
31613162
Borrowed pointers arise by (automatic) conversion from owning pointers, managed pointers,
31623163
or by applying the borrowing operator `&` to some other value,
31633164
including [lvalues, rvalues or temporaries](#lvalues-rvalues-and-temporaries).
3164-
Borrowed pointers are written `&content`, or in some cases `&'f content` for some lifetime-variable `f`,
3165+
Borrowed pointers are written `&content`, or in some cases `&f/content` for some lifetime-variable `f`,
31653166
for example `&int` means a borrowed pointer to an integer.
31663167
Copying a borrowed pointer is a "shallow" operation:
31673168
it involves only copying the pointer itself.
@@ -3596,9 +3597,9 @@ and releases them back to its environment when they are no longer needed.
35963597
The default implementation of the service-provider interface
35973598
consists of the C runtime functions `malloc` and `free`.
35983599

3599-
The runtime memory-management system, in turn, supplies Rust tasks with
3600-
facilities for allocating releasing stacks, as well as allocating and freeing
3601-
heap data.
3600+
The runtime memory-management system, in turn, supplies Rust tasks
3601+
with facilities for allocating, extending and releasing stacks,
3602+
as well as allocating and freeing heap data.
36023603

36033604
### Built in types
36043605

@@ -3761,6 +3762,7 @@ have come and gone during the course of Rust's development:
37613762

37623763
Additional specific influences can be seen from the following languages:
37633764

3765+
* The stack-growth implementation of Go.
37643766
* The structural algebraic types and compilation manager of SML.
37653767
* The attribute and assembly systems of C#.
37663768
* The references and deterministic destructor system of C++.

branches/dist-snap/doc/tutorial.md

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,9 @@ calling the destructor, and the owner determines whether the object is mutable.
890890

891891
Ownership is recursive, so mutability is inherited recursively and a destructor
892892
destroys the contained tree of owned objects. Variables are top-level owners
893-
and destroy the contained object when they go out of scope.
893+
and destroy the contained object when they go out of scope. A box managed by
894+
the garbage collector starts a new ownership tree, and the destructor is called
895+
when it is collected.
894896

895897
~~~~
896898
// the struct owns the objects contained in the `x` and `y` fields
@@ -1007,6 +1009,51 @@ let mut s = r; // box becomes mutable
10071009
let t = s; // box becomes immutable
10081010
~~~~
10091011

1012+
# Managed boxes
1013+
1014+
A managed box (`@`) is a heap allocation with the lifetime managed by a
1015+
task-local garbage collector. It will be destroyed at some point after there
1016+
are no references left to the box, no later than the end of the task. Managed
1017+
boxes lack an owner, so they start a new ownership tree and don't inherit
1018+
mutability. They do own the contained object, and mutability is defined by the
1019+
type of the managed box (`@` or `@mut`). An object containing a managed box is
1020+
not `Owned`, and can't be sent between tasks.
1021+
1022+
~~~~
1023+
let a = @5; // immutable
1024+
1025+
let mut b = @5; // mutable variable, immutable box
1026+
b = @10;
1027+
1028+
let c = @mut 5; // immutable variable, mutable box
1029+
*c = 10;
1030+
1031+
let mut d = @mut 5; // mutable variable, mutable box
1032+
*d += 5;
1033+
d = @mut 15;
1034+
~~~~
1035+
1036+
A mutable variable and an immutable variable can refer to the same box, given
1037+
that their types are compatible. Mutability of a box is a property of its type,
1038+
however, so for example a mutable handle to an immutable box cannot be
1039+
assigned a reference to a mutable box.
1040+
1041+
~~~~
1042+
let a = @1; // immutable box
1043+
let b = @mut 2; // mutable box
1044+
1045+
let mut c : @int; // declare a variable with type managed immutable int
1046+
let mut d : @mut int; // and one of type managed mutable int
1047+
1048+
c = a; // box type is the same, okay
1049+
d = b; // box type is the same, okay
1050+
~~~~
1051+
1052+
~~~~ {.xfail-test}
1053+
// but b cannot be assigned to c, or a to d
1054+
c = b; // error
1055+
~~~~
1056+
10101057
# Borrowed pointers
10111058

10121059
Rust's borrowed pointers are a general purpose reference type. In contrast with
@@ -1300,53 +1347,6 @@ defined in [`std::vec`] and [`std::str`].
13001347
[`std::vec`]: std/vec/index.html
13011348
[`std::str`]: std/str/index.html
13021349
1303-
# Ownership escape hatches
1304-
1305-
Ownership can cleanly describe tree-like data structures, and borrowed pointers provide non-owning
1306-
references. However, more flexibility is often desired and Rust provides ways to escape from strict
1307-
single parent ownership.
1308-
1309-
The standard library provides the `std::rc::Rc` pointer type to express *shared ownership* over a
1310-
reference counted box. As soon as all of the `Rc` pointers go out of scope, the box and the
1311-
contained value are destroyed.
1312-
1313-
~~~
1314-
use std::rc::Rc;
1315-
1316-
// A fixed-size array allocated in a reference-counted box
1317-
let x = Rc::new([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
1318-
let y = x.clone(); // a new owner
1319-
let z = x; // this moves `x` into `z`, rather than creating a new owner
1320-
1321-
assert_eq!(*z.borrow(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
1322-
1323-
// the variable is mutable, but not the contents of the box
1324-
let mut a = Rc::new([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]);
1325-
a = z;
1326-
~~~
1327-
1328-
A garbage collected pointer is provided via `std::gc::Gc`, with a task-local garbage collector
1329-
having ownership of the box. It allows the creation of cycles, and the individual `Gc` pointers do
1330-
not have a destructor.
1331-
1332-
~~~
1333-
use std::gc::Gc;
1334-
1335-
// A fixed-size array allocated in a garbage-collected box
1336-
let x = Gc::new([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
1337-
let y = x; // does not perform a move, unlike with `Rc`
1338-
let z = x;
1339-
1340-
assert_eq!(*z.borrow(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
1341-
~~~
1342-
1343-
With shared ownership, mutability cannot be inherited so the boxes are always immutable. However,
1344-
it's possible to use *dynamic* mutability via types like `std::cell::Cell` where freezing is handled
1345-
via dynamic checks and can fail at runtime.
1346-
1347-
The `Rc` and `Gc` types are not sendable, so they cannot be used to share memory between tasks. Safe
1348-
immutable and mutable shared memory is provided by the `extra::arc` module.
1349-
13501350
# Closures
13511351
13521352
Named functions, like those we've seen so far, may not refer to local

branches/dist-snap/src/etc/local_stage0.sh

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
TARG_DIR=$1
44
PREFIX=$2
55

6-
LIB_DIR=lib
7-
LIB_PREFIX=lib
6+
BINDIR=bin
7+
LIBDIR=lib
88

99
OS=`uname -s`
1010
case $OS in
@@ -21,8 +21,7 @@ case $OS in
2121
(*)
2222
BIN_SUF=.exe
2323
LIB_SUF=.dll
24-
LIB_DIR=bin
25-
LIB_PREFIX=
24+
LIBDIR=bin
2625
break
2726
;;
2827
esac
@@ -32,7 +31,7 @@ if [ -z $PREFIX ]; then
3231
exit 1
3332
fi
3433

35-
if [ ! -e ${PREFIX}/bin/rustc${BIN_SUF} ]; then
34+
if [ ! -e ${PREFIX}/bin/rustc ]; then
3635
echo "No local rust installed at ${PREFIX}"
3736
exit 1
3837
fi
@@ -42,9 +41,9 @@ if [ -z $TARG_DIR ]; then
4241
exit 1
4342
fi
4443

45-
cp ${PREFIX}/bin/rustc${BIN_SUF} ${TARG_DIR}/stage0/bin/
46-
cp ${PREFIX}/${LIB_DIR}/rustc/${TARG_DIR}/${LIB_DIR}/* ${TARG_DIR}/stage0/${LIB_DIR}/
47-
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}extra*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
48-
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}rust*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
49-
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}std*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
50-
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}syntax*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
44+
cp ${PREFIX}/bin/rustc ${TARG_DIR}/stage0/bin/
45+
cp ${PREFIX}/lib/rustc/${TARG_DIR}/${LIBDIR}/* ${TARG_DIR}/stage0/${LIBDIR}/
46+
cp ${PREFIX}/lib/libextra*${LIB_SUF} ${TARG_DIR}/stage0/${LIBDIR}/
47+
cp ${PREFIX}/lib/librust*${LIB_SUF} ${TARG_DIR}/stage0/${LIBDIR}/
48+
cp ${PREFIX}/lib/libstd*${LIB_SUF} ${TARG_DIR}/stage0/${LIBDIR}/
49+
cp ${PREFIX}/lib/libsyntax*${LIB_SUF} ${TARG_DIR}/stage0/${LIBDIR}/

branches/dist-snap/src/libextra/arc.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl<T:Send> MutexArc<T> {
220220
* blocked on the mutex) will also fail immediately.
221221
*/
222222
#[inline]
223-
pub unsafe fn unsafe_access<U>(&self, blk: |x: &mut T| -> U) -> U {
223+
pub unsafe fn unsafe_access<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
224224
let state = self.x.get();
225225
// Borrowck would complain about this if the function were
226226
// not already unsafe. See borrow_rwlock, far below.
@@ -234,7 +234,8 @@ impl<T:Send> MutexArc<T> {
234234
/// As unsafe_access(), but with a condvar, as sync::mutex.lock_cond().
235235
#[inline]
236236
pub unsafe fn unsafe_access_cond<U>(&self,
237-
blk: |x: &mut T, c: &Condvar| -> U)
237+
blk: &fn(x: &mut T,
238+
c: &Condvar) -> U)
238239
-> U {
239240
let state = self.x.get();
240241
do (&(*state).lock).lock_cond |cond| {
@@ -283,14 +284,15 @@ impl<T:Freeze + Send> MutexArc<T> {
283284
* unsafe_access_cond.
284285
*/
285286
#[inline]
286-
pub fn access<U>(&self, blk: |x: &mut T| -> U) -> U {
287+
pub fn access<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
287288
unsafe { self.unsafe_access(blk) }
288289
}
289290

290291
/// As unsafe_access_cond but safe and Freeze.
291292
#[inline]
292293
pub fn access_cond<U>(&self,
293-
blk: |x: &mut T, c: &Condvar| -> U)
294+
blk: &fn(x: &mut T,
295+
c: &Condvar) -> U)
294296
-> U {
295297
unsafe { self.unsafe_access_cond(blk) }
296298
}
@@ -387,7 +389,7 @@ impl<T:Freeze + Send> RWArc<T> {
387389
* poison the Arc, so subsequent readers and writers will both also fail.
388390
*/
389391
#[inline]
390-
pub fn write<U>(&self, blk: |x: &mut T| -> U) -> U {
392+
pub fn write<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
391393
unsafe {
392394
let state = self.x.get();
393395
do (*borrow_rwlock(state)).write {
@@ -401,7 +403,7 @@ impl<T:Freeze + Send> RWArc<T> {
401403
/// As write(), but with a condvar, as sync::rwlock.write_cond().
402404
#[inline]
403405
pub fn write_cond<U>(&self,
404-
blk: |x: &mut T, c: &Condvar| -> U)
406+
blk: &fn(x: &mut T, c: &Condvar) -> U)
405407
-> U {
406408
unsafe {
407409
let state = self.x.get();
@@ -425,7 +427,7 @@ impl<T:Freeze + Send> RWArc<T> {
425427
* Failing will unlock the Arc while unwinding. However, unlike all other
426428
* access modes, this will not poison the Arc.
427429
*/
428-
pub fn read<U>(&self, blk: |x: &T| -> U) -> U {
430+
pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
429431
unsafe {
430432
let state = self.x.get();
431433
do (*state).lock.read {
@@ -455,7 +457,7 @@ impl<T:Freeze + Send> RWArc<T> {
455457
* }
456458
* ```
457459
*/
458-
pub fn write_downgrade<U>(&self, blk: |v: RWWriteMode<T>| -> U) -> U {
460+
pub fn write_downgrade<U>(&self, blk: &fn(v: RWWriteMode<T>) -> U) -> U {
459461
unsafe {
460462
let state = self.x.get();
461463
do (*borrow_rwlock(state)).write_downgrade |write_mode| {
@@ -537,7 +539,7 @@ pub struct RWReadMode<'self, T> {
537539

538540
impl<'self, T:Freeze + Send> RWWriteMode<'self, T> {
539541
/// Access the pre-downgrade RWArc in write mode.
540-
pub fn write<U>(&mut self, blk: |x: &mut T| -> U) -> U {
542+
pub fn write<U>(&mut self, blk: &fn(x: &mut T) -> U) -> U {
541543
match *self {
542544
RWWriteMode {
543545
data: &ref mut data,
@@ -553,7 +555,7 @@ impl<'self, T:Freeze + Send> RWWriteMode<'self, T> {
553555

554556
/// Access the pre-downgrade RWArc in write mode with a condvar.
555557
pub fn write_cond<U>(&mut self,
556-
blk: |x: &mut T, c: &Condvar| -> U)
558+
blk: &fn(x: &mut T, c: &Condvar) -> U)
557559
-> U {
558560
match *self {
559561
RWWriteMode {
@@ -578,7 +580,7 @@ impl<'self, T:Freeze + Send> RWWriteMode<'self, T> {
578580

579581
impl<'self, T:Freeze + Send> RWReadMode<'self, T> {
580582
/// Access the post-downgrade rwlock in read mode.
581-
pub fn read<U>(&self, blk: |x: &T| -> U) -> U {
583+
pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
582584
match *self {
583585
RWReadMode {
584586
data: data,

branches/dist-snap/src/libextra/arena.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl Arena {
184184
}
185185

186186
#[inline]
187-
fn alloc_pod<'a, T>(&'a mut self, op: || -> T) -> &'a T {
187+
fn alloc_pod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
188188
unsafe {
189189
let tydesc = get_tydesc::<T>();
190190
let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align);
@@ -241,7 +241,7 @@ impl Arena {
241241
}
242242

243243
#[inline]
244-
fn alloc_nonpod<'a, T>(&'a mut self, op: || -> T) -> &'a T {
244+
fn alloc_nonpod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
245245
unsafe {
246246
let tydesc = get_tydesc::<T>();
247247
let (ty_ptr, ptr) =
@@ -263,7 +263,7 @@ impl Arena {
263263

264264
// The external interface
265265
#[inline]
266-
pub fn alloc<'a, T>(&'a self, op: || -> T) -> &'a T {
266+
pub fn alloc<'a, T>(&'a self, op: &fn() -> T) -> &'a T {
267267
unsafe {
268268
// XXX: Borrow check
269269
let this = transmute_mut(self);

0 commit comments

Comments
 (0)