Skip to content

Commit 54c83c2

Browse files
committed
---
yaml --- r: 140663 b: refs/heads/try2 c: e9d0018 h: refs/heads/master i: 140661: 4c6648b 140659: eb4c3c1 140655: 10be25b v: v3
1 parent 1e3d63f commit 54c83c2

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

+1011
-424
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: 1393c3a3f438c896083405dca501c8cf05767c65
8+
refs/heads/try2: e9d0018abf8dd0c692db4cfe8f5d1bd1c150d643
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<'self, T: Owned> Unique<T> {
160+
pub impl<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<'self, T: Owned> Unique<T> {
168168
}
169169
}
170170
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) }
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) }
174174
}
175175
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) }
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) }
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 seperately but to stdout only
767+
// to stdout and stderr separately 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 recieves
55+
* * builder - A function that will construct the vector. It receives
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 recieves
73+
* * builder - A function that will construct the vector. It receives
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 recieves
90+
* * builder - A function that will construct the vector. It receives
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: 20 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
{
@@ -108,6 +122,12 @@ pub unsafe fn copy_lifetime<'a,S,T>(_ptr: &'a S, ptr: &T) -> &'a T {
108122
transmute_region(ptr)
109123
}
110124

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+
111131
/// Transforms lifetime of the second pointer to match the first.
112132
#[inline(always)]
113133
pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T {

branches/try2/src/libcore/core.rc

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

63-
#[warn(vecs_implicitly_copyable)];
6463
#[deny(non_camel_case_types)];
6564
#[allow(deprecated_mutable_fields)];
6665

branches/try2/src/libcore/iter.rs

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

187186
#[test]
188-
fn test_iter_to_vec() {
187+
fn test_to_vec() {
189188
let xs = ~[1, 2, 3];
190-
let ys = do iter_to_vec |f| { xs.each(|x| f(*x)) };
189+
let ys = do to_vec |f| { xs.each(|x| f(*x)) };
191190
assert_eq!(xs, ys);
192191
}
193192

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::iter_to_vec(|f| it.advance(f));
381+
let xs = 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 seperately
14+
// XXX: Iteration should probably be considered separately
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 reintepret_cast -- transmute would leak (forget) the closure.
136+
// Use reinterpret_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: 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;

branches/try2/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 recieves
222+
* * builder - A function that will construct the vector. It receives
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 {

branches/try2/src/librustc/driver/session.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ pub impl Session_ {
237237
msg: &str) {
238238
let level = lint::get_lint_settings_level(
239239
self.lint_settings, lint_mode, expr_id, item_id);
240+
let msg = fmt!("%s [-W %s]", msg, lint::get_lint_name(lint_mode));
240241
self.span_lint_level(level, span, msg);
241242
}
242243
fn next_node_id(@self) -> ast::node_id {

0 commit comments

Comments
 (0)