Skip to content

Commit 1601879

Browse files
committed
Change transmute()s in IdxSet::{from_slice, from_slice_mut} to casts
1 parent ffdac5d commit 1601879

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/librustc_data_structures/indexed_set.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ impl<T: Idx> rustc_serialize::Decodable for IdxSetBuf<T> {
5959

6060
// pnkfelix wants to have this be `IdxSet<T>([Word]) and then pass
6161
// around `&mut IdxSet<T>` or `&IdxSet<T>`.
62-
//
63-
// WARNING: Mapping a `&IdxSetBuf<T>` to `&IdxSet<T>` (at least today)
64-
// requires a transmute relying on representation guarantees that may
65-
// not hold in the future.
6662

6763
/// Represents a set (or packed family of sets), of some element type
6864
/// E, where each E is identified by some unique index type `T`.
@@ -134,11 +130,11 @@ impl<T: Idx> IdxSetBuf<T> {
134130

135131
impl<T: Idx> IdxSet<T> {
136132
unsafe fn from_slice(s: &[Word]) -> &Self {
137-
mem::transmute(s) // (see above WARNING)
133+
&*(s as *const [Word] as *const Self)
138134
}
139135

140136
unsafe fn from_slice_mut(s: &mut [Word]) -> &mut Self {
141-
mem::transmute(s) // (see above WARNING)
137+
&mut *(s as *mut [Word] as *mut Self)
142138
}
143139
}
144140

0 commit comments

Comments
 (0)