@@ -742,7 +742,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
742742 {
743743 // Recompute the safe transmute reason and use that for the error reporting
744744 self . get_safe_transmute_error_and_reason (
745- trait_predicate,
746745 obligation. clone ( ) ,
747746 trait_ref,
748747 span,
@@ -1629,7 +1628,6 @@ trait InferCtxtPrivExt<'tcx> {
16291628
16301629 fn get_safe_transmute_error_and_reason (
16311630 & self ,
1632- trait_predicate : ty:: Binder < ' tcx , ty:: TraitPredicate < ' tcx > > ,
16331631 obligation : Obligation < ' tcx , ty:: Predicate < ' tcx > > ,
16341632 trait_ref : ty:: Binder < ' tcx , ty:: TraitRef < ' tcx > > ,
16351633 span : Span ,
@@ -2921,18 +2919,20 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
29212919
29222920 fn get_safe_transmute_error_and_reason (
29232921 & self ,
2924- trait_predicate : ty:: Binder < ' tcx , ty:: TraitPredicate < ' tcx > > ,
29252922 obligation : Obligation < ' tcx , ty:: Predicate < ' tcx > > ,
29262923 trait_ref : ty:: Binder < ' tcx , ty:: TraitRef < ' tcx > > ,
29272924 span : Span ,
29282925 ) -> ( 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 ) ;
29342934 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 {
29362936 span_bug ! ( span, "Unable to construct rustc_transmute::Assume where it was previously possible" ) ;
29372937 } ;
29382938 match rustc_transmute:: TransmuteTypeEnv :: new ( self . infcx ) . is_transmutable (
@@ -2942,8 +2942,8 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
29422942 assume,
29432943 ) {
29442944 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 ) ;
29472947 let custom_err_msg = format ! (
29482948 "`{src}` cannot be safely transmuted into `{dst}` in the defining scope of `{scope}`"
29492949 ) ;
0 commit comments