@@ -1370,12 +1370,14 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
1370
1370
loop {
1371
1371
let mut was_updated_this_iteration = false ;
1372
1372
1373
- // Transmuting `*const T` <=> `*mut T` is just a pointer cast,
1374
- // which we might be able to merge with other ones later.
1373
+ // Transmuting between raw pointers is just a pointer cast so long as
1374
+ // they have the same metadata type (like `*const i32` <=> `*mut u64`
1375
+ // or `*mut [i32]` <=> `*const [u64]`), including the common special
1376
+ // case of `*const T` <=> `*mut T`.
1375
1377
if let Transmute = kind
1376
- && let ty :: RawPtr ( from_pointee , _ ) = from. kind ( )
1377
- && let ty :: RawPtr ( to_pointee , _ ) = to. kind ( )
1378
- && from_pointee == to_pointee
1378
+ && from. is_unsafe_ptr ( )
1379
+ && to. is_unsafe_ptr ( )
1380
+ && self . pointers_have_same_metadata ( from , to )
1379
1381
{
1380
1382
* kind = PtrToPtr ;
1381
1383
was_updated_this_iteration = true ;
@@ -1400,15 +1402,9 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
1400
1402
// Aggregate-then-Transmute can just transmute the original field value,
1401
1403
// so long as the bytes of a value from only from a single field.
1402
1404
if let Transmute = kind
1403
- && let Value :: Aggregate (
1404
- AggregateTy :: Def ( aggregate_did, aggregate_args) ,
1405
- variant_idx,
1406
- field_values,
1407
- ) = self . get ( value)
1408
- && let aggregate_ty =
1409
- self . tcx . type_of ( aggregate_did) . instantiate ( self . tcx , aggregate_args)
1405
+ && let Value :: Aggregate ( _aggregate_ty, variant_idx, field_values) = self . get ( value)
1410
1406
&& let Some ( ( field_idx, field_ty) ) =
1411
- self . value_is_all_in_one_field ( aggregate_ty , * variant_idx)
1407
+ self . value_is_all_in_one_field ( from , * variant_idx)
1412
1408
{
1413
1409
from = field_ty;
1414
1410
value = field_values[ field_idx. as_usize ( ) ] ;
0 commit comments