about summary refs log tree commit diff
diff options
context:
space:
mode:
authorljedrz <ljedrz@gmail.com>2018-08-09 16:59:10 +0200
committerljedrz <ljedrz@gmail.com>2018-08-09 19:50:12 +0200
commit160187937d679d78bfc36aa39c3cb36cc5024012 (patch)
treeba6303c268fbe26131e00535b804c95848227e98
parentffdac5d592194e7026d3e5fc03bce896c3086cd7 (diff)
downloadrust-160187937d679d78bfc36aa39c3cb36cc5024012.tar.gz
rust-160187937d679d78bfc36aa39c3cb36cc5024012.zip
Change transmute()s in IdxSet::{from_slice, from_slice_mut} to casts
-rw-r--r--src/librustc_data_structures/indexed_set.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/librustc_data_structures/indexed_set.rs b/src/librustc_data_structures/indexed_set.rs
index 2e95a45479c..46d6c65101a 100644
--- a/src/librustc_data_structures/indexed_set.rs
+++ b/src/librustc_data_structures/indexed_set.rs
@@ -59,10 +59,6 @@ impl<T: Idx> rustc_serialize::Decodable for IdxSetBuf<T> {
 
 // pnkfelix wants to have this be `IdxSet<T>([Word]) and then pass
 // around `&mut IdxSet<T>` or `&IdxSet<T>`.
-//
-// WARNING: Mapping a `&IdxSetBuf<T>` to `&IdxSet<T>` (at least today)
-// requires a transmute relying on representation guarantees that may
-// not hold in the future.
 
 /// Represents a set (or packed family of sets), of some element type
 /// E, where each E is identified by some unique index type `T`.
@@ -134,11 +130,11 @@ impl<T: Idx> IdxSetBuf<T> {
 
 impl<T: Idx> IdxSet<T> {
     unsafe fn from_slice(s: &[Word]) -> &Self {
-        mem::transmute(s) // (see above WARNING)
+        &*(s as *const [Word] as *const Self)
     }
 
     unsafe fn from_slice_mut(s: &mut [Word]) -> &mut Self {
-        mem::transmute(s) // (see above WARNING)
+        &mut *(s as *mut [Word] as *mut Self)
     }
 }