Skip to content

Commit f2678c7

Browse files
committed
---
yaml --- r: 35554 b: refs/heads/master c: 2f3d4f6 h: refs/heads/master v: v3
1 parent e0a541f commit f2678c7

File tree

14 files changed

+79
-376
lines changed

14 files changed

+79
-376
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: ebd9ad4d0446ac76bdbb0ada21e943ad0cbeef60
2+
refs/heads/master: 2f3d4f61817fcfe48c03990f94175258bdbcc0cb
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024

trunk/RELEASES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Version 0.5 (December 2012)
2828
* `use` statements now take crate-relative paths
2929

3030
* Improved support for language features
31-
* Trait constraints work in many scenarios
31+
* Trait inheritance is much more complete
3232
* More support for explicit self arguments in methods - `self`, `&self`
3333
`@self`, and `~self` all generally work as expected
3434
* Static methods work in more situations

trunk/doc/manual.css

Lines changed: 0 additions & 6 deletions
This file was deleted.

trunk/mk/docs.mk

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@ doc/rust.css: rust.css
3030
@$(call E, cp: $@)
3131
$(Q)cp -a $< $@ 2> /dev/null
3232

33-
doc/manual.css: manual.css
34-
@$(call E, cp: $@)
35-
$(Q)cp -a $< $@ 2> /dev/null
36-
3733
DOCS += doc/rust.html
38-
doc/rust.html: rust.md doc/version_info.html doc/rust.css doc/manual.css
34+
doc/rust.html: rust.md doc/version_info.html doc/rust.css
3935
@$(call E, pandoc: $@)
4036
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
4137
"$(CFG_PANDOC)" \
@@ -44,7 +40,6 @@ doc/rust.html: rust.md doc/version_info.html doc/rust.css doc/manual.css
4440
--number-sections \
4541
--from=markdown --to=html \
4642
--css=rust.css \
47-
--css=manual.css \
4843
--include-before-body=doc/version_info.html \
4944
--output=$@
5045
endif

trunk/src/libcore/uint-template.rs

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pub pure fn to_str_bytes<U>(neg: bool, num: T, radix: uint,
179179
f: fn(v: &[u8]) -> U) -> U {
180180

181181
#[inline(always)]
182-
fn digit(n: T) -> u8 {
182+
pure fn digit(n: T) -> u8 {
183183
if n <= 9u as T {
184184
n as u8 + '0' as u8
185185
} else if n <= 15u as T {
@@ -195,35 +195,27 @@ pub pure fn to_str_bytes<U>(neg: bool, num: T, radix: uint,
195195
// Worst case: 64-bit number, binary-radix, with
196196
// a leading negative sign = 65 bytes.
197197
let buf : [mut u8 * 65] = [mut 0u8, ..65];
198+
let len = buf.len();
198199

199-
// FIXME (#2649): post-snapshot, you can do this without the raw
200-
// pointers and unsafe bits, and the codegen will prove it's all
201-
// in-bounds, no extra cost.
202-
203-
unsafe {
204-
do vec::as_imm_buf(buf) |p, len| {
205-
let mp = p as *mut u8;
206-
let mut i = len;
207-
let mut n = num;
208-
let radix = radix as T;
209-
loop {
210-
i -= 1u;
211-
assert 0u < i && i < len;
212-
*ptr::mut_offset(mp, i) = digit(n % radix);
213-
n /= radix;
214-
if n == 0 as T { break; }
215-
}
216-
217-
assert 0u < i && i < len;
218-
219-
if neg {
220-
i -= 1u;
221-
*ptr::mut_offset(mp, i) = '-' as u8;
222-
}
223-
224-
vec::raw::buf_as_slice(ptr::offset(p, i), len - i, f)
225-
}
200+
let mut i = len;
201+
let mut n = num;
202+
let radix = radix as T;
203+
loop {
204+
i -= 1u;
205+
assert 0u < i && i < len;
206+
buf[i] = digit(n % radix);
207+
n /= radix;
208+
if n == 0 as T { break; }
209+
}
210+
211+
assert 0u < i && i < len;
212+
213+
if neg {
214+
i -= 1u;
215+
buf[i] = '-' as u8;
226216
}
217+
218+
f(vec::view(buf, i, len))
227219
}
228220

229221
/// Convert to a string

trunk/src/libcore/vec.rs

Lines changed: 28 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ extern mod rustrt {
2929
#[abi = "rust-intrinsic"]
3030
extern mod rusti {
3131
fn move_val_init<T>(dst: &mut T, -src: T);
32-
fn init<T>() -> T;
3332
}
3433

3534

@@ -399,51 +398,28 @@ pub fn rsplitn<T: Copy>(v: &[T], n: uint, f: fn(t: &T) -> bool) -> ~[~[T]] {
399398
// Mutators
400399

401400
/// Removes the first element from a vector and return it
402-
pub fn shift<T>(v: &mut ~[T]) -> T unsafe {
403-
404-
assert v.is_not_empty();
405-
406-
if v.len() == 1 { return v.pop() }
407-
408-
if v.len() == 2 {
409-
let last = v.pop();
410-
let first = v.pop();
411-
v.push(last);
412-
return first;
413-
}
414-
401+
pub fn shift<T>(v: &mut ~[T]) -> T {
415402
let ln = v.len();
416-
let next_ln = v.len() - 1;
417-
418-
// Save the last element. We're going to overwrite its position
419-
let mut work_elt = v.pop();
420-
// We still should have room to work where what last element was
421-
assert capacity(v) >= ln;
422-
// Pretend like we have the original length so we can use
423-
// the vector memcpy to overwrite the hole we just made
424-
raw::set_len(v, ln);
425-
426-
// Memcopy the head element (the one we want) to the location we just
427-
// popped. For the moment it unsafely exists at both the head and last
428-
// positions
429-
let first_slice = view(*v, 0, 1);
430-
let last_slice = mut_view(*v, next_ln, ln);
431-
raw::memcpy(last_slice, first_slice, 1);
403+
assert (ln > 0);
432404

433-
// Memcopy everything to the left one element
434-
let init_slice = mut_view(*v, 0, next_ln);
435-
let tail_slice = view(*v, 1, ln);
436-
raw::memcpy(init_slice, tail_slice, next_ln);
437-
438-
// Set the new length. Now the vector is back to normal
439-
raw::set_len(v, next_ln);
405+
let mut vv = ~[];
406+
*v <-> vv;
440407

441-
// Swap out the element we want from the end
442-
let vp = raw::to_mut_ptr(*v);
443-
let vp = ptr::mut_offset(vp, next_ln - 1);
444-
*vp <-> work_elt;
408+
unsafe {
409+
let mut rr;
410+
{
411+
let vv = raw::to_ptr(vv);
412+
rr = move *vv;
413+
414+
for uint::range(1, ln) |i| {
415+
let r = move *ptr::offset(vv, i);
416+
v.push(r);
417+
}
418+
}
419+
raw::set_len(&mut vv, 0);
445420

446-
return work_elt;
421+
rr
422+
}
447423
}
448424

449425
/// Prepend an element to the vector
@@ -484,15 +460,9 @@ pub fn remove<T>(v: &mut ~[T], i: uint) -> T {
484460
pub fn consume<T>(v: ~[T], f: fn(uint, v: T)) unsafe {
485461
let mut v = v; // FIXME(#3488)
486462

487-
do as_mut_buf(v) |p, ln| {
463+
do as_imm_buf(v) |p, ln| {
488464
for uint::range(0, ln) |i| {
489-
// NB: This unsafe operation counts on init writing 0s to the
490-
// holes we create in the vector. That ensures that, if the
491-
// iterator fails then we won't try to clean up the consumed
492-
// elements during unwinding
493-
let mut x = rusti::init();
494-
let p = ptr::mut_offset(p, i);
495-
x <-> *p;
465+
let x = move *ptr::offset(p, i);
496466
f(i, x);
497467
}
498468
}
@@ -512,9 +482,7 @@ pub fn pop<T>(v: &mut ~[T]) -> T {
512482
}
513483
let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]);
514484
unsafe {
515-
// XXX: Should be rusti::uninit() - we don't need this zeroed
516-
let mut val = rusti::init();
517-
val <-> *valptr;
485+
let val = move *valptr;
518486
raw::set_len(v, ln - 1u);
519487
val
520488
}
@@ -583,11 +551,9 @@ pub fn push_all_move<T>(v: &mut ~[T], rhs: ~[T]) {
583551
let mut rhs = rhs; // FIXME(#3488)
584552
reserve(v, v.len() + rhs.len());
585553
unsafe {
586-
do as_mut_buf(rhs) |p, len| {
554+
do as_imm_buf(rhs) |p, len| {
587555
for uint::range(0, len) |i| {
588-
// XXX Should be rusti::uninit() - don't need to zero
589-
let mut x = rusti::init();
590-
x <-> *ptr::mut_offset(p, i);
556+
let x = move *ptr::offset(p, i);
591557
push(v, x);
592558
}
593559
}
@@ -597,14 +563,12 @@ pub fn push_all_move<T>(v: &mut ~[T], rhs: ~[T]) {
597563

598564
/// Shorten a vector, dropping excess elements.
599565
pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
600-
do as_mut_buf(*v) |p, oldlen| {
566+
do as_imm_buf(*v) |p, oldlen| {
601567
assert(newlen <= oldlen);
602568
unsafe {
603569
// This loop is optimized out for non-drop types.
604570
for uint::range(newlen, oldlen) |i| {
605-
// XXX Should be rusti::uninit() - don't need to zero
606-
let mut dropped = rusti::init();
607-
dropped <-> *ptr::mut_offset(p, i);
571+
let _dropped = move *ptr::offset(p, i);
608572
}
609573
raw::set_len(v, newlen);
610574
}
@@ -627,14 +591,12 @@ pub fn dedup<T: Eq>(v: &mut ~[T]) unsafe {
627591
// last_written < next_to_read < ln
628592
if *ptr::mut_offset(p, next_to_read) ==
629593
*ptr::mut_offset(p, last_written) {
630-
// XXX Should be rusti::uninit() - don't need to zero
631-
let mut dropped = rusti::init();
632-
dropped <-> *ptr::mut_offset(p, next_to_read);
594+
let _dropped = move *ptr::mut_offset(p, next_to_read);
633595
} else {
634596
last_written += 1;
635597
// last_written <= next_to_read < ln
636598
if next_to_read != last_written {
637-
*ptr::mut_offset(p, last_written) <->
599+
*ptr::mut_offset(p, last_written) = move
638600
*ptr::mut_offset(p, next_to_read);
639601
}
640602
}
@@ -1798,7 +1760,7 @@ pub struct UnboxedVecRepr {
17981760
}
17991761

18001762
/// Unsafe operations
1801-
pub mod raw {
1763+
mod raw {
18021764

18031765
/// The internal representation of a (boxed) vector
18041766
pub struct VecRepr {

0 commit comments

Comments
 (0)