Skip to content

Commit 1e3d63f

Browse files
committed
---
yaml --- r: 140662 b: refs/heads/try2 c: 1393c3a h: refs/heads/master v: v3
1 parent 4c6648b commit 1e3d63f

File tree

118 files changed

+945
-1477
lines changed

Some content is hidden

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

118 files changed

+945
-1477
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: f04eb37c7ea19bbd2cff12d15816873e0a46fc86
8+
refs/heads/try2: 1393c3a3f438c896083405dca501c8cf05767c65
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/tutorial-ffi.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub struct Unique<T> {
157157
priv ptr: *mut T
158158
}
159159
160-
pub impl<T: Owned> Unique<T> {
160+
pub impl<'self, T: Owned> Unique<T> {
161161
fn new(value: T) -> Unique<T> {
162162
unsafe {
163163
let ptr = malloc(core::sys::size_of::<T>() as size_t) as *mut T;
@@ -168,14 +168,14 @@ pub impl<T: Owned> Unique<T> {
168168
}
169169
}
170170
171-
// the 'r lifetime results in the same semantics as `&*x` with ~T
172-
fn borrow<'r>(&'r self) -> &'r T {
173-
unsafe { cast::copy_lifetime(self, &*self.ptr) }
171+
// the 'self lifetime results in the same semantics as `&*x` with ~T
172+
fn borrow(&self) -> &'self T {
173+
unsafe { cast::transmute(self.ptr) }
174174
}
175175
176-
// the 'r lifetime results in the same semantics as `&mut *x` with ~T
177-
fn borrow_mut<'r>(&'r mut self) -> &'r mut T {
178-
unsafe { cast::copy_mut_lifetime(self, &mut *self.ptr) }
176+
// the 'self lifetime results in the same semantics as `&mut *x` with ~T
177+
fn borrow_mut(&mut self) -> &'self mut T {
178+
unsafe { cast::transmute(self.ptr) }
179179
}
180180
}
181181

branches/try2/src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ fn _arm_exec_compiled_test(config: config, props: TestProps,
764764
logv(config, fmt!("executing (%s) %s", config.target, cmdline));
765765
766766
// adb shell dose not forward stdout and stderr of internal result
767-
// to stdout and stderr separately but to stdout only
767+
// to stdout and stderr seperately but to stdout only
768768
let mut newargs_out = ~[];
769769
let mut newargs_err = ~[];
770770
let subargs = args.args;

branches/try2/src/libcore/at_vec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn capacity<T>(v: @[T]) -> uint {
5252
* # Arguments
5353
*
5454
* * size - An initial size of the vector to reserve
55-
* * builder - A function that will construct the vector. It receives
55+
* * builder - A function that will construct the vector. It recieves
5656
* as an argument a function that will push an element
5757
* onto the vector being constructed.
5858
*/
@@ -70,7 +70,7 @@ pub fn build_sized<A>(size: uint, builder: &fn(push: &fn(v: A))) -> @[A] {
7070
*
7171
* # Arguments
7272
*
73-
* * builder - A function that will construct the vector. It receives
73+
* * builder - A function that will construct the vector. It recieves
7474
* as an argument a function that will push an element
7575
* onto the vector being constructed.
7676
*/
@@ -87,7 +87,7 @@ pub fn build<A>(builder: &fn(push: &fn(v: A))) -> @[A] {
8787
* # Arguments
8888
*
8989
* * size - An option, maybe containing initial size of the vector to reserve
90-
* * builder - A function that will construct the vector. It receives
90+
* * builder - A function that will construct the vector. It recieves
9191
* as an argument a function that will push an element
9292
* onto the vector being constructed.
9393
*/

branches/try2/src/libcore/cast.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,6 @@ pub mod rusti {
2424
}
2525

2626
/// Casts the value at `src` to U. The two types must have the same length.
27-
#[cfg(not(stage0))]
28-
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
29-
let mut dest: U = unstable::intrinsics::uninit();
30-
{
31-
let dest_ptr: *mut u8 = rusti::transmute(&mut dest);
32-
let src_ptr: *u8 = rusti::transmute(src);
33-
unstable::intrinsics::memmove64(dest_ptr,
34-
src_ptr,
35-
sys::size_of::<U>() as u64);
36-
}
37-
dest
38-
}
39-
40-
#[cfg(stage0)]
4127
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
4228
let mut dest: U = unstable::intrinsics::init();
4329
{
@@ -122,12 +108,6 @@ pub unsafe fn copy_lifetime<'a,S,T>(_ptr: &'a S, ptr: &T) -> &'a T {
122108
transmute_region(ptr)
123109
}
124110

125-
/// Transforms lifetime of the second pointer to match the first.
126-
#[inline(always)]
127-
pub unsafe fn copy_mut_lifetime<'a,S,T>(_ptr: &'a mut S, ptr: &mut T) -> &'a mut T {
128-
transmute_mut_region(ptr)
129-
}
130-
131111
/// Transforms lifetime of the second pointer to match the first.
132112
#[inline(always)]
133113
pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T {

branches/try2/src/libcore/core.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ they contained the following prologue:
6060
// Don't link to core. We are core.
6161
#[no_core];
6262

63+
#[warn(vecs_implicitly_copyable)];
6364
#[deny(non_camel_case_types)];
6465
#[allow(deprecated_mutable_fields)];
6566

branches/try2/src/libcore/iter.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ breaking out of iteration. The adaptors in the module work with any such iterato
1717
tied to specific traits. For example:
1818
1919
~~~~
20-
println(iter::to_vec(|f| uint::range(0, 20, f)).to_str());
20+
use core::iter::iter_to_vec;
21+
println(iter_to_vec(|f| uint::range(0, 20, f)).to_str());
2122
~~~~
2223
2324
An external iterator object implementing the interface in the `iterator` module can be used as an
@@ -54,12 +55,12 @@ pub trait Times {
5455
*
5556
* ~~~
5657
* let xs = ~[1, 2, 3];
57-
* let ys = do iter::to_vec |f| { xs.each(|x| f(*x)) };
58+
* let ys = do iter_to_vec |f| { xs.each(|x| f(*x)) };
5859
* assert_eq!(xs, ys);
5960
* ~~~
6061
*/
6162
#[inline(always)]
62-
pub fn to_vec<T>(iter: &fn(f: &fn(T) -> bool)) -> ~[T] {
63+
pub fn iter_to_vec<T>(iter: &fn(f: &fn(T) -> bool)) -> ~[T] {
6364
let mut v = ~[];
6465
for iter |x| { v.push(x) }
6566
v
@@ -184,9 +185,9 @@ mod tests {
184185
use prelude::*;
185186

186187
#[test]
187-
fn test_to_vec() {
188+
fn test_iter_to_vec() {
188189
let xs = ~[1, 2, 3];
189-
let ys = do to_vec |f| { xs.each(|x| f(*x)) };
190+
let ys = do iter_to_vec |f| { xs.each(|x| f(*x)) };
190191
assert_eq!(xs, ys);
191192
}
192193

branches/try2/src/libcore/iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ mod tests {
378378
#[test]
379379
fn test_counter_to_vec() {
380380
let mut it = Counter::new(0, 5).take(10);
381-
let xs = iter::to_vec(|f| it.advance(f));
381+
let xs = iter::iter_to_vec(|f| it.advance(f));
382382
assert_eq!(xs, ~[0, 5, 10, 15, 20, 25, 30, 35, 40, 45]);
383383
}
384384

branches/try2/src/libcore/rt/io/extensions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! Utility mixins that apply to all Readers and Writers
1212
1313
// XXX: Not sure how this should be structured
14-
// XXX: Iteration should probably be considered separately
14+
// XXX: Iteration should probably be considered seperately
1515

1616
pub trait ReaderUtil {
1717

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ unsafe fn get_newsched_local_map(local: *mut LocalStorage) -> TaskLocalMap {
133133

134134
unsafe fn key_to_key_value<T: 'static>(key: LocalDataKey<T>) -> *libc::c_void {
135135
// Keys are closures, which are (fnptr,envptr) pairs. Use fnptr.
136-
// Use reinterpret_cast -- transmute would leak (forget) the closure.
136+
// Use reintepret_cast -- transmute would leak (forget) the closure.
137137
let pair: (*libc::c_void, *libc::c_void) = cast::transmute_copy(&key);
138138
pair.first()
139139
}

branches/try2/src/libcore/unstable/intrinsics.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ pub extern "rust-intrinsic" {
4444

4545
pub fn init<T>() -> T;
4646

47-
#[cfg(not(stage0))]
48-
pub unsafe fn uninit<T>() -> T;
49-
5047
pub fn forget<T>(_: T) -> ();
5148

5249
pub fn needs_drop<T>() -> bool;

branches/try2/src/libcore/vec.rs

Lines changed: 6 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ pub fn build<A>(builder: &fn(push: &fn(v: A))) -> ~[A] {
219219
* # Arguments
220220
*
221221
* * size - An option, maybe containing initial size of the vector to reserve
222-
* * builder - A function that will construct the vector. It receives
222+
* * builder - A function that will construct the vector. It recieves
223223
* as an argument a function that will push an element
224224
* onto the vector being constructed.
225225
*/
@@ -584,29 +584,14 @@ pub fn consume_reverse<T>(mut v: ~[T], f: &fn(uint, v: T)) {
584584
}
585585
586586
/// Remove the last element from a vector and return it
587-
#[cfg(not(stage0))]
588-
pub fn pop<T>(v: &mut ~[T]) -> T {
589-
let ln = v.len();
590-
if ln == 0 {
591-
fail!(~"sorry, cannot vec::pop an empty vector")
592-
}
593-
let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]);
594-
unsafe {
595-
let mut val = intrinsics::uninit();
596-
val <-> *valptr;
597-
raw::set_len(v, ln - 1u);
598-
val
599-
}
600-
}
601-
602-
#[cfg(stage0)]
603587
pub fn pop<T>(v: &mut ~[T]) -> T {
604588
let ln = v.len();
605589
if ln == 0 {
606590
fail!(~"sorry, cannot vec::pop an empty vector")
607591
}
608592
let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]);
609593
unsafe {
594+
// FIXME #4204: Should be uninit() - we don't need this zeroed
610595
let mut val = intrinsics::init();
611596
val <-> *valptr;
612597
raw::set_len(v, ln - 1u);
@@ -675,30 +660,13 @@ pub fn push_all<T:Copy>(v: &mut ~[T], rhs: &const [T]) {
675660
}
676661
677662
#[inline(always)]
678-
#[cfg(not(stage0))]
679-
pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) {
680-
let new_len = v.len() + rhs.len();
681-
reserve(&mut *v, new_len);
682-
unsafe {
683-
do as_mut_buf(rhs) |p, len| {
684-
for uint::range(0, len) |i| {
685-
let mut x = intrinsics::uninit();
686-
x <-> *ptr::mut_offset(p, i);
687-
push(&mut *v, x);
688-
}
689-
}
690-
raw::set_len(&mut rhs, 0);
691-
}
692-
}
693-
694-
#[inline(always)]
695-
#[cfg(stage0)]
696663
pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) {
697664
let new_len = v.len() + rhs.len();
698665
reserve(&mut *v, new_len);
699666
unsafe {
700667
do as_mut_buf(rhs) |p, len| {
701668
for uint::range(0, len) |i| {
669+
// FIXME #4204 Should be uninit() - don't need to zero
702670
let mut x = intrinsics::init();
703671
x <-> *ptr::mut_offset(p, i);
704672
push(&mut *v, x);
@@ -709,29 +677,13 @@ pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) {
709677
}
710678
711679
/// Shorten a vector, dropping excess elements.
712-
#[cfg(not(stage0))]
713-
pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
714-
do as_mut_buf(*v) |p, oldlen| {
715-
assert!(newlen <= oldlen);
716-
unsafe {
717-
// This loop is optimized out for non-drop types.
718-
for uint::range(newlen, oldlen) |i| {
719-
let mut dropped = intrinsics::uninit();
720-
dropped <-> *ptr::mut_offset(p, i);
721-
}
722-
}
723-
}
724-
unsafe { raw::set_len(&mut *v, newlen); }
725-
}
726-
727-
/// Shorten a vector, dropping excess elements.
728-
#[cfg(stage0)]
729680
pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
730681
do as_mut_buf(*v) |p, oldlen| {
731682
assert!(newlen <= oldlen);
732683
unsafe {
733684
// This loop is optimized out for non-drop types.
734685
for uint::range(newlen, oldlen) |i| {
686+
// FIXME #4204 Should be uninit() - don't need to zero
735687
let mut dropped = intrinsics::init();
736688
dropped <-> *ptr::mut_offset(p, i);
737689
}
@@ -744,45 +696,6 @@ pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
744696
* Remove consecutive repeated elements from a vector; if the vector is
745697
* sorted, this removes all duplicates.
746698
*/
747-
#[cfg(not(stage0))]
748-
pub fn dedup<T:Eq>(v: &mut ~[T]) {
749-
unsafe {
750-
if v.len() < 1 { return; }
751-
let mut last_written = 0, next_to_read = 1;
752-
do as_const_buf(*v) |p, ln| {
753-
// We have a mutable reference to v, so we can make arbitrary
754-
// changes. (cf. push and pop)
755-
let p = p as *mut T;
756-
// last_written < next_to_read <= ln
757-
while next_to_read < ln {
758-
// last_written < next_to_read < ln
759-
if *ptr::mut_offset(p, next_to_read) ==
760-
*ptr::mut_offset(p, last_written) {
761-
let mut dropped = intrinsics::uninit();
762-
dropped <-> *ptr::mut_offset(p, next_to_read);
763-
} else {
764-
last_written += 1;
765-
// last_written <= next_to_read < ln
766-
if next_to_read != last_written {
767-
*ptr::mut_offset(p, last_written) <->
768-
*ptr::mut_offset(p, next_to_read);
769-
}
770-
}
771-
// last_written <= next_to_read < ln
772-
next_to_read += 1;
773-
// last_written < next_to_read <= ln
774-
}
775-
}
776-
// last_written < next_to_read == ln
777-
raw::set_len(v, last_written + 1);
778-
}
779-
}
780-
781-
/**
782-
* Remove consecutive repeated elements from a vector; if the vector is
783-
* sorted, this removes all duplicates.
784-
*/
785-
#[cfg(stage0)]
786699
pub fn dedup<T:Eq>(v: &mut ~[T]) {
787700
unsafe {
788701
if v.len() < 1 { return; }
@@ -796,6 +709,8 @@ pub fn dedup<T:Eq>(v: &mut ~[T]) {
796709
// last_written < next_to_read < ln
797710
if *ptr::mut_offset(p, next_to_read) ==
798711
*ptr::mut_offset(p, last_written) {
712+
// FIXME #4204 Should be uninit() - don't need to
713+
// zero
799714
let mut dropped = intrinsics::init();
800715
dropped <-> *ptr::mut_offset(p, next_to_read);
801716
} else {

branches/try2/src/librustc/back/link.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,8 @@ pub fn exported_name(sess: Session,
698698
vers: &str) -> ~str {
699699
return mangle(sess,
700700
vec::append_one(
701-
vec::append_one(path, path_name(sess.ident_of(hash.to_owned()))),
702-
path_name(sess.ident_of(vers.to_owned()))));
701+
vec::append_one(path, path_name(sess.ident_of(hash))),
702+
path_name(sess.ident_of(vers))));
703703
}
704704
705705
pub fn mangle_exported_name(ccx: @CrateContext,
@@ -717,14 +717,14 @@ pub fn mangle_internal_name_by_type_only(ccx: @CrateContext,
717717
let s = ppaux::ty_to_short_str(ccx.tcx, t);
718718
let hash = get_symbol_hash(ccx, t);
719719
return mangle(ccx.sess,
720-
~[path_name(ccx.sess.ident_of(name.to_owned())),
720+
~[path_name(ccx.sess.ident_of(name)),
721721
path_name(ccx.sess.ident_of(s)),
722-
path_name(ccx.sess.ident_of(hash.to_owned()))]);
722+
path_name(ccx.sess.ident_of(hash))]);
723723
}
724724
725725
pub fn mangle_internal_name_by_path_and_seq(ccx: @CrateContext,
726726
path: path,
727-
flav: ~str) -> ~str {
727+
flav: &str) -> ~str {
728728
return mangle(ccx.sess,
729729
vec::append_one(path, path_name((ccx.names)(flav))));
730730
}
@@ -733,7 +733,7 @@ pub fn mangle_internal_name_by_path(ccx: @CrateContext, path: path) -> ~str {
733733
return mangle(ccx.sess, path);
734734
}
735735
736-
pub fn mangle_internal_name_by_seq(ccx: @CrateContext, flav: ~str) -> ~str {
736+
pub fn mangle_internal_name_by_seq(ccx: @CrateContext, flav: &str) -> ~str {
737737
return fmt!("%s_%u", flav, (ccx.names)(flav).repr);
738738
}
739739

0 commit comments

Comments
 (0)