Skip to content

Commit 66b396e

Browse files
committed
---
yaml --- r: 61374 b: refs/heads/try c: 22c3db5 h: refs/heads/master v: v3
1 parent 425b743 commit 66b396e

File tree

10 files changed

+42
-146
lines changed

10 files changed

+42
-146
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
5-
refs/heads/try: 8a15333c06b8ba491e1654c3fca3fa21d21def9b
5+
refs/heads/try: 22c3db5df786316c7a7c702aad93e9f0e9a4061d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/etc/vim/after/syntax/rust.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ syn match rustRightArrowHead contained ">" conceal cchar= 
1111
syn match rustRightArrowTail contained "-" conceal cchar=
1212
syn match rustNiceOperator "->" contains=rustRightArrowHead,rustRightArrowTail
1313

14+
syn match rustLeftRightArrowHead contained ">" conceal cchar= 
15+
syn match rustLeftRightArrowTail contained "<-" conceal cchar=
16+
syn match rustNiceOperator "<->" contains=rustLeftRightArrowHead,rustLeftRightArrowTail
17+
1418
syn match rustFatRightArrowHead contained ">" conceal cchar= 
1519
syn match rustFatRightArrowTail contained "=" conceal cchar=
1620
syn match rustNiceOperator "=>" contains=rustFatRightArrowHead,rustFatRightArrowTail

branches/try/src/etc/vim/syntax/rust.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ syn keyword rustOperator as
1515

1616
syn keyword rustKeyword break copy do drop extern
1717
syn keyword rustKeyword for if impl let log
18-
syn keyword rustKeyword copy do extern
18+
syn keyword rustKeyword copy do drop extern
1919
syn keyword rustKeyword for impl let log
2020
syn keyword rustKeyword loop mod once priv pub
2121
syn keyword rustKeyword return
@@ -28,8 +28,8 @@ syn keyword rustStorage const mut ref static
2828
syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
2929
syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
3030

31-
" reserved
32-
syn keyword rustKeyword be
31+
" Reserved words
32+
"syn keyword rustKeyword m32 m64 m128 f80 f16 f128 be " These are obsolete
3333

3434
syn keyword rustType int uint float char bool u8 u16 u32 u64 f32
3535
syn keyword rustType f64 i8 i16 i32 i64 str Self

branches/try/src/libcore/cell.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,10 @@ Similar to a mutable option type, but friendlier.
2121
*/
2222

2323
#[mutable]
24-
#[deriving(Clone)]
2524
pub struct Cell<T> {
2625
priv value: Option<T>
2726
}
2827

29-
impl<T: DeepClone> DeepClone for Cell<T> {
30-
fn deep_clone(&self) -> Cell<T> {
31-
Cell{value: self.value.deep_clone()}
32-
}
33-
}
34-
3528
impl<T:cmp::Eq> cmp::Eq for Cell<T> {
3629
fn eq(&self, other: &Cell<T>) -> bool {
3730
(self.value) == (other.value)

branches/try/src/libcore/clone.rs

Lines changed: 23 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ 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. Types with shared ownership like managed boxes
27-
/// are cloned with a shallow copy.
26+
/// Return a deep copy of the owned object tree. Managed boxes are cloned with a shallow copy.
2827
fn clone(&self) -> Self;
2928
}
3029

31-
impl<T: Clone> Clone for ~T {
30+
impl Clone for () {
31+
/// Return a copy of the value.
32+
#[inline(always)]
33+
fn clone(&self) -> () { () }
34+
}
35+
36+
impl<T:Clone> Clone for ~T {
3237
/// Return a deep copy of the owned box.
3338
#[inline(always)]
3439
fn clone(&self) -> ~T { ~(**self).clone() }
@@ -46,10 +51,16 @@ impl<T> Clone for @mut T {
4651
fn clone(&self) -> @mut T { *self }
4752
}
4853

54+
impl<'self, T> Clone for &'self T {
55+
/// Return a shallow copy of the borrowed pointer.
56+
#[inline(always)]
57+
fn clone(&self) -> &'self T { *self }
58+
}
59+
4960
macro_rules! clone_impl(
5061
($t:ty) => {
5162
impl Clone for $t {
52-
/// Return a deep copy of the value.
63+
/// Return a copy of the value.
5364
#[inline(always)]
5465
fn clone(&self) -> $t { *self }
5566
}
@@ -72,53 +83,9 @@ clone_impl!(float)
7283
clone_impl!(f32)
7384
clone_impl!(f64)
7485

75-
clone_impl!(())
7686
clone_impl!(bool)
7787
clone_impl!(char)
7888

79-
pub trait DeepClone {
80-
/// Return a deep copy of the object tree. Types with shared ownership are also copied via a
81-
/// deep copy, unlike `Clone`. Note that this is currently unimplemented for managed boxes, as
82-
/// it would need to handle cycles.
83-
fn deep_clone(&self) -> Self;
84-
}
85-
86-
macro_rules! deep_clone_impl(
87-
($t:ty) => {
88-
impl DeepClone for $t {
89-
/// Return a deep copy of the value.
90-
#[inline(always)]
91-
fn deep_clone(&self) -> $t { *self }
92-
}
93-
}
94-
)
95-
96-
impl<T: DeepClone> DeepClone for ~T {
97-
/// Return a deep copy of the owned box.
98-
#[inline(always)]
99-
fn deep_clone(&self) -> ~T { ~(**self).deep_clone() }
100-
}
101-
102-
deep_clone_impl!(int)
103-
deep_clone_impl!(i8)
104-
deep_clone_impl!(i16)
105-
deep_clone_impl!(i32)
106-
deep_clone_impl!(i64)
107-
108-
deep_clone_impl!(uint)
109-
deep_clone_impl!(u8)
110-
deep_clone_impl!(u16)
111-
deep_clone_impl!(u32)
112-
deep_clone_impl!(u64)
113-
114-
deep_clone_impl!(float)
115-
deep_clone_impl!(f32)
116-
deep_clone_impl!(f64)
117-
118-
deep_clone_impl!(())
119-
deep_clone_impl!(bool)
120-
deep_clone_impl!(char)
121-
12289
#[test]
12390
fn test_owned_clone() {
12491
let a: ~int = ~5i;
@@ -141,3 +108,11 @@ fn test_managed_mut_clone() {
141108
*b = 10;
142109
assert!(a == b);
143110
}
111+
112+
#[test]
113+
fn test_borrowed_clone() {
114+
let x = 5i;
115+
let y: &int = &x;
116+
let z: &int = (&y).clone();
117+
assert_eq!(*z, 5);
118+
}

branches/try/src/libcore/option.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ use num::Zero;
4949
use old_iter::{BaseIter, MutableIter, ExtendedIter};
5050
use old_iter;
5151
use str::StrSlice;
52-
use clone::DeepClone;
5352

5453
#[cfg(test)] use str;
5554

@@ -60,15 +59,6 @@ pub enum Option<T> {
6059
Some(T),
6160
}
6261

63-
impl<T: DeepClone> DeepClone for Option<T> {
64-
fn deep_clone(&self) -> Option<T> {
65-
match *self {
66-
Some(ref x) => Some(x.deep_clone()),
67-
None => None
68-
}
69-
}
70-
}
71-
7262
impl<T:Ord> Ord for Option<T> {
7363
fn lt(&self, other: &Option<T>) -> bool {
7464
match (self, other) {

branches/try/src/libcore/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub use io::{print, println};
2727

2828
/* Reexported types and traits */
2929

30-
pub use clone::{Clone, DeepClone};
30+
pub use clone::Clone;
3131
pub use cmp::{Eq, ApproxEq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater, Equiv};
3232
pub use container::{Container, Mutable, Map, Set};
3333
pub use hash::Hash;

branches/try/src/libcore/task/local_data_priv.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap {
9494
let map_ptr = rt::rust_get_task_local_data(task);
9595
if map_ptr.is_null() {
9696
let map: TaskLocalMap = @mut ~[];
97-
// NB: This bumps the ref count before converting to an unsafe pointer,
98-
// keeping the map alive until TLS is destroyed
9997
rt::rust_set_task_local_data(task, cast::transmute(map));
10098
rt::rust_task_local_data_atexit(task, cleanup_task_local_map_extern_cb);
99+
// Also need to reference it an extra time to keep it for now.
100+
let nonmut = cast::transmute::<TaskLocalMap,
101+
@~[Option<TaskLocalElement>]>(map);
102+
cast::bump_box_refcount(nonmut);
101103
map
102104
} else {
103105
let map = cast::transmute(map_ptr);

branches/try/src/librusti/rusti.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ mod tests {
446446
}
447447
}
448448

449-
#[test] #[ignore]
449+
#[test]
450450
fn run_all() {
451451
// By default, unit tests are run in parallel. Rusti, on the other hand,
452452
// does not enjoy doing this. I suspect that it is because the LLVM

branches/try/src/libstd/rc.rs

Lines changed: 5 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ impl<T: Owned> Drop for Rc<T> {
7676

7777

7878
impl<T: Owned> Clone for Rc<T> {
79-
/// Return a shallow copy of the reference counted pointer.
8079
#[inline]
8180
fn clone(&self) -> Rc<T> {
8281
unsafe {
@@ -86,38 +85,9 @@ impl<T: Owned> Clone for Rc<T> {
8685
}
8786
}
8887

89-
impl<T: Owned + DeepClone> DeepClone for Rc<T> {
90-
/// Return a deep copy of the reference counted pointer.
91-
#[inline]
92-
fn deep_clone(&self) -> Rc<T> {
93-
Rc::new(self.borrow().deep_clone())
94-
}
95-
}
96-
9788
#[cfg(test)]
9889
mod test_rc {
9990
use super::*;
100-
use core::cell::Cell;
101-
102-
#[test]
103-
fn test_clone() {
104-
let x = Rc::new(Cell(5));
105-
let y = x.clone();
106-
do x.borrow().with_mut_ref |inner| {
107-
*inner = 20;
108-
}
109-
assert_eq!(y.borrow().take(), 20);
110-
}
111-
112-
#[test]
113-
fn test_deep_clone() {
114-
let x = Rc::new(Cell(5));
115-
let y = x.deep_clone();
116-
do x.borrow().with_mut_ref |inner| {
117-
*inner = 20;
118-
}
119-
assert_eq!(y.borrow().take(), 5);
120-
}
12191

12292
#[test]
12393
fn test_simple() {
@@ -126,7 +96,7 @@ mod test_rc {
12696
}
12797

12898
#[test]
129-
fn test_simple_clone() {
99+
fn test_clone() {
130100
let x = Rc::new(5);
131101
let y = x.clone();
132102
assert_eq!(*x.borrow(), 5);
@@ -179,26 +149,24 @@ pub impl<T: Owned> RcMut<T> {
179149

180150
/// Fails if there is already a mutable borrow of the box
181151
#[inline]
182-
fn with_borrow<U>(&self, f: &fn(&T) -> U) -> U {
152+
fn with_borrow(&self, f: &fn(&T)) {
183153
unsafe {
184154
assert!((*self.ptr).borrow != Mutable);
185155
let previous = (*self.ptr).borrow;
186156
(*self.ptr).borrow = Immutable;
187-
let res = f(&(*self.ptr).value);
157+
f(&(*self.ptr).value);
188158
(*self.ptr).borrow = previous;
189-
res
190159
}
191160
}
192161

193162
/// Fails if there is already a mutable or immutable borrow of the box
194163
#[inline]
195-
fn with_mut_borrow<U>(&self, f: &fn(&mut T) -> U) -> U {
164+
fn with_mut_borrow(&self, f: &fn(&mut T)) {
196165
unsafe {
197166
assert!((*self.ptr).borrow == Nothing);
198167
(*self.ptr).borrow = Mutable;
199-
let res = f(&mut (*self.ptr).value);
168+
f(&mut (*self.ptr).value);
200169
(*self.ptr).borrow = Nothing;
201-
res
202170
}
203171
}
204172
}
@@ -232,7 +200,6 @@ impl<T: Owned> Drop for RcMut<T> {
232200
}
233201

234202
impl<T: Owned> Clone for RcMut<T> {
235-
/// Return a shallow copy of the reference counted pointer.
236203
#[inline]
237204
fn clone(&self) -> RcMut<T> {
238205
unsafe {
@@ -242,45 +209,10 @@ impl<T: Owned> Clone for RcMut<T> {
242209
}
243210
}
244211

245-
impl<T: Owned + DeepClone> DeepClone for RcMut<T> {
246-
/// Return a deep copy of the reference counted pointer.
247-
#[inline]
248-
fn deep_clone(&self) -> RcMut<T> {
249-
do self.with_borrow |x| {
250-
// FIXME: #6497: should avoid freeze (slow)
251-
RcMut::new(x.deep_clone())
252-
}
253-
}
254-
}
255-
256212
#[cfg(test)]
257213
mod test_rc_mut {
258214
use super::*;
259215

260-
#[test]
261-
fn test_clone() {
262-
let x = RcMut::new(5);
263-
let y = x.clone();
264-
do x.with_mut_borrow |value| {
265-
*value = 20;
266-
}
267-
do y.with_borrow |value| {
268-
assert_eq!(*value, 20);
269-
}
270-
}
271-
272-
#[test]
273-
fn test_deep_clone() {
274-
let x = RcMut::new(5);
275-
let y = x.deep_clone();
276-
do x.with_mut_borrow |value| {
277-
*value = 20;
278-
}
279-
do y.with_borrow |value| {
280-
assert_eq!(*value, 5);
281-
}
282-
}
283-
284216
#[test]
285217
fn borrow_many() {
286218
let x = RcMut::new(5);

0 commit comments

Comments
 (0)