Skip to content

Commit 105c192

Browse files
committed
---
yaml --- r: 57341 b: refs/heads/incoming c: 786ae01 h: refs/heads/master i: 57339: 729271f v: v3
1 parent 297ecd4 commit 105c192

File tree

7 files changed

+94
-39
lines changed

7 files changed

+94
-39
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: bf67eb2362b7d0f37012f2d6dac604c3bbacd2c6
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: 2e907a3ac2fcaa799f570e07c35f54efae39829b
9+
refs/heads/incoming: 786ae0114b514f048d94dbbddf24fc56e5b9239c
1010
refs/heads/dist-snap: 00dbbd01c2aee72982b3e0f9511ae1d4428c3ba9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/doc/rust.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,11 +1653,12 @@ Path expressions are [lvalues](#lvalues-rvalues-and-temporaries).
16531653

16541654
### Tuple expressions
16551655

1656-
Tuples are written by enclosing two or more comma-separated
1656+
Tuples are written by enclosing one or more comma-separated
16571657
expressions in parentheses. They are used to create [tuple-typed](#tuple-types)
16581658
values.
16591659

16601660
~~~~~~~~ {.tuple}
1661+
(0,);
16611662
(0f, 4.5f);
16621663
("a", 4u, true);
16631664
~~~~~~~~
@@ -2578,7 +2579,7 @@ to the record type-constructor. The differences are as follows:
25782579

25792580
Tuple types and values are denoted by listing the types or values of their
25802581
elements, respectively, in a parenthesized, comma-separated
2581-
list. Single-element tuples are not legal; all tuples have two or more values.
2582+
list.
25822583

25832584
The members of a tuple are laid out in memory contiguously, like a record, in
25842585
order specified by the tuple type.

branches/incoming/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ fn area(sh: Shape) -> float {
747747

748748
Tuples in Rust behave exactly like structs, except that their fields
749749
do not have names. Thus, you cannot access their fields with dot notation.
750-
Tuples can have any arity except for 0 or 1 (though you may consider
750+
Tuples can have any arity except for 0 (though you may consider
751751
unit, `()`, as the empty tuple if you like).
752752

753753
~~~~

branches/incoming/src/libcore/clone.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ In Rust, some simple types are "implicitly copyable" and when you
1414
assign them or pass them as arguments, the receiver will get a copy,
1515
leaving the original value in place. These types do not require
1616
allocation to copy and do not have finalizers (i.e. they do not
17-
contain owned pointers or implement `Drop`), so the compiler considers
17+
contain owned boxes or implement `Drop`), so the compiler considers
1818
them cheap and safe to copy and automatically implements the `Copy`
1919
trait for them. For other types copies must be made explicitly,
2020
by convention implementing the `Clone` trait and calling the
@@ -23,32 +23,38 @@ by convention implementing the `Clone` trait and calling the
2323
*/
2424

2525
pub trait Clone {
26+
/// Return a deep copy of the owned object tree. Managed boxes are cloned with a shallow copy.
2627
fn clone(&self) -> Self;
2728
}
2829

2930
impl Clone for () {
31+
/// Return a copy of the value.
3032
#[inline(always)]
3133
fn clone(&self) -> () { () }
3234
}
3335

3436
impl<T:Clone> Clone for ~T {
37+
/// Return a deep copy of the owned box.
3538
#[inline(always)]
3639
fn clone(&self) -> ~T { ~(**self).clone() }
3740
}
3841

39-
impl<T:Clone> Clone for @T {
42+
impl<T> Clone for @T {
43+
/// Return a shallow copy of the managed box.
4044
#[inline(always)]
41-
fn clone(&self) -> @T { @(**self).clone() }
45+
fn clone(&self) -> @T { *self }
4246
}
4347

44-
impl<T:Clone> Clone for @mut T {
48+
impl<T> Clone for @mut T {
49+
/// Return a shallow copy of the managed box.
4550
#[inline(always)]
46-
fn clone(&self) -> @mut T { @mut (**self).clone() }
51+
fn clone(&self) -> @mut T { *self }
4752
}
4853

4954
macro_rules! clone_impl(
5055
($t:ty) => {
5156
impl Clone for $t {
57+
/// Return a copy of the value.
5258
#[inline(always)]
5359
fn clone(&self) -> $t { *self }
5460
}
@@ -76,21 +82,23 @@ clone_impl!(char)
7682

7783
#[test]
7884
fn test_owned_clone() {
79-
let a : ~int = ~5i;
80-
let b : ~int = a.clone();
85+
let a: ~int = ~5i;
86+
let b: ~int = a.clone();
8187
assert!(a == b);
8288
}
8389

8490
#[test]
8591
fn test_managed_clone() {
86-
let a : @int = @5i;
87-
let b : @int = a.clone();
92+
let a: @int = @5i;
93+
let b: @int = a.clone();
8894
assert!(a == b);
8995
}
9096

9197
#[test]
9298
fn test_managed_mut_clone() {
93-
let a : @int = @5i;
94-
let b : @int = a.clone();
99+
let a: @mut int = @mut 5i;
100+
let b: @mut int = a.clone();
101+
assert!(a == b);
102+
*b = 10;
95103
assert!(a == b);
96104
}

branches/incoming/src/libcore/task/mod.rs

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use result;
4242
use task::rt::{task_id, sched_id, rust_task};
4343
use util;
4444
use util::replace;
45-
use unstable::finally::Finally;
4645

4746
#[cfg(test)] use comm::SharedChan;
4847

@@ -566,27 +565,51 @@ pub fn get_scheduler() -> Scheduler {
566565
* ~~~
567566
*/
568567
pub unsafe fn unkillable<U>(f: &fn() -> U) -> U {
568+
struct AllowFailure {
569+
t: *rust_task,
570+
drop {
571+
unsafe {
572+
rt::rust_task_allow_kill(self.t);
573+
}
574+
}
575+
}
576+
577+
fn AllowFailure(t: *rust_task) -> AllowFailure{
578+
AllowFailure {
579+
t: t
580+
}
581+
}
582+
569583
unsafe {
570584
let t = rt::rust_get_task();
585+
let _allow_failure = AllowFailure(t);
571586
rt::rust_task_inhibit_kill(t);
572-
do (|| {
573-
f()
574-
}).finally {
575-
rt::rust_task_allow_kill(t);
576-
}
587+
f()
577588
}
578589
}
579590
580591
/// The inverse of unkillable. Only ever to be used nested in unkillable().
581592
pub unsafe fn rekillable<U>(f: &fn() -> U) -> U {
593+
struct DisallowFailure {
594+
t: *rust_task,
595+
drop {
596+
unsafe {
597+
rt::rust_task_inhibit_kill(self.t);
598+
}
599+
}
600+
}
601+
602+
fn DisallowFailure(t: *rust_task) -> DisallowFailure {
603+
DisallowFailure {
604+
t: t
605+
}
606+
}
607+
582608
unsafe {
583609
let t = rt::rust_get_task();
610+
let _allow_failure = DisallowFailure(t);
584611
rt::rust_task_allow_kill(t);
585-
do (|| {
586-
f()
587-
}).finally {
588-
rt::rust_task_inhibit_kill(t);
589-
}
612+
f()
590613
}
591614
}
592615
@@ -595,16 +618,28 @@ pub unsafe fn rekillable<U>(f: &fn() -> U) -> U {
595618
* For use with exclusive ARCs, which use pthread mutexes directly.
596619
*/
597620
pub unsafe fn atomically<U>(f: &fn() -> U) -> U {
621+
struct DeferInterrupts {
622+
t: *rust_task,
623+
drop {
624+
unsafe {
625+
rt::rust_task_allow_yield(self.t);
626+
rt::rust_task_allow_kill(self.t);
627+
}
628+
}
629+
}
630+
631+
fn DeferInterrupts(t: *rust_task) -> DeferInterrupts {
632+
DeferInterrupts {
633+
t: t
634+
}
635+
}
636+
598637
unsafe {
599638
let t = rt::rust_get_task();
639+
let _interrupts = DeferInterrupts(t);
600640
rt::rust_task_inhibit_kill(t);
601641
rt::rust_task_inhibit_yield(t);
602-
do (|| {
603-
f()
604-
}).finally {
605-
rt::rust_task_allow_yield(t);
606-
rt::rust_task_allow_kill(t);
607-
}
642+
f()
608643
}
609644
}
610645

branches/incoming/src/libcore/unstable.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use comm::{GenericChan, GenericPort};
1616
use prelude::*;
1717
use task;
1818
use task::atomically;
19-
use self::finally::Finally;
2019

2120
#[path = "unstable/at_exit.rs"]
2221
pub mod at_exit;
@@ -230,13 +229,25 @@ fn LittleLock() -> LittleLock {
230229
pub impl LittleLock {
231230
#[inline(always)]
232231
unsafe fn lock<T>(&self, f: &fn() -> T) -> T {
232+
struct Unlock {
233+
l: rust_little_lock,
234+
drop {
235+
unsafe {
236+
rustrt::rust_unlock_little_lock(self.l);
237+
}
238+
}
239+
}
240+
241+
fn Unlock(l: rust_little_lock) -> Unlock {
242+
Unlock {
243+
l: l
244+
}
245+
}
246+
233247
do atomically {
234248
rustrt::rust_lock_little_lock(self.l);
235-
do (|| {
236-
f()
237-
}).finally {
238-
rustrt::rust_unlock_little_lock(self.l);
239-
}
249+
let _r = Unlock(self.l);
250+
f()
240251
}
241252
}
242253
}

branches/incoming/src/test/run-pass/borrowck-borrow-from-expr-block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn borrow(x: &int, f: &fn(x: &int)) {
1313
}
1414

1515
fn test1(x: @~int) {
16-
do borrow(&**x.clone()) |p| {
16+
do borrow(&*(*x).clone()) |p| {
1717
let x_a = ptr::addr_of(&(**x));
1818
assert!((x_a as uint) != ptr::to_uint(p));
1919
assert!(unsafe{*x_a} == *p);

0 commit comments

Comments
 (0)