Skip to content

Commit 7afb8b6

Browse files
committed
---
yaml --- r: 13367 b: refs/heads/master c: 7a74545 h: refs/heads/master i: 13365: 4dbb55c 13363: 4782919 13359: afaa180 v: v3
1 parent e47ef35 commit 7afb8b6

File tree

7 files changed

+13
-32
lines changed

7 files changed

+13
-32
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: f12adcbf930122ef6d98790b53d80d511dc62406
2+
refs/heads/master: 7a74545e9717ab0e85ab154e06810007b1de602f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/libcore/str.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ Fails if invalid UTF-8
137137
pure fn from_byte(b: u8) -> str unsafe {
138138
assert b < 128u8;
139139
let mut v = [b, 0u8];
140-
let s: str = ::unsafe::reinterpret_cast(v);
141-
::unsafe::forget(v);
142-
s
140+
::unsafe::transmute(v)
143141
}
144142

145143
#[doc = "Appends a character at the end of a string"]
@@ -324,8 +322,7 @@ The result vector is not null-terminated.
324322
"]
325323
pure fn bytes(s: str) -> [u8] unsafe {
326324
let mut s_copy = s;
327-
let mut v: [u8] = ::unsafe::reinterpret_cast(s_copy);
328-
::unsafe::forget(s_copy);
325+
let mut v: [u8] = ::unsafe::transmute(s_copy);
329326
vec::unsafe::set_len(v, len(s));
330327
ret v;
331328
}
@@ -1708,9 +1705,7 @@ mod unsafe {
17081705
v += [0u8];
17091706

17101707
assert is_utf8(v);
1711-
let s: str = ::unsafe::reinterpret_cast(v);
1712-
::unsafe::forget(v);
1713-
ret s;
1708+
ret ::unsafe::transmute(v);
17141709
}
17151710

17161711
#[doc = "Create a Rust string from a null-terminated C string"]
@@ -1732,9 +1727,7 @@ mod unsafe {
17321727
"]
17331728
unsafe fn from_bytes(v: [const u8]) -> str unsafe {
17341729
let vcopy = v + [0u8];
1735-
let scopy: str = ::unsafe::reinterpret_cast(vcopy);
1736-
::unsafe::forget(vcopy);
1737-
ret scopy;
1730+
ret ::unsafe::transmute(vcopy);
17381731
}
17391732

17401733
#[doc = "
@@ -1769,9 +1762,7 @@ mod unsafe {
17691762
v
17701763
};
17711764
v += [0u8];
1772-
let s: str = ::unsafe::reinterpret_cast(v);
1773-
::unsafe::forget(v);
1774-
ret s;
1765+
ret ::unsafe::transmute(v);
17751766
}
17761767

17771768
#[doc = "Appends a byte to a string. (Not UTF-8 safe)."]

trunk/src/libcore/task.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -979,13 +979,12 @@ fn test_unkillable() unsafe {
979979

980980
unkillable {||
981981
let p = ~0;
982-
let pp: *uint = unsafe::reinterpret_cast(p);
983-
unsafe::forget(p);
982+
let pp: *uint = unsafe::transmute(p);
984983

985984
// If we are killed here then the box will leak
986985
po.recv();
987986

988-
let _p: ~int = unsafe::reinterpret_cast(pp);
987+
let _p: ~int = unsafe::transmute(pp);
989988
}
990989

991990
// Now we can be killed

trunk/src/libcore/vec.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,16 +193,12 @@ pure fn from_elem<T: copy>(n_elts: uint, t: T) -> [T] {
193193

194194
#[doc = "Produces a mut vector from an immutable vector."]
195195
fn to_mut<T>(+v: [T]) -> [mut T] unsafe {
196-
let r = ::unsafe::reinterpret_cast(v);
197-
::unsafe::forget(v);
198-
r
196+
::unsafe::transmute(v)
199197
}
200198

201199
#[doc = "Produces an immutable vector from a mut vector."]
202200
fn from_mut<T>(+v: [mut T]) -> [T] unsafe {
203-
let r = ::unsafe::reinterpret_cast(v);
204-
::unsafe::forget(v);
205-
r
201+
::unsafe::transmute(v)
206202
}
207203

208204
// Accessors

trunk/src/libstd/arc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ type arc<T: const> = arc_destruct<T>;
4040
fn arc<T: const>(-data: T) -> arc<T> {
4141
let data = ~{mut count: 1, data: data};
4242
unsafe {
43-
let ptr = unsafe::reinterpret_cast(data);
44-
unsafe::forget(data);
43+
let ptr = unsafe::transmute(data);
4544
arc_destruct(ptr)
4645
}
4746
}

trunk/src/libstd/rope.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -817,9 +817,7 @@ mod node {
817817
}
818818
}
819819
}
820-
let str : str = unsafe::reinterpret_cast(buf);
821-
unsafe::forget(buf);//TODO: Check if this is correct
822-
ret str;
820+
ret unsafe::transmute(buf);
823821
}
824822

825823
#[doc ="

trunk/src/rustc/middle/trans/debuginfo.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ enum debug_metadata {
130130

131131
fn cast_safely<T: copy, U>(val: T) -> U unsafe {
132132
let val2 = val;
133-
let val3 = unsafe::reinterpret_cast(val2);
134-
unsafe::forget(val2);
135-
ret val3;
133+
ret unsafe::transmute(val2);
136134
}
137135

138136
fn md_from_metadata<T>(val: debug_metadata) -> T unsafe {

0 commit comments

Comments
 (0)