@@ -16,7 +16,7 @@ use rustc_middle::ty::fold::TypeFoldable;
1616use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitableExt as _} ;
1717use rustc_span:: { ErrorGuaranteed , Span , DUMMY_SP } ;
1818use rustc_type_ir:: relate:: Relate ;
19- use rustc_type_ir:: solve:: { NoSolution , SolverMode } ;
19+ use rustc_type_ir:: solve:: { Certainty , NoSolution , SolverMode } ;
2020
2121use crate :: traits:: coherence:: trait_ref_is_knowable;
2222use crate :: traits:: specialization_graph;
@@ -406,4 +406,30 @@ impl<'tcx> rustc_next_trait_solver::infcx::SolverDelegate for SolverDelegate<'tc
406406 // FIXME: Check for defaultness here may cause diagnostics problems.
407407 if eligible { Ok ( Some ( node_item. item . def_id ) ) } else { Ok ( None ) }
408408 }
409+
410+ fn is_transmutable (
411+ & self ,
412+ param_env : ty:: ParamEnv < ' tcx > ,
413+ dst : Ty < ' tcx > ,
414+ src : Ty < ' tcx > ,
415+ assume : ty:: Const < ' tcx > ,
416+ ) -> Result < Certainty , NoSolution > {
417+ // Erase regions because we compute layouts in `rustc_transmute`,
418+ // which will ICE for region vars.
419+ let ( dst, src) = self . tcx . erase_regions ( ( dst, src) ) ;
420+
421+ let Some ( assume) = rustc_transmute:: Assume :: from_const ( self . tcx , param_env, assume) else {
422+ return Err ( NoSolution ) ;
423+ } ;
424+
425+ // FIXME(transmutability): This really should be returning nested goals for `Answer::If*`
426+ match rustc_transmute:: TransmuteTypeEnv :: new ( & self . 0 ) . is_transmutable (
427+ ObligationCause :: dummy ( ) ,
428+ rustc_transmute:: Types { src, dst } ,
429+ assume,
430+ ) {
431+ rustc_transmute:: Answer :: Yes => Ok ( Certainty :: Yes ) ,
432+ rustc_transmute:: Answer :: No ( _) | rustc_transmute:: Answer :: If ( _) => Err ( NoSolution ) ,
433+ }
434+ }
409435}
0 commit comments