@@ -16,7 +16,7 @@ use rustc_middle::ty::fold::TypeFoldable;
16
16
use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitableExt as _} ;
17
17
use rustc_span:: { ErrorGuaranteed , Span , DUMMY_SP } ;
18
18
use rustc_type_ir:: relate:: Relate ;
19
- use rustc_type_ir:: solve:: { NoSolution , SolverMode } ;
19
+ use rustc_type_ir:: solve:: { Certainty , NoSolution , SolverMode } ;
20
20
21
21
use crate :: traits:: coherence:: trait_ref_is_knowable;
22
22
use crate :: traits:: specialization_graph;
@@ -406,4 +406,30 @@ impl<'tcx> rustc_next_trait_solver::infcx::SolverDelegate for SolverDelegate<'tc
406
406
// FIXME: Check for defaultness here may cause diagnostics problems.
407
407
if eligible { Ok ( Some ( node_item. item . def_id ) ) } else { Ok ( None ) }
408
408
}
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
+ }
409
435
}
0 commit comments