Skip to content

Commit c34a302

Browse files
committed
---
yaml --- r: 61400 b: refs/heads/try c: 47c9157 h: refs/heads/master v: v3
1 parent 162228f commit c34a302

File tree

22 files changed

+159
-239
lines changed

22 files changed

+159
-239
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: f19883223cbf72ec28b503cae71f823fc2229708
5+
refs/heads/try: 47c9157d872fed7a7ef422efe7176f8a29b949d8
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/.swo

72 KB
Binary file not shown.

branches/try/doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@ Supported traits for `deriving` are:
15621562

15631563
* Comparison traits: `Eq`, `TotalEq`, `Ord`, `TotalOrd`.
15641564
* Serialization: `Encodable`, `Decodable`. These require `std`.
1565-
* `Clone`, to perform deep copies.
1565+
* `Clone` and `DeepClone`, to perform (deep) copies.
15661566
* `IterBytes`, to iterate over the bytes in a data type.
15671567
* `Rand`, to create a random instance of a data type.
15681568
* `ToStr`, to convert to a string. For a type with this instance,

branches/try/doc/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,8 +2308,8 @@ enum ABC { A, B, C }
23082308
~~~
23092309

23102310
The full list of derivable traits is `Eq`, `TotalEq`, `Ord`,
2311-
`TotalOrd`, `Encodable` `Decodable`, `Clone`, `IterBytes`, `Rand` and
2312-
`ToStr`.
2311+
`TotalOrd`, `Encodable` `Decodable`, `Clone`, `DeepClone`,
2312+
`IterBytes`, `Rand` and `ToStr`.
23132313

23142314
# Modules and crates
23152315

branches/try/src/libcore/clone.rs

Lines changed: 11 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ by convention implementing the `Clone` trait and calling the
2222
2323
*/
2424

25-
use core::kinds::Const;
26-
2725
pub trait Clone {
2826
/// Return a deep copy of the owned object tree. Types with shared ownership like managed boxes
2927
/// are cloned with a shallow copy.
@@ -48,12 +46,6 @@ impl<T> Clone for @mut T {
4846
fn clone(&self) -> @mut T { *self }
4947
}
5048

51-
impl<'self, T> Clone for &'self T {
52-
/// Return a shallow copy of the borrowed pointer.
53-
#[inline(always)]
54-
fn clone(&self) -> &'self T { *self }
55-
}
56-
5749
macro_rules! clone_impl(
5850
($t:ty) => {
5951
impl Clone for $t {
@@ -86,32 +78,11 @@ clone_impl!(char)
8678

8779
pub trait DeepClone {
8880
/// Return a deep copy of the object tree. Types with shared ownership are also copied via a
89-
/// deep copy, unlike `Clone`.
81+
/// deep copy, unlike `Clone`. Note that this is currently unimplemented for managed boxes, as
82+
/// it would need to handle cycles.
9083
fn deep_clone(&self) -> Self;
9184
}
9285

93-
impl<T: DeepClone> DeepClone for ~T {
94-
/// Return a deep copy of the owned box.
95-
#[inline(always)]
96-
fn deep_clone(&self) -> ~T { ~(**self).deep_clone() }
97-
}
98-
99-
// FIXME: #6525: should also be implemented for `T: Owned + DeepClone`
100-
impl<T: Const + DeepClone> DeepClone for @T {
101-
/// Return a deep copy of the managed box. The `Const` trait is required to prevent performing
102-
/// a deep clone of a potentially cyclical type.
103-
#[inline(always)]
104-
fn deep_clone(&self) -> @T { @(**self).deep_clone() }
105-
}
106-
107-
// FIXME: #6525: should also be implemented for `T: Owned + DeepClone`
108-
impl<T: Const + DeepClone> DeepClone for @mut T {
109-
/// Return a deep copy of the managed box. The `Const` trait is required to prevent performing
110-
/// a deep clone of a potentially cyclical type.
111-
#[inline(always)]
112-
fn deep_clone(&self) -> @mut T { @mut (**self).deep_clone() }
113-
}
114-
11586
macro_rules! deep_clone_impl(
11687
($t:ty) => {
11788
impl DeepClone for $t {
@@ -122,6 +93,12 @@ macro_rules! deep_clone_impl(
12293
}
12394
)
12495

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+
125102
deep_clone_impl!(int)
126103
deep_clone_impl!(i8)
127104
deep_clone_impl!(i16)
@@ -144,39 +121,23 @@ deep_clone_impl!(char)
144121

145122
#[test]
146123
fn test_owned_clone() {
147-
let a = ~5i;
124+
let a: ~int = ~5i;
148125
let b: ~int = a.clone();
149126
assert!(a == b);
150127
}
151128

152129
#[test]
153130
fn test_managed_clone() {
154-
let a = @5i;
131+
let a: @int = @5i;
155132
let b: @int = a.clone();
156133
assert!(a == b);
157134
}
158135

159-
#[test]
160-
fn test_managed_mut_deep_clone() {
161-
let x = @mut 5i;
162-
let y: @mut int = x.deep_clone();
163-
*x = 20;
164-
assert_eq!(*y, 5);
165-
}
166-
167136
#[test]
168137
fn test_managed_mut_clone() {
169-
let a = @mut 5i;
138+
let a: @mut int = @mut 5i;
170139
let b: @mut int = a.clone();
171140
assert!(a == b);
172141
*b = 10;
173142
assert!(a == b);
174143
}
175-
176-
#[test]
177-
fn test_borrowed_clone() {
178-
let x = 5i;
179-
let y: &int = &x;
180-
let z: &int = (&y).clone();
181-
assert_eq!(*z, 5);
182-
}

branches/try/src/libcore/os.rs

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -289,33 +289,6 @@ pub fn setenv(n: &str, v: &str) {
289289
}
290290
}
291291

292-
/// Remove a variable from the environment entirely
293-
pub fn unsetenv(n: &str) {
294-
#[cfg(unix)]
295-
fn _unsetenv(n: &str) {
296-
unsafe {
297-
do with_env_lock {
298-
do str::as_c_str(n) |nbuf| {
299-
libc::funcs::posix01::unistd::unsetenv(nbuf);
300-
}
301-
}
302-
}
303-
}
304-
#[cfg(windows)]
305-
fn _unsetenv(n: &str) {
306-
unsafe {
307-
do with_env_lock {
308-
use os::win32::as_utf16_p;
309-
do as_utf16_p(n) |nbuf| {
310-
libc::SetEnvironmentVariableW(nbuf, ptr::null());
311-
}
312-
}
313-
}
314-
}
315-
316-
_unsetenv(n);
317-
}
318-
319292
pub fn fdopen(fd: c_int) -> *FILE {
320293
unsafe {
321294
return do as_c_charp("r") |modebuf| {
@@ -1439,7 +1412,7 @@ mod tests {
14391412
use option::Some;
14401413
use option;
14411414
use os::{as_c_charp, env, getcwd, getenv, make_absolute, real_args};
1442-
use os::{remove_file, setenv, unsetenv};
1415+
use os::{remove_file, setenv};
14431416
use os;
14441417
use path::Path;
14451418
use rand::RngUtil;
@@ -1475,14 +1448,6 @@ mod tests {
14751448
assert!(getenv(n) == option::Some(~"VALUE"));
14761449
}
14771450
1478-
#[test]
1479-
fn test_unsetenv() {
1480-
let n = make_rand_name();
1481-
setenv(n, ~"VALUE");
1482-
unsetenv(n);
1483-
assert!(getenv(n) == option::None);
1484-
}
1485-
14861451
#[test]
14871452
#[ignore(cfg(windows))]
14881453
#[ignore]

branches/try/src/libcore/vec.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2546,29 +2546,23 @@ pub mod raw {
25462546
* would also make any pointers to it invalid.
25472547
*/
25482548
#[inline(always)]
2549-
pub fn to_ptr<T>(v: &[T]) -> *T {
2550-
unsafe {
2551-
let repr: **SliceRepr = transmute(&v);
2552-
transmute(&((**repr).data))
2553-
}
2549+
pub unsafe fn to_ptr<T>(v: &[T]) -> *T {
2550+
let repr: **SliceRepr = transmute(&v);
2551+
transmute(&((**repr).data))
25542552
}
25552553

25562554
/** see `to_ptr()` */
25572555
#[inline(always)]
2558-
pub fn to_const_ptr<T>(v: &const [T]) -> *const T {
2559-
unsafe {
2560-
let repr: **SliceRepr = transmute(&v);
2561-
transmute(&((**repr).data))
2562-
}
2556+
pub unsafe fn to_const_ptr<T>(v: &const [T]) -> *const T {
2557+
let repr: **SliceRepr = transmute(&v);
2558+
transmute(&((**repr).data))
25632559
}
25642560

25652561
/** see `to_ptr()` */
25662562
#[inline(always)]
2567-
pub fn to_mut_ptr<T>(v: &mut [T]) -> *mut T {
2568-
unsafe {
2569-
let repr: **SliceRepr = transmute(&v);
2570-
transmute(&((**repr).data))
2571-
}
2563+
pub unsafe fn to_mut_ptr<T>(v: &mut [T]) -> *mut T {
2564+
let repr: **SliceRepr = transmute(&v);
2565+
transmute(&((**repr).data))
25722566
}
25732567

25742568
/**

branches/try/src/librustpkg/tests.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ fn test_sysroot() -> Path {
9393
self_path.pop()
9494
}
9595

96-
// Ignored on i686 -- see #6517
9796
#[test]
98-
#[ignore(cfg(target_arch = "x86"))]
9997
fn test_make_dir_rwx() {
10098
let temp = &os::tmpdir();
10199
let dir = temp.push(~"quux");
@@ -109,7 +107,6 @@ fn test_make_dir_rwx() {
109107
}
110108

111109
#[test]
112-
#[ignore(cfg(target_arch = "x86"))]
113110
fn test_install_valid() {
114111
let sysroot = test_sysroot();
115112
debug!("sysroot = %s", sysroot.to_str());
@@ -135,7 +132,6 @@ fn test_install_valid() {
135132
}
136133

137134
#[test]
138-
#[ignore(cfg(target_arch = "x86"))]
139135
fn test_install_invalid() {
140136
use conditions::nonexistent_package::cond;
141137
use cond1 = conditions::missing_pkg_files::cond;
@@ -158,7 +154,6 @@ fn test_install_invalid() {
158154
}
159155

160156
#[test]
161-
#[ignore(cfg(target_arch = "x86"))]
162157
fn test_install_url() {
163158
let workspace = mkdtemp(&os::tmpdir(), "test").expect("couldn't create temp dir");
164159
let sysroot = test_sysroot();

0 commit comments

Comments
 (0)