@@ -527,34 +527,41 @@ where
527
527
}
528
528
529
529
// Also used e.g. when miri runs into a constant.
530
- pub fn const_to_mplace (
530
+ pub fn const_value_to_mplace (
531
531
& self ,
532
- val : & ty :: Const < ' tcx > ,
533
- ) -> EvalResult < ' tcx , MPlaceTy < ' tcx , M :: PointerTag > > {
532
+ val : ConstValue < ' tcx > ,
533
+ ) -> EvalResult < ' tcx , MemPlace < M :: PointerTag > > {
534
534
trace ! ( "const_value_to_mplace: {:?}" , val) ;
535
- let mplace = match val . val {
535
+ match val {
536
536
ConstValue :: Unevaluated ( def_id, substs) => {
537
537
let instance = self . resolve ( def_id, substs) ?;
538
538
self . global_to_mplace ( GlobalId {
539
539
instance,
540
540
promoted : None ,
541
- } ) ?
541
+ } )
542
542
}
543
543
ConstValue :: ByRef ( id, alloc, offset) => {
544
544
// We rely on mutability being set correctly in that allocation to prevent writes
545
545
// where none should happen -- and for `static mut`, we copy on demand anyway.
546
- MemPlace :: from_ptr ( Pointer :: new ( id, offset) , alloc. align ) . with_default_tag ( )
546
+ Ok ( MemPlace :: from_ptr ( Pointer :: new ( id, offset) , alloc. align ) . with_default_tag ( ) )
547
547
}
548
- } ;
549
- Ok ( MPlaceTy { mplace, layout : self . layout_of ( val. ty ) ? } )
548
+ }
549
+ }
550
+
551
+ pub fn const_to_mplace (
552
+ & self ,
553
+ cnst : & ty:: Const < ' tcx > ,
554
+ ) -> EvalResult < ' tcx , MPlaceTy < ' tcx , M :: PointerTag > > {
555
+ let mplace = self . const_value_to_mplace ( cnst. val ) ?;
556
+ Ok ( MPlaceTy { mplace, layout : self . layout_of ( cnst. ty ) ? } )
550
557
}
551
558
552
559
fn global_to_mplace (
553
560
& self ,
554
561
gid : GlobalId < ' tcx >
555
562
) -> EvalResult < ' tcx , MemPlace < M :: PointerTag > > {
556
563
let cv = self . const_eval ( gid) ?;
557
- Ok ( * self . const_to_mplace ( cv) ? )
564
+ self . const_value_to_mplace ( cv. val )
558
565
}
559
566
560
567
/// Evaluate statics and promoteds to an `MPlace`. Used to share some code between
0 commit comments