Skip to content

Commit f1060a5

Browse files
committed
---
yaml --- r: 139043 b: refs/heads/try2 c: dc5ad50 h: refs/heads/master i: 139041: f74b79c 139039: 9d52971 v: v3
1 parent 9a0276a commit f1060a5

Some content is hidden

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

49 files changed

+146
-97
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: 83f2d4ab3dbd3b52ea60212a6698c73201b67a34
8+
refs/heads/try2: dc5ad5070d06015d6a45f656882ae245197d0ff8
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/clone.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ impl Clone for () {
2020
fn clone(&self) -> () { () }
2121
}
2222

23+
impl<T:Clone> Clone for ~T {
24+
#[inline(always)]
25+
fn clone(&self) -> ~T { ~(**self).clone() }
26+
}
27+
2328
macro_rules! clone_impl(
2429
($t:ty) => {
2530
impl Clone for $t {

branches/try2/src/libcore/str.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use at_vec;
2121
use cast;
2222
use char;
23+
use clone::Clone;
2324
use cmp::{Equiv, TotalOrd, Ordering, Less, Equal, Greater};
2425
use libc;
2526
use option::{None, Option, Some};
@@ -2436,6 +2437,13 @@ impl OwnedStr for ~str {
24362437
}
24372438
}
24382439
2440+
impl Clone for ~str {
2441+
#[inline(always)]
2442+
fn clone(&self) -> ~str {
2443+
self.to_str() // hilarious
2444+
}
2445+
}
2446+
24392447
#[cfg(test)]
24402448
mod tests {
24412449
use char;

branches/try2/src/libcore/unstable/global.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ unsafe fn global_data_clone_create_<T:Owned + Clone>(
6868
match value {
6969
None => {
7070
let value = create();
71-
clone_value = Some(value.clone());
71+
clone_value = Some((*value).clone());
7272
Some(value)
7373
}
7474
Some(value) => {
75-
clone_value = Some(value.clone());
75+
clone_value = Some((*value).clone());
7676
Some(value)
7777
}
7878
}
@@ -193,7 +193,7 @@ fn get_global_state() -> Exclusive<GlobalState> {
193193
// Successfully installed the global pointer
194194

195195
// Take a handle to return
196-
let clone = state.clone();
196+
let clone = (*state).clone();
197197

198198
// Install a runtime exit function to destroy the global object
199199
do at_exit {

branches/try2/src/libcore/vec.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use container::{Container, Mutable};
1616
use cast;
1717
use cmp::{Eq, Equiv, Ord, TotalOrd, Ordering, Less, Equal, Greater};
18+
use clone::Clone;
1819
use iter::BaseIter;
1920
use iter;
2021
use kinds::Copy;
@@ -2501,6 +2502,18 @@ impl<A:Copy> iter::CopyableNonstrictIter<A> for @[A] {
25012502
}
25022503
}
25032504

2505+
impl<A:Clone> Clone for ~[A] {
2506+
#[inline]
2507+
fn clone(&self) -> ~[A] {
2508+
let mut dolly = ~[];
2509+
vec::reserve(&mut dolly, self.len());
2510+
for self.each |item| {
2511+
dolly.push(item.clone());
2512+
}
2513+
return dolly;
2514+
}
2515+
}
2516+
25042517
// ___________________________________________________________________________
25052518

25062519
#[cfg(test)]

branches/try2/src/libstd/arc.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ mod tests {
572572
#[test] #[should_fail] #[ignore(cfg(windows))]
573573
pub fn test_rw_arc_poison_wr() {
574574
let arc = ~RWARC(1);
575-
let arc2 = ~arc.clone();
575+
let arc2 = (*arc).clone();
576576
do task::try || {
577577
do arc2.write |one| {
578578
fail_unless!(*one == 2);
@@ -585,7 +585,7 @@ mod tests {
585585
#[test] #[should_fail] #[ignore(cfg(windows))]
586586
pub fn test_rw_arc_poison_ww() {
587587
let arc = ~RWARC(1);
588-
let arc2 = ~arc.clone();
588+
let arc2 = (*arc).clone();
589589
do task::try || {
590590
do arc2.write |one| {
591591
fail_unless!(*one == 2);
@@ -598,7 +598,7 @@ mod tests {
598598
#[test] #[should_fail] #[ignore(cfg(windows))]
599599
pub fn test_rw_arc_poison_dw() {
600600
let arc = ~RWARC(1);
601-
let arc2 = ~arc.clone();
601+
let arc2 = (*arc).clone();
602602
do task::try || {
603603
do arc2.write_downgrade |write_mode| {
604604
do (&write_mode).write |one| {
@@ -613,7 +613,7 @@ mod tests {
613613
#[test] #[ignore(cfg(windows))]
614614
pub fn test_rw_arc_no_poison_rr() {
615615
let arc = ~RWARC(1);
616-
let arc2 = ~arc.clone();
616+
let arc2 = (*arc).clone();
617617
do task::try || {
618618
do arc2.read |one| {
619619
fail_unless!(*one == 2);
@@ -626,7 +626,7 @@ mod tests {
626626
#[test] #[ignore(cfg(windows))]
627627
pub fn test_rw_arc_no_poison_rw() {
628628
let arc = ~RWARC(1);
629-
let arc2 = ~arc.clone();
629+
let arc2 = (*arc).clone();
630630
do task::try || {
631631
do arc2.read |one| {
632632
fail_unless!(*one == 2);
@@ -639,7 +639,7 @@ mod tests {
639639
#[test] #[ignore(cfg(windows))]
640640
pub fn test_rw_arc_no_poison_dr() {
641641
let arc = ~RWARC(1);
642-
let arc2 = ~arc.clone();
642+
let arc2 = (*arc).clone();
643643
do task::try || {
644644
do arc2.write_downgrade |write_mode| {
645645
let read_mode = arc2.downgrade(write_mode);
@@ -655,7 +655,7 @@ mod tests {
655655
#[test]
656656
pub fn test_rw_arc() {
657657
let arc = ~RWARC(0);
658-
let arc2 = ~arc.clone();
658+
let arc2 = (*arc).clone();
659659
let (p,c) = comm::stream();
660660

661661
do task::spawn || {
@@ -673,7 +673,7 @@ mod tests {
673673
// Readers try to catch the writer in the act
674674
let mut children = ~[];
675675
for 5.times {
676-
let arc3 = ~arc.clone();
676+
let arc3 = (*arc).clone();
677677
do task::task().future_result(|+r| children.push(r)).spawn
678678
|| {
679679
do arc3.read |num| {
@@ -704,7 +704,7 @@ mod tests {
704704
for 10.times {
705705
let ((rp1,rc1),(rp2,rc2)) = (comm::stream(),comm::stream());
706706
reader_convos.push((rc1, rp2));
707-
let arcn = ~arc.clone();
707+
let arcn = (*arc).clone();
708708
do task::spawn || {
709709
rp1.recv(); // wait for downgrader to give go-ahead
710710
do arcn.read |state| {
@@ -715,7 +715,7 @@ mod tests {
715715
}
716716

717717
// Writer task
718-
let arc2 = ~arc.clone();
718+
let arc2 = (*arc).clone();
719719
let ((wp1,wc1),(wp2,wc2)) = (comm::stream(),comm::stream());
720720
do task::spawn || {
721721
wp1.recv();

branches/try2/src/libstd/deque.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,40 +22,61 @@ pub struct Deque<T> {
2222
}
2323

2424
impl<T> Container for Deque<T> {
25+
/// Return the number of elements in the deque
2526
pure fn len(&self) -> uint { self.nelts }
27+
28+
/// Return true if the deque contains no elements
2629
pure fn is_empty(&self) -> bool { self.len() == 0 }
2730
}
2831

2932
impl<T> Mutable for Deque<T> {
33+
/// Clear the deque, removing all values.
3034
fn clear(&mut self) {
31-
for vec::each_mut(self.elts) |x| { *x = None }
35+
for self.elts.each_mut |x| { *x = None }
3236
self.nelts = 0;
3337
self.lo = 0;
3438
self.hi = 0;
3539
}
3640
}
3741

3842
pub impl<T> Deque<T> {
43+
/// Create an empty Deque
3944
static pure fn new() -> Deque<T> {
4045
Deque{nelts: 0, lo: 0, hi: 0,
4146
elts: vec::from_fn(initial_capacity, |_| None)}
4247
}
4348

49+
/// Return a reference to the first element in the deque
50+
///
51+
/// Fails if the deque is empty
4452
fn peek_front(&self) -> &self/T { get(self.elts, self.lo) }
53+
54+
/// Return a reference to the last element in the deque
55+
///
56+
/// Fails if the deque is empty
4557
fn peek_back(&self) -> &self/T { get(self.elts, self.hi - 1u) }
4658

59+
/// Retrieve an element in the deque by index
60+
///
61+
/// Fails if there is no element with the given index
4762
fn get(&self, i: int) -> &self/T {
4863
let idx = (self.lo + (i as uint)) % self.elts.len();
4964
get(self.elts, idx)
5065
}
5166

67+
/// Remove and return the first element in the deque
68+
///
69+
/// Fails if the deque is empty
5270
fn pop_front(&mut self) -> T {
5371
let mut result = self.elts[self.lo].swap_unwrap();
5472
self.lo = (self.lo + 1u) % self.elts.len();
5573
self.nelts -= 1u;
5674
result
5775
}
5876

77+
/// Remove and return the last element in the deque
78+
///
79+
/// Fails if the deque is empty
5980
fn pop_back(&mut self) -> T {
6081
if self.hi == 0u {
6182
self.hi = self.elts.len() - 1u;
@@ -66,6 +87,7 @@ pub impl<T> Deque<T> {
6687
result
6788
}
6889

90+
/// Prepend an element to the deque
6991
fn add_front(&mut self, t: T) {
7092
let oldlo = self.lo;
7193
if self.lo == 0u {
@@ -80,6 +102,7 @@ pub impl<T> Deque<T> {
80102
self.nelts += 1u;
81103
}
82104

105+
/// Append an element to the deque
83106
fn add_back(&mut self, t: T) {
84107
if self.lo == self.hi && self.nelts != 0u {
85108
self.elts = grow(self.nelts, self.lo, self.elts);

branches/try2/src/libstd/sync.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ mod tests {
827827
// "load tmp = move ptr; inc tmp; store ptr <- tmp" dance.
828828
let (p,c) = comm::stream();
829829
let m = ~Mutex();
830-
let m2 = ~m.clone();
830+
let m2 = m.clone();
831831
let mut sharedstate = ~0;
832832
let ptr = ptr::addr_of(&(*sharedstate));
833833
do task::spawn || {
@@ -1105,13 +1105,13 @@ mod tests {
11051105
// Test mutual exclusion between readers and writers. Just like the
11061106
// mutex mutual exclusion test, a ways above.
11071107
let (p,c) = comm::stream();
1108-
let x2 = ~x.clone();
1108+
let x2 = (*x).clone();
11091109
let mut sharedstate = ~0;
11101110
let ptr = ptr::addr_of(&(*sharedstate));
11111111
do task::spawn || {
11121112
let sharedstate: &mut int =
11131113
unsafe { cast::reinterpret_cast(&ptr) };
1114-
access_shared(sharedstate, x2, mode1, 10);
1114+
access_shared(sharedstate, &x2, mode1, 10);
11151115
c.send(());
11161116
}
11171117
access_shared(sharedstate, x, mode2, 10);
@@ -1150,14 +1150,14 @@ mod tests {
11501150
mode2: RWlockMode,
11511151
make_mode2_go_first: bool) {
11521152
// Much like sem_multi_resource.
1153-
let x2 = ~x.clone();
1153+
let x2 = (*x).clone();
11541154
let (p1,c1) = comm::stream();
11551155
let (p2,c2) = comm::stream();
11561156
do task::spawn || {
11571157
if !make_mode2_go_first {
11581158
let _ = p2.recv(); // parent sends to us once it locks, or ...
11591159
}
1160-
do lock_rwlock_in_mode(x2, mode2) {
1160+
do lock_rwlock_in_mode(&x2, mode2) {
11611161
if make_mode2_go_first {
11621162
c1.send(()); // ... we send to it once we lock
11631163
}
@@ -1207,7 +1207,7 @@ mod tests {
12071207
12081208
// Child wakes up parent
12091209
do x.write_cond |cond| {
1210-
let x2 = ~x.clone();
1210+
let x2 = (*x).clone();
12111211
do task::spawn || {
12121212
do x2.write_cond |cond| {
12131213
let woken = cond.signal();
@@ -1218,7 +1218,7 @@ mod tests {
12181218
}
12191219
// Parent wakes up child
12201220
let (port,chan) = comm::stream();
1221-
let x3 = ~x.clone();
1221+
let x3 = (*x).clone();
12221222
do task::spawn || {
12231223
do x3.write_cond |cond| {
12241224
chan.send(());
@@ -1253,11 +1253,11 @@ mod tests {
12531253
let mut ports = ~[];
12541254
12551255
for num_waiters.times {
1256-
let xi = ~x.clone();
1256+
let xi = (*x).clone();
12571257
let (port, chan) = comm::stream();
12581258
ports.push(port);
12591259
do task::spawn || {
1260-
do lock_cond(xi, dg1) |cond| {
1260+
do lock_cond(&xi, dg1) |cond| {
12611261
chan.send(());
12621262
cond.wait();
12631263
chan.send(());
@@ -1289,10 +1289,10 @@ mod tests {
12891289
pub fn rwlock_kill_helper(mode1: RWlockMode, mode2: RWlockMode) {
12901290
// Mutex must get automatically unlocked if failed/killed within.
12911291
let x = ~RWlock();
1292-
let x2 = ~x.clone();
1292+
let x2 = (*x).clone();
12931293
12941294
let result: result::Result<(),()> = do task::try || {
1295-
do lock_rwlock_in_mode(x2, mode1) {
1295+
do lock_rwlock_in_mode(&x2, mode1) {
12961296
fail!();
12971297
}
12981298
};

branches/try2/src/libstd/treemap.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -636,14 +636,13 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
636636
fn heir_swap<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>,
637637
child: &mut Option<~TreeNode<K, V>>) {
638638
// *could* be done without recursion, but it won't borrow check
639-
do child.mutate |mut child| {
640-
if child.right.is_some() {
641-
heir_swap(node, &mut child.right);
639+
for child.each_mut |x| {
640+
if x.right.is_some() {
641+
heir_swap(node, &mut x.right);
642642
} else {
643-
node.key <-> child.key;
644-
node.value <-> child.value;
643+
node.key <-> x.key;
644+
node.value <-> x.value;
645645
}
646-
child
647646
}
648647
}
649648

@@ -689,7 +688,7 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
689688
save.level -= 1;
690689

691690
if right_level > save.level {
692-
do save.right.mutate |mut x| { x.level = save.level; x }
691+
for save.right.each_mut |x| { x.level = save.level }
693692
}
694693

695694
skew(save);
@@ -988,8 +987,6 @@ mod test_treemap {
988987
let m = m;
989988
let mut a = m.iter();
990989

991-
// FIXME: #4492 (ICE): iter.get() == Some((&x1, &y1))
992-
993990
fail_unless!(map_next(&mut a).unwrap() == (&x1, &y1));
994991
fail_unless!(map_next(&mut a).unwrap() == (&x2, &y2));
995992
fail_unless!(map_next(&mut a).unwrap() == (&x3, &y3));

branches/try2/src/libsyntax/ext/pipes/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn analyze(proto: protocol, _cx: @ext_ctxt) {
6363
debug!("colive iteration %?", i);
6464
let mut new_colive = ~[];
6565
for colive.eachi |i, this_colive| {
66-
let mut result = ~this_colive.clone();
66+
let mut result = this_colive.clone();
6767
let this = proto.get_state_by_id(i);
6868
for this_colive.ones |j| {
6969
let next = proto.get_state_by_id(j);

0 commit comments

Comments
 (0)