Skip to content

Commit ed2f4d8

Browse files
committed
---
yaml --- r: 61409 b: refs/heads/try c: 65b7903 h: refs/heads/master i: 61407: dd7e0ae v: v3
1 parent c3dfde3 commit ed2f4d8

Some content is hidden

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

75 files changed

+2186
-1612
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: 00eef96a007a817533e78860e97b251258177d5f
5+
refs/heads/try: 65b7903ba3aab91c68d09e192f907a68b7308ee4
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` and `DeepClone`, to perform (deep) copies.
1565+
* `Clone`, 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`, `DeepClone`,
2312-
`IterBytes`, `Rand` and `ToStr`.
2311+
`TotalOrd`, `Encodable` `Decodable`, `Clone`, `IterBytes`, `Rand` and
2312+
`ToStr`.
23132313

23142314
# Modules and crates
23152315

branches/try/src/libcore/at_vec.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub fn from_elem<T:Copy>(n_elts: uint, t: T) -> @[T] {
149149
* Creates and initializes an immutable managed vector by moving all the
150150
* elements from an owned vector.
151151
*/
152-
pub fn to_managed_consume<T>(v: ~[T]) -> @[T] {
152+
pub fn from_owned<T>(v: ~[T]) -> @[T] {
153153
let mut av = @[];
154154
unsafe {
155155
raw::reserve(&mut av, v.len());
@@ -164,7 +164,7 @@ pub fn to_managed_consume<T>(v: ~[T]) -> @[T] {
164164
* Creates and initializes an immutable managed vector by copying all the
165165
* elements of a slice.
166166
*/
167-
pub fn to_managed<T:Copy>(v: &[T]) -> @[T] {
167+
pub fn from_slice<T:Copy>(v: &[T]) -> @[T] {
168168
from_fn(v.len(), |i| v[i])
169169
}
170170

@@ -304,20 +304,20 @@ mod test {
304304
}
305305

306306
#[test]
307-
fn test_to_managed_consume() {
308-
assert!(to_managed_consume::<int>(~[]) == @[]);
309-
assert!(to_managed_consume(~[true]) == @[true]);
310-
assert!(to_managed_consume(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
311-
assert!(to_managed_consume(~[~"abc", ~"123"]) == @[~"abc", ~"123"]);
312-
assert!(to_managed_consume(~[~[42]]) == @[~[42]]);
307+
fn test_from_owned() {
308+
assert!(from_owned::<int>(~[]) == @[]);
309+
assert!(from_owned(~[true]) == @[true]);
310+
assert!(from_owned(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
311+
assert!(from_owned(~[~"abc", ~"123"]) == @[~"abc", ~"123"]);
312+
assert!(from_owned(~[~[42]]) == @[~[42]]);
313313
}
314314
315315
#[test]
316-
fn test_to_managed() {
317-
assert!(to_managed::<int>([]) == @[]);
318-
assert!(to_managed([true]) == @[true]);
319-
assert!(to_managed([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
320-
assert!(to_managed([@"abc", @"123"]) == @[@"abc", @"123"]);
321-
assert!(to_managed([@[42]]) == @[@[42]]);
316+
fn test_from_slice() {
317+
assert!(from_slice::<int>([]) == @[]);
318+
assert!(from_slice([true]) == @[true]);
319+
assert!(from_slice([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
320+
assert!(from_slice([@"abc", @"123"]) == @[@"abc", @"123"]);
321+
assert!(from_slice([@[42]]) == @[@[42]]);
322322
}
323323
}

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/hashmap.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,10 +825,6 @@ pub impl <T:Hash + Eq> HashSet<T> {
825825
fn consume(&mut self, f: &fn(T)) {
826826
self.map.consume(|k, _| f(k))
827827
}
828-
829-
fn contains_equiv<Q:Hash + Equiv<T>>(&self, value: &Q) -> bool {
830-
self.map.contains_key_equiv(value)
831-
}
832828
}
833829

834830
#[cfg(test)]

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/librustc/README.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ ASTs -- are in a separate crate called "syntax", whose files are in
3535
./../libsyntax, where . is the current directory (that is, the parent
3636
directory of front/, middle/, back/, and so on).
3737

38-
The entry-point for the compiler is main() in rustc.rc, and
38+
The entry-point for the compiler is main() in driver/rustc.rs, and
3939
this file sequences the various parts together.
4040

4141

4242
The 3 central data structures:
4343
------------------------------
4444

45-
#1: ./../libsyntax/ast.rs defines the AST. The AST is treated as immutable
45+
#1: ../libsyntax/ast.rs defines the AST. The AST is treated as immutable
4646
after parsing, but it depends on mutable context data structures
4747
(mainly hash maps) to give it meaning.
4848

4949
- Many -- though not all -- nodes within this data structure are
50-
wrapped in the type `spanned<T>`, meaning that the front-end has
50+
wrapped in the type spanned<T>, meaning that the front-end has
5151
marked the input coordinates of that node. The member .node is
5252
the data itself, the member .span is the input location (file,
5353
line, column; both low and high).
@@ -78,7 +78,7 @@ Control and information flow within the compiler:
7878
- main() in rustc.rc assumes control on startup. Options are
7979
parsed, platform is detected, etc.
8080

81-
- ./../libsyntax/parse/parser.rs parses the input files and produces an AST
81+
- libsyntax/parse/parser.rs parses the input files and produces an AST
8282
that represents the input crate.
8383

8484
- Multiple middle-end passes (middle/resolve.rs, middle/typeck.rs)

branches/try/src/librustc/metadata/csearch.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,13 @@ pub fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id,
234234
}
235235
}
236236

237-
// Given a def_id for an impl or class, return the traits it implements,
238-
// or the empty vector if it's not for an impl or for a class that implements
239-
// traits
240-
pub fn get_impl_traits(tcx: ty::ctxt,
241-
def: ast::def_id) -> ~[@ty::TraitRef] {
237+
// Given a def_id for an impl, return the trait it implements,
238+
// if there is one.
239+
pub fn get_impl_trait(tcx: ty::ctxt,
240+
def: ast::def_id) -> Option<@ty::TraitRef> {
242241
let cstore = tcx.cstore;
243242
let cdata = cstore::get_crate_data(cstore, def.crate);
244-
decoder::get_impl_traits(cdata, def.node, tcx)
243+
decoder::get_impl_trait(cdata, def.node, tcx)
245244
}
246245

247246
pub fn get_impl_method(cstore: @mut cstore::CStore,

branches/try/src/librustc/metadata/decoder.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,19 +415,20 @@ pub fn get_type_param_count(data: @~[u8], id: ast::node_id) -> uint {
415415
item_ty_param_count(lookup_item(id, data))
416416
}
417417

418-
pub fn get_impl_traits(cdata: cmd,
418+
pub fn get_impl_trait(cdata: cmd,
419419
id: ast::node_id,
420-
tcx: ty::ctxt) -> ~[@ty::TraitRef]
420+
tcx: ty::ctxt) -> Option<@ty::TraitRef>
421421
{
422422
let item_doc = lookup_item(id, cdata.data);
423-
let mut results = ~[];
423+
let mut result = None;
424424
for reader::tagged_docs(item_doc, tag_item_trait_ref) |tp| {
425425
let trait_ref =
426426
@parse_trait_ref_data(tp.data, cdata.cnum, tp.start, tcx,
427427
|_, did| translate_def_id(cdata, did));
428-
results.push(trait_ref);
428+
result = Some(trait_ref);
429+
break;
429430
};
430-
results
431+
result
431432
}
432433

433434
pub fn get_impl_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,

0 commit comments

Comments
 (0)