File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
compiler/rustc_middle/src/query Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,8 @@ use crate::mir;
22use crate :: query:: CyclePlaceholder ;
33use crate :: traits;
44use crate :: ty:: { self , Ty } ;
5- use std:: mem:: { size_of, transmute_copy, MaybeUninit } ;
5+ use std:: mem:: { size_of, MaybeUninit } ;
6+ use std:: intrinsics:: transmute_unchecked;
67
78#[ derive( Copy , Clone ) ]
89pub struct Erased < T : Copy > {
@@ -30,7 +31,7 @@ pub fn erase<T: EraseType>(src: T) -> Erase<T> {
3031
3132 Erased :: < <T as EraseType >:: Result > {
3233 // SAFETY: It is safe to transmute to MaybeUninit for types with the same sizes.
33- data : unsafe { transmute_copy ( & src) } ,
34+ data : unsafe { transmute_unchecked :: < T , MaybeUninit < T :: Result > > ( src) } ,
3435 }
3536}
3637
@@ -41,7 +42,7 @@ pub fn restore<T: EraseType>(value: Erase<T>) -> T {
4142 // SAFETY: Due to the use of impl Trait in `Erase` the only way to safely create an instance
4243 // of `Erase` is to call `erase`, so we know that `value.data` is a valid instance of `T` of
4344 // the right size.
44- unsafe { transmute_copy ( & value. data ) }
45+ unsafe { transmute_unchecked :: < MaybeUninit < T :: Result > , T > ( value. data ) }
4546}
4647
4748impl < T > EraseType for & ' _ T {
You can’t perform that action at this time.
0 commit comments