Skip to content

Commit 82089ba

Browse files
committed
---
yaml --- r: 72191 b: refs/heads/dist-snap c: 51a68eb h: refs/heads/master i: 72189: 36038d7 72187: 01d3df8 72183: b4d4db0 72175: b121c0e 72159: b12ff77 72127: 2c1ed41 72063: 79b0b28 71935: 1bbe313 71679: 4addab6 v: v3
1 parent 52a7b97 commit 82089ba

File tree

25 files changed

+127
-156
lines changed

25 files changed

+127
-156
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: b50030718cf28f2a5a81857a26b57442734fe854
10-
refs/heads/dist-snap: 3c2a44b60f472827884c868c527debbd7e61b054
10+
refs/heads/dist-snap: 51a68eb9b14f5d6f8ac358eed8c11e8567d5f87b
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libcore/at_vec.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub mod rustrt {
4141
pub fn capacity<T>(v: @[T]) -> uint {
4242
unsafe {
4343
let repr: **raw::VecRepr =
44-
::cast::reinterpret_cast(&addr_of(&v));
44+
::cast::transmute(addr_of(&v));
4545
(**repr).unboxed.alloc / sys::size_of::<T>()
4646
}
4747
}
@@ -208,7 +208,7 @@ pub mod raw {
208208
*/
209209
#[inline(always)]
210210
pub unsafe fn set_len<T>(v: @[T], new_len: uint) {
211-
let repr: **mut VecRepr = ::cast::reinterpret_cast(&addr_of(&v));
211+
let repr: **mut VecRepr = ::cast::transmute(addr_of(&v));
212212
(**repr).unboxed.fill = new_len * sys::size_of::<T>();
213213
}
214214

@@ -226,7 +226,7 @@ pub mod raw {
226226

227227
#[inline(always)] // really pretty please
228228
pub unsafe fn push_fast<T>(v: &mut @[T], initval: T) {
229-
let repr: **mut VecRepr = ::cast::reinterpret_cast(&v);
229+
let repr: **mut VecRepr = ::cast::transmute(v);
230230
let fill = (**repr).unboxed.fill;
231231
(**repr).unboxed.fill += sys::size_of::<T>();
232232
let p = addr_of(&((**repr).unboxed.data));
@@ -322,4 +322,4 @@ mod test {
322322
assert!(from_slice([@"abc", @"123"]) == @[@"abc", @"123"]);
323323
assert!(from_slice([@[42]]) == @[@[42]]);
324324
}
325-
}
325+
}

branches/dist-snap/src/libcore/gc.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ pub mod rustrt {
7777
}
7878

7979
unsafe fn bump<T, U>(ptr: *T, count: uint) -> *U {
80-
return cast::reinterpret_cast(&ptr::offset(ptr, count));
80+
return cast::transmute(ptr::offset(ptr, count));
8181
}
8282

8383
unsafe fn align_to_pointer<T>(ptr: *T) -> *T {
8484
let align = sys::min_align_of::<*T>();
85-
let ptr: uint = cast::reinterpret_cast(&ptr);
85+
let ptr: uint = cast::transmute(ptr);
8686
let ptr = (ptr + (align - 1)) & -align;
87-
return cast::reinterpret_cast(&ptr);
87+
return cast::transmute(ptr);
8888
}
8989

9090
unsafe fn get_safe_point_count() -> uint {
@@ -129,8 +129,8 @@ type Visitor<'self> = &'self fn(root: **Word, tydesc: *Word) -> bool;
129129
// Walks the list of roots for the given safe point, and calls visitor
130130
// on each root.
131131
unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) {
132-
let fp_bytes: *u8 = cast::reinterpret_cast(&fp);
133-
let sp_meta: *u32 = cast::reinterpret_cast(&sp.sp_meta);
132+
let fp_bytes: *u8 = cast::transmute(fp);
133+
let sp_meta: *u32 = cast::transmute(sp.sp_meta);
134134

135135
let num_stack_roots = *sp_meta as uint;
136136
let num_reg_roots = *ptr::offset(sp_meta, 1) as uint;
@@ -171,9 +171,9 @@ unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) {
171171

172172
// Is fp contained in segment?
173173
unsafe fn is_frame_in_segment(fp: *Word, segment: *StackSegment) -> bool {
174-
let begin: Word = cast::reinterpret_cast(&segment);
175-
let end: Word = cast::reinterpret_cast(&(*segment).end);
176-
let frame: Word = cast::reinterpret_cast(&fp);
174+
let begin: Word = cast::transmute(segment);
175+
let end: Word = cast::transmute((*segment).end);
176+
let frame: Word = cast::transmute(fp);
177177

178178
return begin <= frame && frame <= end;
179179
}
@@ -339,7 +339,7 @@ pub fn cleanup_stack_for_failure() {
339339
// own stack roots on the stack anyway.
340340
let sentinel_box = ~0;
341341
let sentinel: **Word = if expect_sentinel() {
342-
cast::reinterpret_cast(&ptr::addr_of(&sentinel_box))
342+
cast::transmute(ptr::addr_of(&sentinel_box))
343343
} else {
344344
ptr::null()
345345
};

branches/dist-snap/src/libcore/iterator.rs

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ pub trait IteratorUtil<A> {
3939
fn take_while<'r>(self, predicate: &'r fn(&A) -> bool) -> TakeWhileIterator<'r, A, Self>;
4040
fn skip(self, n: uint) -> SkipIterator<Self>;
4141
fn take(self, n: uint) -> TakeIterator<Self>;
42-
fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option<B>)
43-
-> ScanIterator<'r, A, B, Self, St>;
4442
fn advance(&mut self, f: &fn(A) -> bool);
4543
}
4644

@@ -95,12 +93,6 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
9593
TakeIterator{iter: self, n: n}
9694
}
9795

98-
#[inline(always)]
99-
fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option<B>)
100-
-> ScanIterator<'r, A, B, T, St> {
101-
ScanIterator{iter: self, f: f, state: initial_state}
102-
}
103-
10496
/// A shim implementing the `for` loop iteration protocol for iterator objects
10597
#[inline]
10698
fn advance(&mut self, f: &fn(A) -> bool) {
@@ -314,13 +306,12 @@ impl<A, T: Iterator<A>> Iterator<A> for TakeIterator<T> {
314306

315307
pub struct UnfoldrIterator<'self, A, St> {
316308
priv f: &'self fn(&mut St) -> Option<A>,
317-
state: St
309+
priv state: St
318310
}
319311

320312
pub impl<'self, A, St> UnfoldrIterator<'self, A, St> {
321313
#[inline]
322-
fn new(f: &'self fn(&mut St) -> Option<A>, initial_state: St)
323-
-> UnfoldrIterator<'self, A, St> {
314+
fn new(f: &'self fn(&mut St) -> Option<A>, initial_state: St) -> UnfoldrIterator<'self, A, St> {
324315
UnfoldrIterator {
325316
f: f,
326317
state: initial_state
@@ -335,19 +326,6 @@ impl<'self, A, St> Iterator<A> for UnfoldrIterator<'self, A, St> {
335326
}
336327
}
337328

338-
pub struct ScanIterator<'self, A, B, T, St> {
339-
priv iter: T,
340-
priv f: &'self fn(&mut St, A) -> Option<B>,
341-
state: St
342-
}
343-
344-
impl<'self, A, B, T: Iterator<A>, St> Iterator<B> for ScanIterator<'self, A, B, T, St> {
345-
#[inline]
346-
fn next(&mut self) -> Option<B> {
347-
self.iter.next().chain(|a| (self.f)(&mut self.state, a))
348-
}
349-
}
350-
351329
#[cfg(test)]
352330
mod tests {
353331
use super::*;
@@ -428,25 +406,6 @@ mod tests {
428406
assert_eq!(i, ys.len());
429407
}
430408

431-
#[test]
432-
fn test_iterator_scan() {
433-
// test the type inference
434-
fn add(old: &mut int, new: &uint) -> Option<float> {
435-
*old += *new as int;
436-
Some(*old as float)
437-
}
438-
let xs = [0u, 1, 2, 3, 4];
439-
let ys = [0f, 1f, 3f, 6f, 10f];
440-
441-
let mut it = xs.iter().scan(0, add);
442-
let mut i = 0;
443-
for it.advance |x| {
444-
assert_eq!(x, ys[i]);
445-
i += 1;
446-
}
447-
assert_eq!(i, ys.len());
448-
}
449-
450409
#[test]
451410
fn test_unfoldr() {
452411
fn count(st: &mut uint) -> Option<uint> {

branches/dist-snap/src/libcore/os.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,10 @@ pub fn getenv(n: &str) -> Option<~str> {
239239
unsafe {
240240
do with_env_lock {
241241
let s = str::as_c_str(n, |s| libc::getenv(s));
242-
if ptr::null::<u8>() == cast::reinterpret_cast(&s) {
242+
if ptr::null::<u8>() == cast::transmute(s) {
243243
option::None::<~str>
244244
} else {
245-
let s = cast::reinterpret_cast(&s);
245+
let s = cast::transmute(s);
246246
option::Some::<~str>(str::raw::from_buf(s))
247247
}
248248
}
@@ -644,7 +644,7 @@ pub fn make_dir(p: &Path, mode: c_int) -> bool {
644644
// FIXME: turn mode into something useful? #2623
645645
do as_utf16_p(p.to_str()) |buf| {
646646
libc::CreateDirectoryW(buf, unsafe {
647-
cast::reinterpret_cast(&0)
647+
cast::transmute(0)
648648
})
649649
!= (0 as libc::BOOL)
650650
}

branches/dist-snap/src/libcore/ptr.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ pub unsafe fn position<T>(buf: *T, f: &fn(&T) -> bool) -> uint {
8686

8787
/// Create an unsafe null pointer
8888
#[inline(always)]
89-
pub fn null<T>() -> *T { unsafe { cast::reinterpret_cast(&0u) } }
89+
pub fn null<T>() -> *T { unsafe { cast::transmute(0u) } }
9090

9191
/// Create an unsafe mutable null pointer
9292
#[inline(always)]
93-
pub fn mut_null<T>() -> *mut T { unsafe { cast::reinterpret_cast(&0u) } }
93+
pub fn mut_null<T>() -> *mut T { unsafe { cast::transmute(0u) } }
9494

9595
/// Returns true if the pointer is equal to the null pointer.
9696
#[inline(always)]
@@ -134,7 +134,7 @@ pub unsafe fn set_memory<T>(dst: *mut T, c: int, count: uint) {
134134
*/
135135
#[inline(always)]
136136
pub fn to_unsafe_ptr<T>(thing: &T) -> *T {
137-
unsafe { cast::reinterpret_cast(&thing) }
137+
unsafe { cast::transmute(thing) }
138138
}
139139

140140
/**
@@ -144,7 +144,7 @@ pub fn to_unsafe_ptr<T>(thing: &T) -> *T {
144144
*/
145145
#[inline(always)]
146146
pub fn to_const_unsafe_ptr<T>(thing: &const T) -> *const T {
147-
unsafe { cast::reinterpret_cast(&thing) }
147+
unsafe { cast::transmute(thing) }
148148
}
149149

150150
/**
@@ -154,7 +154,7 @@ pub fn to_const_unsafe_ptr<T>(thing: &const T) -> *const T {
154154
*/
155155
#[inline(always)]
156156
pub fn to_mut_unsafe_ptr<T>(thing: &mut T) -> *mut T {
157-
unsafe { cast::reinterpret_cast(&thing) }
157+
unsafe { cast::transmute(thing) }
158158
}
159159

160160
/**
@@ -167,7 +167,7 @@ pub fn to_mut_unsafe_ptr<T>(thing: &mut T) -> *mut T {
167167
#[inline(always)]
168168
pub fn to_uint<T>(thing: &T) -> uint {
169169
unsafe {
170-
cast::reinterpret_cast(&thing)
170+
cast::transmute(thing)
171171
}
172172
}
173173

@@ -259,8 +259,8 @@ impl<T> Eq for *const T {
259259
#[inline(always)]
260260
fn eq(&self, other: &*const T) -> bool {
261261
unsafe {
262-
let a: uint = cast::reinterpret_cast(&(*self));
263-
let b: uint = cast::reinterpret_cast(&(*other));
262+
let a: uint = cast::transmute(*self);
263+
let b: uint = cast::transmute(*other);
264264
return a == b;
265265
}
266266
}
@@ -274,32 +274,32 @@ impl<T> Ord for *const T {
274274
#[inline(always)]
275275
fn lt(&self, other: &*const T) -> bool {
276276
unsafe {
277-
let a: uint = cast::reinterpret_cast(&(*self));
278-
let b: uint = cast::reinterpret_cast(&(*other));
277+
let a: uint = cast::transmute(*self);
278+
let b: uint = cast::transmute(*other);
279279
return a < b;
280280
}
281281
}
282282
#[inline(always)]
283283
fn le(&self, other: &*const T) -> bool {
284284
unsafe {
285-
let a: uint = cast::reinterpret_cast(&(*self));
286-
let b: uint = cast::reinterpret_cast(&(*other));
285+
let a: uint = cast::transmute(*self);
286+
let b: uint = cast::transmute(*other);
287287
return a <= b;
288288
}
289289
}
290290
#[inline(always)]
291291
fn ge(&self, other: &*const T) -> bool {
292292
unsafe {
293-
let a: uint = cast::reinterpret_cast(&(*self));
294-
let b: uint = cast::reinterpret_cast(&(*other));
293+
let a: uint = cast::transmute(*self);
294+
let b: uint = cast::transmute(*other);
295295
return a >= b;
296296
}
297297
}
298298
#[inline(always)]
299299
fn gt(&self, other: &*const T) -> bool {
300300
unsafe {
301-
let a: uint = cast::reinterpret_cast(&(*self));
302-
let b: uint = cast::reinterpret_cast(&(*other));
301+
let a: uint = cast::transmute(*self);
302+
let b: uint = cast::transmute(*other);
303303
return a > b;
304304
}
305305
}
@@ -350,7 +350,7 @@ pub mod ptr_tests {
350350
struct Pair {mut fst: int, mut snd: int};
351351
let mut p = Pair {fst: 10, snd: 20};
352352
let pptr: *mut Pair = &mut p;
353-
let iptr: *mut int = cast::reinterpret_cast(&pptr);
353+
let iptr: *mut int = cast::transmute(pptr);
354354
assert!((*iptr == 10));;
355355
*iptr = 30;
356356
assert!((*iptr == 30));

branches/dist-snap/src/libcore/run.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn with_envp<T>(env: &Option<~[(~str,~str)]>,
147147
}
148148
ptrs.push(ptr::null());
149149
vec::as_imm_buf(ptrs, |p, _len|
150-
unsafe { cb(::cast::reinterpret_cast(&p)) }
150+
unsafe { cb(::cast::transmute(p)) }
151151
)
152152
}
153153
_ => cb(ptr::null())
@@ -167,12 +167,12 @@ fn with_envp<T>(env: &Option<~[(~str,~str)]>,
167167
for vec::each(*es) |e| {
168168
let (k,v) = copy *e;
169169
let t = fmt!("%s=%s", k, v);
170-
let mut v : ~[u8] = ::cast::reinterpret_cast(&t);
170+
let mut v : ~[u8] = ::cast::transmute(t);
171171
blk += v;
172172
::cast::forget(v);
173173
}
174174
blk += ~[0_u8];
175-
vec::as_imm_buf(blk, |p, _len| cb(::cast::reinterpret_cast(&p)))
175+
vec::as_imm_buf(blk, |p, _len| cb(::cast::transmute(p)))
176176
}
177177
_ => cb(ptr::null())
178178
}

branches/dist-snap/src/libcore/stackwalk.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#[doc(hidden)]; // FIXME #3538
1212

13-
use cast::reinterpret_cast;
13+
use cast::transmute;
1414

1515
pub type Word = uint;
1616

@@ -30,16 +30,16 @@ pub fn walk_stack(visit: &fn(Frame) -> bool) {
3030

3131
do frame_address |frame_pointer| {
3232
let mut frame_address: *Word = unsafe {
33-
reinterpret_cast(&frame_pointer)
33+
transmute(frame_pointer)
3434
};
3535
loop {
3636
let fr = Frame(frame_address);
3737

38-
debug!("frame: %x", unsafe { reinterpret_cast(&fr.fp) });
38+
debug!("frame: %x", unsafe { transmute(fr.fp) });
3939
visit(fr);
4040

4141
unsafe {
42-
let next_fp: **Word = reinterpret_cast(&frame_address);
42+
let next_fp: **Word = transmute(frame_address);
4343
frame_address = *next_fp;
4444
if *frame_address == 0u {
4545
debug!("encountered task_start_wrapper. ending walk");

0 commit comments

Comments
 (0)