@@ -742,7 +742,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
742
742
{
743
743
// Recompute the safe transmute reason and use that for the error reporting
744
744
self . get_safe_transmute_error_and_reason (
745
- trait_predicate,
746
745
obligation. clone ( ) ,
747
746
trait_ref,
748
747
span,
@@ -1629,7 +1628,6 @@ trait InferCtxtPrivExt<'tcx> {
1629
1628
1630
1629
fn get_safe_transmute_error_and_reason (
1631
1630
& self ,
1632
- trait_predicate : ty:: Binder < ' tcx , ty:: TraitPredicate < ' tcx > > ,
1633
1631
obligation : Obligation < ' tcx , ty:: Predicate < ' tcx > > ,
1634
1632
trait_ref : ty:: Binder < ' tcx , ty:: TraitRef < ' tcx > > ,
1635
1633
span : Span ,
@@ -2921,18 +2919,20 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
2921
2919
2922
2920
fn get_safe_transmute_error_and_reason (
2923
2921
& self ,
2924
- trait_predicate : ty:: Binder < ' tcx , ty:: TraitPredicate < ' tcx > > ,
2925
2922
obligation : Obligation < ' tcx , ty:: Predicate < ' tcx > > ,
2926
2923
trait_ref : ty:: Binder < ' tcx , ty:: TraitRef < ' tcx > > ,
2927
2924
span : Span ,
2928
2925
) -> ( String , Option < String > ) {
2929
- let src_and_dst = trait_predicate. map_bound ( |p| rustc_transmute:: Types {
2930
- dst : p. trait_ref . substs . type_at ( 0 ) ,
2931
- src : p. trait_ref . substs . type_at ( 1 ) ,
2932
- } ) ;
2933
- let scope = trait_ref. skip_binder ( ) . substs . type_at ( 2 ) ;
2926
+ // Erase regions because layout code doesn't particularly care about regions.
2927
+ let trait_ref = self . tcx . erase_regions ( self . tcx . erase_late_bound_regions ( trait_ref) ) ;
2928
+
2929
+ let src_and_dst = rustc_transmute:: Types {
2930
+ dst : trait_ref. substs . type_at ( 0 ) ,
2931
+ src : trait_ref. substs . type_at ( 1 ) ,
2932
+ } ;
2933
+ let scope = trait_ref. substs . type_at ( 2 ) ;
2934
2934
let Some ( assume) =
2935
- rustc_transmute:: Assume :: from_const ( self . infcx . tcx , obligation. param_env , trait_ref. skip_binder ( ) . substs . const_at ( 3 ) ) else {
2935
+ rustc_transmute:: Assume :: from_const ( self . infcx . tcx , obligation. param_env , trait_ref. substs . const_at ( 3 ) ) else {
2936
2936
span_bug ! ( span, "Unable to construct rustc_transmute::Assume where it was previously possible" ) ;
2937
2937
} ;
2938
2938
match rustc_transmute:: TransmuteTypeEnv :: new ( self . infcx ) . is_transmutable (
@@ -2942,8 +2942,8 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
2942
2942
assume,
2943
2943
) {
2944
2944
rustc_transmute:: Answer :: No ( reason) => {
2945
- let dst = trait_ref. skip_binder ( ) . substs . type_at ( 0 ) ;
2946
- let src = trait_ref. skip_binder ( ) . substs . type_at ( 1 ) ;
2945
+ let dst = trait_ref. substs . type_at ( 0 ) ;
2946
+ let src = trait_ref. substs . type_at ( 1 ) ;
2947
2947
let custom_err_msg = format ! (
2948
2948
"`{src}` cannot be safely transmuted into `{dst}` in the defining scope of `{scope}`"
2949
2949
) ;
0 commit comments