Skip to content

Commit 62d838b

Browse files
committed
---
yaml --- r: 140651 b: refs/heads/try2 c: f547a67 h: refs/heads/master i: 140649: e13a3da 140647: 15e157e v: v3
1 parent 6930028 commit 62d838b

File tree

27 files changed

+332
-115
lines changed

27 files changed

+332
-115
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: e18ed77b720b46cc8ae0e6754698c47f51bed9a0
8+
refs/heads/try2: f547a671dcc64530f0cf07f39698d63174f37733
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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
{

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/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: 90 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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 {

branches/try2/src/librustc/middle/lint.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ pub fn get_lint_dict() -> LintDict {
237237
return @map;
238238
}
239239

240+
pub fn get_lint_name(lint_mode: lint) -> ~str {
241+
for lint_table.each |&(name, spec)| {
242+
if spec.lint == lint_mode {
243+
return name.to_str();
244+
}
245+
}
246+
fail!();
247+
}
240248
// This is a highly not-optimal set of data structure decisions.
241249
type LintModes = @mut SmallIntMap<level>;
242250
type LintModeMap = @mut HashMap<ast::node_id, LintModes>;

branches/try2/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]);

branches/try2/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,

branches/try2/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" => {

branches/try2/src/libstd/arc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ mod tests {
498498

499499
let arc_v = p.recv();
500500

501-
let v = *arc::get::<~[int]>(&arc_v);
501+
let v = copy *arc::get::<~[int]>(&arc_v);
502502
assert!(v[3] == 4);
503503
};
504504

branches/try2/src/libstd/future.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ mod test {
238238
239239
#[test]
240240
fn test_sendable_future() {
241-
let expected = ~"schlorf";
242-
let f = Cell(do spawn { copy expected });
241+
let expected = "schlorf";
242+
let f = Cell(do spawn { expected });
243243
do task::spawn {
244244
let mut f = f.take();
245245
let actual = f.get();

0 commit comments

Comments
 (0)