Skip to content

Commit e0b9462

Browse files
committed
---
yaml --- r: 139031 b: refs/heads/try2 c: 748c2c9 h: refs/heads/master i: 139029: 599cbb2 139027: bb85426 139023: 129aaf6 v: v3
1 parent cd13d6c commit e0b9462

File tree

13 files changed

+77
-74
lines changed

13 files changed

+77
-74
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: 5a77a1048897a12c9031d3e0b3867f0c6e3673ea
8+
refs/heads/try2: 748c2c9ebc3859c77a1fa3ef808ddd04c77bab75
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/rt/thread_local_storage.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ type pthread_key_t = c_ulong;
4040

4141
#[cfg(target_os="linux")]
4242
#[cfg(target_os="freebsd")]
43-
#[cfg(target_os="android")]
4443
#[allow(non_camel_case_types)] // foreign type
4544
type pthread_key_t = c_uint;
4645

branches/try2/src/libcore/str.rs

Lines changed: 8 additions & 3 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};
@@ -2273,7 +2274,6 @@ pub trait StrSlice {
22732274
pure fn to_owned(&self) -> ~str;
22742275
pure fn to_managed(&self) -> @str;
22752276
pure fn char_at(&self, i: uint) -> char;
2276-
fn to_bytes(&self) -> ~[u8];
22772277
}
22782278
22792279
/// Extension methods for strings
@@ -2417,8 +2417,6 @@ impl StrSlice for &self/str {
24172417
24182418
#[inline]
24192419
pure fn char_at(&self, i: uint) -> char { char_at(*self, i) }
2420-
2421-
fn to_bytes(&self) -> ~[u8] { to_bytes(*self) }
24222420
}
24232421
24242422
pub trait OwnedStr {
@@ -2436,6 +2434,13 @@ impl OwnedStr for ~str {
24362434
}
24372435
}
24382436
2437+
impl Clone for ~str {
2438+
#[inline(always)]
2439+
fn clone(&self) -> ~str {
2440+
self.to_str() // hilarious
2441+
}
2442+
}
2443+
24392444
#[cfg(test)]
24402445
mod tests {
24412446
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: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,61 +22,40 @@ pub struct Deque<T> {
2222
}
2323

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

3229
impl<T> Mutable for Deque<T> {
33-
/// Clear the deque, removing all values.
3430
fn clear(&mut self) {
35-
for self.elts.each_mut |x| { *x = None }
31+
for vec::each_mut(self.elts) |x| { *x = None }
3632
self.nelts = 0;
3733
self.lo = 0;
3834
self.hi = 0;
3935
}
4036
}
4137

4238
pub impl<T> Deque<T> {
43-
/// Create an empty Deque
4439
static pure fn new() -> Deque<T> {
4540
Deque{nelts: 0, lo: 0, hi: 0,
4641
elts: vec::from_fn(initial_capacity, |_| None)}
4742
}
4843

49-
/// Return a reference to the first element in the deque
50-
///
51-
/// Fails if the deque is empty
5244
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
5745
fn peek_back(&self) -> &self/T { get(self.elts, self.hi - 1u) }
5846

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

67-
/// Remove and return the first element in the deque
68-
///
69-
/// Fails if the deque is empty
7052
fn pop_front(&mut self) -> T {
7153
let mut result = self.elts[self.lo].swap_unwrap();
7254
self.lo = (self.lo + 1u) % self.elts.len();
7355
self.nelts -= 1u;
7456
result
7557
}
7658

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

90-
/// Prepend an element to the deque
9169
fn add_front(&mut self, t: T) {
9270
let oldlo = self.lo;
9371
if self.lo == 0u {
@@ -102,7 +80,6 @@ pub impl<T> Deque<T> {
10280
self.nelts += 1u;
10381
}
10482

105-
/// Append an element to the deque
10683
fn add_back(&mut self, t: T) {
10784
if self.lo == self.hi && self.nelts != 0u {
10885
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
};

0 commit comments

Comments
 (0)