Skip to content

Commit 806fed7

Browse files
committed
---
yaml --- r: 61375 b: refs/heads/try c: 6a9c3bd h: refs/heads/master i: 61373: 425b743 61371: 59326f3 61367: ee05b03 61359: 346bbb2 61343: 6399c8d 61311: 9f2e87b v: v3
1 parent 66b396e commit 806fed7

File tree

17 files changed

+443
-474
lines changed

17 files changed

+443
-474
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: 22c3db5df786316c7a7c702aad93e9f0e9a4061d
5+
refs/heads/try: 6a9c3bd86e0271f26dc63bd12e0d54a35b704dff
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: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ 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-
1814
syn match rustFatRightArrowHead contained ">" conceal cchar= 
1915
syn match rustFatRightArrowTail contained "=" conceal cchar=
2016
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 drop extern
18+
syn keyword rustKeyword copy do 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 words
32-
"syn keyword rustKeyword m32 m64 m128 f80 f16 f128 be " These are obsolete
31+
" reserved
32+
syn keyword rustKeyword be
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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@ Similar to a mutable option type, but friendlier.
2121
*/
2222

2323
#[mutable]
24+
#[deriving(Clone)]
2425
pub struct Cell<T> {
2526
priv value: Option<T>
2627
}
2728

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+
2835
impl<T:cmp::Eq> cmp::Eq for Cell<T> {
2936
fn eq(&self, other: &Cell<T>) -> bool {
3037
(self.value) == (other.value)

branches/try/src/libcore/clone.rs

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

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 {
31+
impl<T: Clone> Clone for ~T {
3732
/// Return a deep copy of the owned box.
3833
#[inline(always)]
3934
fn clone(&self) -> ~T { ~(**self).clone() }
@@ -51,16 +46,10 @@ impl<T> Clone for @mut T {
5146
fn clone(&self) -> @mut T { *self }
5247
}
5348

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-
6049
macro_rules! clone_impl(
6150
($t:ty) => {
6251
impl Clone for $t {
63-
/// Return a copy of the value.
52+
/// Return a deep copy of the value.
6453
#[inline(always)]
6554
fn clone(&self) -> $t { *self }
6655
}
@@ -83,9 +72,53 @@ clone_impl!(float)
8372
clone_impl!(f32)
8473
clone_impl!(f64)
8574

75+
clone_impl!(())
8676
clone_impl!(bool)
8777
clone_impl!(char)
8878

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+
89122
#[test]
90123
fn test_owned_clone() {
91124
let a: ~int = ~5i;
@@ -108,11 +141,3 @@ fn test_managed_mut_clone() {
108141
*b = 10;
109142
assert!(a == b);
110143
}
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ use num::Zero;
4949
use old_iter::{BaseIter, MutableIter, ExtendedIter};
5050
use old_iter;
5151
use str::StrSlice;
52+
use clone::DeepClone;
5253

5354
#[cfg(test)] use str;
5455

@@ -59,6 +60,15 @@ pub enum Option<T> {
5960
Some(T),
6061
}
6162

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+
6272
impl<T:Ord> Ord for Option<T> {
6373
fn lt(&self, other: &Option<T>) -> bool {
6474
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;
30+
pub use clone::{Clone, DeepClone};
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: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,10 @@ 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
9799
rt::rust_set_task_local_data(task, cast::transmute(map));
98100
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);
103101
map
104102
} else {
105103
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]
449+
#[test] #[ignore]
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/librustpkg/conditions.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ condition! {
2828
condition! {
2929
missing_pkg_files: (super::PkgId) -> ();
3030
}
31+
32+
condition! {
33+
bad_pkg_id: (super::Path, ~str) -> ::util::PkgId;
34+
}

0 commit comments

Comments
 (0)