File tree 1 file changed +4
-3
lines changed
compiler/rustc_middle/src/query
1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,8 @@ use crate::mir;
2
2
use crate :: query:: CyclePlaceholder ;
3
3
use crate :: traits;
4
4
use 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;
6
7
7
8
#[ derive( Copy , Clone ) ]
8
9
pub struct Erased < T : Copy > {
@@ -30,7 +31,7 @@ pub fn erase<T: EraseType>(src: T) -> Erase<T> {
30
31
31
32
Erased :: < <T as EraseType >:: Result > {
32
33
// 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) } ,
34
35
}
35
36
}
36
37
@@ -41,7 +42,7 @@ pub fn restore<T: EraseType>(value: Erase<T>) -> T {
41
42
// SAFETY: Due to the use of impl Trait in `Erase` the only way to safely create an instance
42
43
// of `Erase` is to call `erase`, so we know that `value.data` is a valid instance of `T` of
43
44
// the right size.
44
- unsafe { transmute_copy ( & value. data ) }
45
+ unsafe { transmute_unchecked :: < MaybeUninit < T :: Result > , T > ( value. data ) }
45
46
}
46
47
47
48
impl < T > EraseType for & ' _ T {
You can’t perform that action at this time.
0 commit comments