Skip to content

Commit 0599929

Browse files
committed
Finally removing all uses of by-mut-ref
The code for the mode itself is still there.
1 parent 688a920 commit 0599929

File tree

5 files changed

+6
-209
lines changed

5 files changed

+6
-209
lines changed

src/libcore/at_vec.rs

-18
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ extern mod rustrt {
2121
#[abi = "rust-intrinsic"]
2222
extern mod rusti {
2323
#[legacy_exports];
24-
#[cfg(stage0)]
25-
fn move_val_init<T>(&dst: T, -src: T);
26-
#[cfg(stage1)]
27-
#[cfg(stage2)]
2824
fn move_val_init<T>(dst: &mut T, -src: T);
2925
}
3026

@@ -181,20 +177,6 @@ pub mod raw {
181177
}
182178
}
183179

184-
// This doesn't bother to make sure we have space.
185-
#[cfg(stage0)]
186-
#[inline(always)] // really pretty please
187-
pub unsafe fn push_fast<T>(v: &mut @[const T], initval: T) {
188-
let repr: **VecRepr = ::cast::reinterpret_cast(&v);
189-
let fill = (**repr).unboxed.fill;
190-
(**repr).unboxed.fill += sys::size_of::<T>();
191-
let p = addr_of(&((**repr).unboxed.data));
192-
let p = ptr::offset(p, fill) as *mut T;
193-
rusti::move_val_init(*p, move initval);
194-
}
195-
// This doesn't bother to make sure we have space.
196-
#[cfg(stage1)]
197-
#[cfg(stage2)]
198180
#[inline(always)] // really pretty please
199181
pub unsafe fn push_fast<T>(v: &mut @[const T], initval: T) {
200182
let repr: **VecRepr = ::cast::reinterpret_cast(&v);

src/libcore/vec.rs

-46
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ extern mod rustrt {
1818

1919
#[abi = "rust-intrinsic"]
2020
extern mod rusti {
21-
#[cfg(stage0)]
22-
fn move_val_init<T>(&dst: T, -src: T);
23-
#[cfg(stage1)]
24-
#[cfg(stage2)]
2521
fn move_val_init<T>(dst: &mut T, -src: T);
2622
}
2723

@@ -103,23 +99,6 @@ pub pure fn len<T>(v: &[const T]) -> uint {
10399
* Creates an immutable vector of size `n_elts` and initializes the elements
104100
* to the value returned by the function `op`.
105101
*/
106-
#[cfg(stage0)]
107-
pub pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> ~[T] {
108-
unsafe {
109-
let mut v = with_capacity(n_elts);
110-
do as_mut_buf(v) |p, _len| {
111-
let mut i: uint = 0u;
112-
while i < n_elts {
113-
rusti::move_val_init(*ptr::mut_offset(p, i), op(i));
114-
i += 1u;
115-
}
116-
}
117-
raw::set_len(&mut v, n_elts);
118-
return move v;
119-
}
120-
}
121-
#[cfg(stage1)]
122-
#[cfg(stage2)]
123102
pub pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> ~[T] {
124103
unsafe {
125104
let mut v = with_capacity(n_elts);
@@ -503,19 +482,6 @@ pub fn push<T>(v: &mut ~[T], initval: T) {
503482
}
504483
}
505484

506-
#[cfg(stage0)]
507-
// This doesn't bother to make sure we have space.
508-
#[inline(always)] // really pretty please
509-
unsafe fn push_fast<T>(v: &mut ~[T], initval: T) {
510-
let repr: **raw::VecRepr = ::cast::transmute(v);
511-
let fill = (**repr).unboxed.fill;
512-
(**repr).unboxed.fill += sys::size_of::<T>();
513-
let p = addr_of(&((**repr).unboxed.data));
514-
let p = ptr::offset(p, fill) as *mut T;
515-
rusti::move_val_init(*p, move initval);
516-
}
517-
#[cfg(stage1)]
518-
#[cfg(stage2)]
519485
// This doesn't bother to make sure we have space.
520486
#[inline(always)] // really pretty please
521487
unsafe fn push_fast<T>(v: &mut ~[T], initval: T) {
@@ -1793,18 +1759,6 @@ pub mod raw {
17931759
as_const_buf(v, |p, _len| *ptr::const_offset(p, i))
17941760
}
17951761

1796-
#[cfg(stage0)]
1797-
#[inline(always)]
1798-
pub unsafe fn init_elem<T>(v: &[mut T], i: uint, val: T) {
1799-
let mut box = Some(move val);
1800-
do as_mut_buf(v) |p, _len| {
1801-
let mut box2 = None;
1802-
box2 <-> box;
1803-
rusti::move_val_init(*ptr::mut_offset(p, i),
1804-
option::unwrap(move box2));
1805-
}
1806-
}
1807-
#[cfg(stage1)]
18081762
/**
18091763
* Unchecked vector index assignment. Does not drop the
18101764
* old value and hence is only suitable when the vector

src/libstd/arena.rs

-115
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ use libc::size_t;
3131

3232
#[abi = "rust-intrinsic"]
3333
extern mod rusti {
34-
#[cfg(stage0)]
35-
fn move_val_init<T>(&dst: T, -src: T);
36-
#[cfg(stage1)]
37-
#[cfg(stage2)]
3834
fn move_val_init<T>(dst: &mut T, -src: T);
3935
fn needs_drop<T>() -> bool;
4036
}
@@ -132,117 +128,6 @@ unsafe fn un_bitpack_tydesc_ptr(p: uint) -> (*TypeDesc, bool) {
132128
(reinterpret_cast(&(p & !1)), p & 1 == 1)
133129
}
134130

135-
// tjc: Can get rid of the duplication post-snapshot
136-
#[cfg(stage0)]
137-
// The duplication between the POD and non-POD functions is annoying.
138-
impl &Arena {
139-
// Functions for the POD part of the arena
140-
fn alloc_pod_grow(n_bytes: uint, align: uint) -> *u8 {
141-
// Allocate a new chunk.
142-
let chunk_size = at_vec::capacity(self.pod_head.data);
143-
let new_min_chunk_size = uint::max(n_bytes, chunk_size);
144-
self.chunks = @Cons(copy self.pod_head, self.chunks);
145-
self.pod_head =
146-
chunk(uint::next_power_of_two(new_min_chunk_size + 1u), true);
147-
148-
return self.alloc_pod_inner(n_bytes, align);
149-
}
150-
151-
#[inline(always)]
152-
fn alloc_pod_inner(n_bytes: uint, align: uint) -> *u8 {
153-
let head = &mut self.pod_head;
154-
155-
let start = round_up_to(head.fill, align);
156-
let end = start + n_bytes;
157-
if end > at_vec::capacity(head.data) {
158-
return self.alloc_pod_grow(n_bytes, align);
159-
}
160-
head.fill = end;
161-
162-
//debug!("idx = %u, size = %u, align = %u, fill = %u",
163-
// start, n_bytes, align, head.fill);
164-
165-
unsafe {
166-
ptr::offset(vec::raw::to_ptr(head.data), start)
167-
}
168-
}
169-
170-
#[inline(always)]
171-
fn alloc_pod<T>(op: fn() -> T) -> &self/T {
172-
unsafe {
173-
let tydesc = sys::get_type_desc::<T>();
174-
let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align);
175-
let ptr: *mut T = reinterpret_cast(&ptr);
176-
rusti::move_val_init(*ptr, op());
177-
return reinterpret_cast(&ptr);
178-
}
179-
}
180-
181-
// Functions for the non-POD part of the arena
182-
fn alloc_nonpod_grow(n_bytes: uint, align: uint) -> (*u8, *u8) {
183-
// Allocate a new chunk.
184-
let chunk_size = at_vec::capacity(self.head.data);
185-
let new_min_chunk_size = uint::max(n_bytes, chunk_size);
186-
self.chunks = @Cons(copy self.head, self.chunks);
187-
self.head =
188-
chunk(uint::next_power_of_two(new_min_chunk_size + 1u), false);
189-
190-
return self.alloc_nonpod_inner(n_bytes, align);
191-
}
192-
193-
#[inline(always)]
194-
fn alloc_nonpod_inner(n_bytes: uint, align: uint) -> (*u8, *u8) {
195-
let head = &mut self.head;
196-
197-
let tydesc_start = head.fill;
198-
let after_tydesc = head.fill + sys::size_of::<*TypeDesc>();
199-
let start = round_up_to(after_tydesc, align);
200-
let end = start + n_bytes;
201-
if end > at_vec::capacity(head.data) {
202-
return self.alloc_nonpod_grow(n_bytes, align);
203-
}
204-
head.fill = round_up_to(end, sys::pref_align_of::<*TypeDesc>());
205-
206-
//debug!("idx = %u, size = %u, align = %u, fill = %u",
207-
// start, n_bytes, align, head.fill);
208-
209-
unsafe {
210-
let buf = vec::raw::to_ptr(head.data);
211-
return (ptr::offset(buf, tydesc_start), ptr::offset(buf, start));
212-
}
213-
}
214-
215-
#[inline(always)]
216-
fn alloc_nonpod<T>(op: fn() -> T) -> &self/T {
217-
unsafe {
218-
let tydesc = sys::get_type_desc::<T>();
219-
let (ty_ptr, ptr) =
220-
self.alloc_nonpod_inner((*tydesc).size, (*tydesc).align);
221-
let ty_ptr: *mut uint = reinterpret_cast(&ty_ptr);
222-
let ptr: *mut T = reinterpret_cast(&ptr);
223-
// Write in our tydesc along with a bit indicating that it
224-
// has *not* been initialized yet.
225-
*ty_ptr = reinterpret_cast(&tydesc);
226-
// Actually initialize it
227-
rusti::move_val_init(*ptr, op());
228-
// Now that we are done, update the tydesc to indicate that
229-
// the object is there.
230-
*ty_ptr = bitpack_tydesc_ptr(tydesc, true);
231-
232-
return reinterpret_cast(&ptr);
233-
}
234-
}
235-
236-
// The external interface
237-
#[inline(always)]
238-
fn alloc<T>(op: fn() -> T) -> &self/T {
239-
if !rusti::needs_drop::<T>() {
240-
self.alloc_pod(op)
241-
} else { self.alloc_nonpod(op) }
242-
}
243-
}
244-
#[cfg(stage1)]
245-
#[cfg(stage2)]
246131
impl &Arena {
247132
// Functions for the POD part of the arena
248133
fn alloc_pod_grow(n_bytes: uint, align: uint) -> *u8 {

src/libstd/time.rs

+4-29
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,16 @@ use result::{Result, Ok, Err};
88
#[abi = "cdecl"]
99
extern mod rustrt {
1010
#[legacy_exports]
11-
#[cfg(stage0)]
12-
fn get_time(&sec: i64, &nsec: i32);
13-
#[cfg(stage1)]
14-
#[cfg(stage2)]
1511
fn get_time(sec: &mut i64, nsec: &mut i32);
1612

17-
#[cfg(stage0)]
18-
fn precise_time_ns(&ns: u64);
19-
#[cfg(stage1)]
20-
#[cfg(stage2)]
2113
fn precise_time_ns(ns: &mut u64);
2214

2315
fn rust_tzset();
2416
// FIXME: The i64 values can be passed by-val when #2064 is fixed.
2517
fn rust_gmtime(&&sec: i64, &&nsec: i32, &&result: Tm);
2618
fn rust_localtime(&&sec: i64, &&nsec: i32, &&result: Tm);
27-
fn rust_timegm(&&tm: Tm, &sec: i64);
28-
fn rust_mktime(&&tm: Tm, &sec: i64);
19+
fn rust_timegm(&&tm: Tm, sec: &mut i64);
20+
fn rust_mktime(&&tm: Tm, sec: &mut i64);
2921
}
3022

3123
/// A record specifying a time value in seconds and nanoseconds.
@@ -42,15 +34,6 @@ impl Timespec : Eq {
4234
* Returns the current time as a `timespec` containing the seconds and
4335
* nanoseconds since 1970-01-01T00:00:00Z.
4436
*/
45-
#[cfg(stage0)]
46-
pub fn get_time() -> Timespec {
47-
let mut sec = 0i64;
48-
let mut nsec = 0i32;
49-
rustrt::get_time(sec, nsec);
50-
return {sec: sec, nsec: nsec};
51-
}
52-
#[cfg(stage1)]
53-
#[cfg(stage2)]
5437
pub fn get_time() -> Timespec {
5538
let mut sec = 0i64;
5639
let mut nsec = 0i32;
@@ -63,14 +46,6 @@ pub fn get_time() -> Timespec {
6346
* Returns the current value of a high-resolution performance counter
6447
* in nanoseconds since an unspecified epoch.
6548
*/
66-
#[cfg(stage0)]
67-
pub fn precise_time_ns() -> u64 {
68-
let mut ns = 0u64;
69-
rustrt::precise_time_ns(ns);
70-
ns
71-
}
72-
#[cfg(stage1)]
73-
#[cfg(stage2)]
7449
pub fn precise_time_ns() -> u64 {
7550
let mut ns = 0u64;
7651
rustrt::precise_time_ns(&mut ns);
@@ -790,9 +765,9 @@ impl Tm {
790765
fn to_timespec() -> Timespec {
791766
let mut sec = 0i64;
792767
if self.tm_gmtoff == 0_i32 {
793-
rustrt::rust_timegm(self, sec);
768+
rustrt::rust_timegm(self, &mut sec);
794769
} else {
795-
rustrt::rust_mktime(self, sec);
770+
rustrt::rust_mktime(self, &mut sec);
796771
}
797772
{ sec: sec, nsec: self.tm_nsec }
798773
}

src/libsyntax/parse/parser.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,8 @@ impl parser {
570570

571571
fn parse_arg_mode() -> mode {
572572
if self.eat(token::BINOP(token::AND)) {
573-
self.warn(~"Obsolete syntax has no effect");
573+
self.span_fatal(copy self.last_span,
574+
~"Obsolete syntax has no effect");
574575
expl(by_mutbl_ref)
575576
} else if self.eat(token::BINOP(token::MINUS)) {
576577
expl(by_move)

0 commit comments

Comments
 (0)