🚨 fix unsoundness in bootstrap cache code
This commit is contained in:
parent
d137783642
commit
675fa0b3dd
@ -89,16 +89,16 @@ fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
|
||||
impl<T: Internable + Deref> Deref for Interned<T> {
|
||||
type Target = T::Target;
|
||||
fn deref(&self) -> &'static Self::Target {
|
||||
fn deref(&self) -> &Self::Target {
|
||||
let l = T::intern_cache().lock().unwrap();
|
||||
unsafe { mem::transmute::<&Self::Target, &'static Self::Target>(l.get(*self)) }
|
||||
unsafe { mem::transmute::<&Self::Target, &Self::Target>(l.get(*self)) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Internable + AsRef<U>, U: ?Sized> AsRef<U> for Interned<T> {
|
||||
fn as_ref(&self) -> &'static U {
|
||||
fn as_ref(&self) -> &U {
|
||||
let l = T::intern_cache().lock().unwrap();
|
||||
unsafe { mem::transmute::<&U, &'static U>(l.get(*self).as_ref()) }
|
||||
unsafe { mem::transmute::<&U, &U>(l.get(*self).as_ref()) }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user