Skip to content

Commit 858e160

Browse files
committed
---
yaml --- r: 55715 b: refs/heads/master c: 0e017ab h: refs/heads/master i: 55713: 3e30bdb 55711: 05f9437 v: v3
1 parent 802378e commit 858e160

File tree

28 files changed

+142
-461
lines changed

28 files changed

+142
-461
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: df61ec2da6c4bb6e77ec15d0e5a60e4122b79d75
2+
refs/heads/master: 0e017ab4e0d59c82109604fa1917abd66b72e0e0
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 79a2b2eafc3c766cecec8a5f76317693bae9ed17
55
refs/heads/try: 8eb2bab100b42f0ba751552d8eff00eb2134c55a

trunk/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+
}

trunk/src/libcore/char.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -234,21 +234,6 @@ pub fn escape_default(c: char) -> ~str {
234234
}
235235
}
236236

237-
/// Returns the amount of bytes this character would need if encoded in utf8
238-
pub fn len_utf8_bytes(c: char) -> uint {
239-
static max_one_b: uint = 128u;
240-
static max_two_b: uint = 2048u;
241-
static max_three_b: uint = 65536u;
242-
static max_four_b: uint = 2097152u;
243-
244-
let code = c as uint;
245-
if code < max_one_b { 1u }
246-
else if code < max_two_b { 2u }
247-
else if code < max_three_b { 3u }
248-
else if code < max_four_b { 4u }
249-
else { fail!(~"invalid character!") }
250-
}
251-
252237
/**
253238
* Compare two chars
254239
*
@@ -349,6 +334,7 @@ fn test_escape_default() {
349334
assert_eq!(escape_default('\U0001d4b6'), ~"\\U0001d4b6");
350335
}
351336
337+
352338
#[test]
353339
fn test_escape_unicode() {
354340
assert_eq!(escape_unicode('\x00'), ~"\\x00");

trunk/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
};

trunk/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
}

trunk/src/libcore/prelude.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,9 @@ pub use path::Path;
4040
pub use path::PosixPath;
4141
pub use path::WindowsPath;
4242
pub use ptr::Ptr;
43-
// NOTE: Remove markers after snapshot
44-
#[cfg(stage1)]
45-
#[cfg(stage2)]
46-
#[cfg(stage3)]
47-
pub use str::{Ascii, AsciiCast, OwnedAsciiCast, ToStrAscii};
4843
pub use str::{StrSlice, OwnedStr};
4944
pub use to_bytes::IterBytes;
50-
pub use to_str::{ToStr, ToStrConsume};
45+
pub use to_str::ToStr;
5146
pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps};
5247
pub use vec::{CopyableVector, ImmutableVector};
5348
pub use vec::{ImmutableEqVector, ImmutableCopyableVector};

trunk/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));

trunk/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
}

trunk/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)