Skip to content

Commit c7d9969

Browse files
author
James Miller
committed
---
yaml --- r: 60150 b: refs/heads/master c: 5750970 h: refs/heads/master v: v3
1 parent c8f7b2d commit c7d9969

38 files changed

+254
-48
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: ca95e7f94ed7b9f793a061bd0a7cc4d74de6b10d
2+
refs/heads/master: 57509709b4ecc31b04b765bd07cd5fe672667e43
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
55
refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589

trunk/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;

trunk/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
*/

trunk/src/libcore/cast.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ 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)]
2741
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
2842
let mut dest: U = unstable::intrinsics::init();
2943
{

trunk/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

trunk/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

trunk/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

trunk/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
}

trunk/src/libcore/unstable/intrinsics.rs

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

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

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

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

trunk/src/libcore/vec.rs

Lines changed: 91 additions & 6 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,14 +584,29 @@ 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)]
587603
pub fn pop<T>(v: &mut ~[T]) -> T {
588604
let ln = v.len();
589605
if ln == 0 {
590606
fail!(~"sorry, cannot vec::pop an empty vector")
591607
}
592608
let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]);
593609
unsafe {
594-
// FIXME #4204: Should be uninit() - we don't need this zeroed
595610
let mut val = intrinsics::init();
596611
val <-> *valptr;
597612
raw::set_len(v, ln - 1u);
@@ -660,13 +675,30 @@ pub fn push_all<T:Copy>(v: &mut ~[T], rhs: &const [T]) {
660675
}
661676
662677
#[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)]
663696
pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) {
664697
let new_len = v.len() + rhs.len();
665698
reserve(&mut *v, new_len);
666699
unsafe {
667700
do as_mut_buf(rhs) |p, len| {
668701
for uint::range(0, len) |i| {
669-
// FIXME #4204 Should be uninit() - don't need to zero
670702
let mut x = intrinsics::init();
671703
x <-> *ptr::mut_offset(p, i);
672704
push(&mut *v, x);
@@ -677,13 +709,29 @@ pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) {
677709
}
678710
679711
/// 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)]
680729
pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
681730
do as_mut_buf(*v) |p, oldlen| {
682731
assert!(newlen <= oldlen);
683732
unsafe {
684733
// This loop is optimized out for non-drop types.
685734
for uint::range(newlen, oldlen) |i| {
686-
// FIXME #4204 Should be uninit() - don't need to zero
687735
let mut dropped = intrinsics::init();
688736
dropped <-> *ptr::mut_offset(p, i);
689737
}
@@ -696,6 +744,45 @@ pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
696744
* Remove consecutive repeated elements from a vector; if the vector is
697745
* sorted, this removes all duplicates.
698746
*/
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)]
699786
pub fn dedup<T:Eq>(v: &mut ~[T]) {
700787
unsafe {
701788
if v.len() < 1 { return; }
@@ -709,8 +796,6 @@ pub fn dedup<T:Eq>(v: &mut ~[T]) {
709796
// last_written < next_to_read < ln
710797
if *ptr::mut_offset(p, next_to_read) ==
711798
*ptr::mut_offset(p, last_written) {
712-
// FIXME #4204 Should be uninit() - don't need to
713-
// zero
714799
let mut dropped = intrinsics::init();
715800
dropped <-> *ptr::mut_offset(p, next_to_read);
716801
} else {

trunk/src/librustc/middle/trans/foreign.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,9 @@ pub fn trans_intrinsic(ccx: @CrateContext,
715715
Store(bcx, C_null(lltp_ty), fcx.llretptr.get());
716716
}
717717
}
718+
~"uninit" => {
719+
// Do nothing, this is effectively a no-op
720+
}
718721
~"forget" => {}
719722
~"transmute" => {
720723
let (in_type, out_type) = (substs.tys[0], substs.tys[1]);

trunk/src/librustc/middle/trans/machine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub fn nonzero_llsize_of(cx: @CrateContext, t: TypeRef) -> ValueRef {
8787
}
8888

8989
// Returns the preferred alignment of the given type for the current target.
90-
// The preferred alignment may be larger than the alignment used when
90+
// The preffered alignment may be larger than the alignment used when
9191
// packing the type into structs. This will be used for things like
9292
// allocations inside a stack frame, which LLVM has a free hand in.
9393
pub fn llalign_of_pref(cx: @CrateContext, t: TypeRef) -> uint {
@@ -96,7 +96,7 @@ pub fn llalign_of_pref(cx: @CrateContext, t: TypeRef) -> uint {
9696
}
9797
}
9898

99-
// Returns the minimum alignment of a type required by the platform.
99+
// Returns the minimum alignment of a type required by the plattform.
100100
// This is the alignment that will be used for struct fields, arrays,
101101
// and similar ABI-mandated things.
102102
pub fn llalign_of_min(cx: @CrateContext, t: TypeRef) -> uint {

trunk/src/librustc/middle/trans/type_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint)
118118
if abi.is_intrinsic() {
119119
let flags = match *cx.ccx.sess.str_of(i.ident) {
120120
~"size_of" | ~"pref_align_of" | ~"min_align_of" |
121-
~"init" | ~"transmute" | ~"move_val" |
121+
~"uninit" | ~"init" | ~"transmute" | ~"move_val" |
122122
~"move_val_init" => use_repr,
123123

124124
~"get_tydesc" | ~"needs_drop" => use_tydesc,

trunk/src/librustc/middle/typeck/check/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3447,6 +3447,7 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
34473447
~"size_of" |
34483448
~"pref_align_of" | ~"min_align_of" => (1u, ~[], ty::mk_uint()),
34493449
~"init" => (1u, ~[], param(ccx, 0u)),
3450+
~"uninit" => (1u, ~[], param(ccx, 0u)),
34503451
~"forget" => (1u, ~[arg(param(ccx, 0u))], ty::mk_nil()),
34513452
~"transmute" => (2, ~[ arg(param(ccx, 0)) ], param(ccx, 1)),
34523453
~"move_val" | ~"move_val_init" => {

trunk/src/librustc/middle/typeck/check/vtable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use syntax::print::pprust::expr_to_str;
3131
use syntax::visit;
3232

3333
// vtable resolution looks for places where trait bounds are
34-
// substituted in and figures out which vtable is used. There is some
34+
// subsituted in and figures out which vtable is used. There is some
3535
// extra complication thrown in to support early "opportunistic"
3636
// vtable resolution. This is a hacky mechanism that is invoked while
3737
// typechecking function calls (after typechecking non-closure

trunk/src/libstd/arena.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// calling the destructors on them.
2121
// One subtle point that needs to be addressed is how to handle
2222
// failures while running the user provided initializer function. It
23-
// is important to not run the destructor on uninitialized objects, but
23+
// is important to not run the destructor on uninitalized objects, but
2424
// how to detect them is somewhat subtle. Since alloc() can be invoked
2525
// recursively, it is not sufficient to simply exclude the most recent
2626
// object. To solve this without requiring extra space, we use the low

trunk/src/libstd/flatpipes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ or transformed to and from, byte vectors.
1515
1616
The `FlatPort` and `FlatChan` types implement the generic channel and
1717
port interface for arbitrary types and transport strategies. It can
18-
particularly be used to send and receive serializable types over I/O
18+
particularly be used to send and recieve serializable types over I/O
1919
streams.
2020
2121
`FlatPort` and `FlatChan` implement the same comm traits as pipe-based
@@ -55,7 +55,7 @@ use core::sys::size_of;
5555
use core::vec;
5656

5757
/**
58-
A FlatPort, consisting of a `BytePort` that receives byte vectors,
58+
A FlatPort, consisting of a `BytePort` that recieves byte vectors,
5959
and an `Unflattener` that converts the bytes to a value.
6060
6161
Create using the constructors in the `serial` and `pod` modules.
@@ -821,7 +821,7 @@ mod test {
821821
}
822822
}
823823
824-
// Receiver task
824+
// Reciever task
825825
do task::spawn || {
826826
// Wait for a connection
827827
let (conn, res_chan) = accept_port.recv();
@@ -840,7 +840,7 @@ mod test {
840840
841841
for int::range(0, 10) |i| {
842842
let j = port.recv();
843-
debug!("received %?", j);
843+
debug!("receieved %?", j);
844844
assert!(i == j);
845845
}
846846

0 commit comments

Comments
 (0)