@@ -17,7 +17,6 @@ use std::ffi::OsStr;
17
17
use std:: fmt;
18
18
use std:: hash:: { Hash , Hasher } ;
19
19
use std:: marker:: PhantomData ;
20
- use std:: mem;
21
20
use std:: ops:: Deref ;
22
21
use std:: path:: { Path , PathBuf } ;
23
22
use std:: sync:: Mutex ;
@@ -114,43 +113,47 @@ impl Deref for Interned<String> {
114
113
type Target = str ;
115
114
fn deref ( & self ) -> & ' static str {
116
115
let l = INTERNER . strs . lock ( ) . unwrap ( ) ;
117
- unsafe { mem:: transmute :: < & str , & ' static str > ( l. get ( * self ) ) }
116
+ let s: & str = l. get ( * self ) . as_ref ( ) ;
117
+ unsafe { & * ( s * const _) }
118
118
}
119
119
}
120
120
121
121
impl Deref for Interned < PathBuf > {
122
122
type Target = Path ;
123
123
fn deref ( & self ) -> & ' static Path {
124
124
let l = INTERNER . paths . lock ( ) . unwrap ( ) ;
125
- unsafe { mem:: transmute :: < & Path , & ' static Path > ( l. get ( * self ) ) }
125
+ let p: & Path = l. get ( * self ) . as_ref ( ) ;
126
+ unsafe { & * ( p * const _) }
126
127
}
127
128
}
128
129
129
130
impl AsRef < Path > for Interned < PathBuf > {
130
131
fn as_ref ( & self ) -> & ' static Path {
131
- let l = INTERNER . paths . lock ( ) . unwrap ( ) ;
132
- unsafe { mem:: transmute :: < & Path , & ' static Path > ( l. get ( * self ) ) }
132
+ & * self
133
133
}
134
134
}
135
135
136
136
impl AsRef < Path > for Interned < String > {
137
137
fn as_ref ( & self ) -> & ' static Path {
138
138
let l = INTERNER . strs . lock ( ) . unwrap ( ) ;
139
- unsafe { mem:: transmute :: < & Path , & ' static Path > ( l. get ( * self ) . as_ref ( ) ) }
139
+ let p: & Path = l. get ( * self ) . as_ref ( ) ;
140
+ unsafe { & * ( p * const _) }
140
141
}
141
142
}
142
143
143
144
impl AsRef < OsStr > for Interned < PathBuf > {
144
145
fn as_ref ( & self ) -> & ' static OsStr {
145
146
let l = INTERNER . paths . lock ( ) . unwrap ( ) ;
146
- unsafe { mem:: transmute :: < & OsStr , & ' static OsStr > ( l. get ( * self ) . as_ref ( ) ) }
147
+ let s: & OsStr = l. get ( * self ) . as_ref ( ) ;
148
+ unsafe { & * ( s * const _) }
147
149
}
148
150
}
149
151
150
152
impl AsRef < OsStr > for Interned < String > {
151
153
fn as_ref ( & self ) -> & ' static OsStr {
152
154
let l = INTERNER . strs . lock ( ) . unwrap ( ) ;
153
- unsafe { mem:: transmute :: < & OsStr , & ' static OsStr > ( l. get ( * self ) . as_ref ( ) ) }
155
+ let s: & OsStr = l. get ( * self ) . as_ref ( ) ;
156
+ unsafe { & * ( s * const _) }
154
157
}
155
158
}
156
159
0 commit comments