@@ -490,32 +490,6 @@ impl<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for OpTy<'tcx, Prov> {
490
490
}
491
491
}
492
492
493
- /// The `Readable` trait describes interpreter values that one can read from.
494
- pub trait Readable < ' tcx , Prov : Provenance > : Projectable < ' tcx , Prov > {
495
- fn as_mplace_or_imm ( & self ) -> Either < MPlaceTy < ' tcx , Prov > , ImmTy < ' tcx , Prov > > ;
496
- }
497
-
498
- impl < ' tcx , Prov : Provenance > Readable < ' tcx , Prov > for OpTy < ' tcx , Prov > {
499
- #[ inline( always) ]
500
- fn as_mplace_or_imm ( & self ) -> Either < MPlaceTy < ' tcx , Prov > , ImmTy < ' tcx , Prov > > {
501
- self . as_mplace_or_imm ( )
502
- }
503
- }
504
-
505
- impl < ' tcx , Prov : Provenance > Readable < ' tcx , Prov > for MPlaceTy < ' tcx , Prov > {
506
- #[ inline( always) ]
507
- fn as_mplace_or_imm ( & self ) -> Either < MPlaceTy < ' tcx , Prov > , ImmTy < ' tcx , Prov > > {
508
- Left ( self . clone ( ) )
509
- }
510
- }
511
-
512
- impl < ' tcx , Prov : Provenance > Readable < ' tcx , Prov > for ImmTy < ' tcx , Prov > {
513
- #[ inline( always) ]
514
- fn as_mplace_or_imm ( & self ) -> Either < MPlaceTy < ' tcx , Prov > , ImmTy < ' tcx , Prov > > {
515
- Right ( self . clone ( ) )
516
- }
517
- }
518
-
519
493
impl < ' tcx , M : Machine < ' tcx > > InterpCx < ' tcx , M > {
520
494
/// Try reading an immediate in memory; this is interesting particularly for `ScalarPair`.
521
495
/// Returns `None` if the layout does not permit loading this as a value.
@@ -588,9 +562,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
588
562
/// ConstProp needs it, though.
589
563
pub fn read_immediate_raw (
590
564
& self ,
591
- src : & impl Readable < ' tcx , M :: Provenance > ,
565
+ src : & impl Projectable < ' tcx , M :: Provenance > ,
592
566
) -> InterpResult < ' tcx , Either < MPlaceTy < ' tcx , M :: Provenance > , ImmTy < ' tcx , M :: Provenance > > > {
593
- Ok ( match src. as_mplace_or_imm ( ) {
567
+ Ok ( match src. to_op ( self ) ? . as_mplace_or_imm ( ) {
594
568
Left ( ref mplace) => {
595
569
if let Some ( val) = self . read_immediate_from_mplace_raw ( mplace) ? {
596
570
Right ( val)
@@ -608,7 +582,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
608
582
#[ inline( always) ]
609
583
pub fn read_immediate (
610
584
& self ,
611
- op : & impl Readable < ' tcx , M :: Provenance > ,
585
+ op : & impl Projectable < ' tcx , M :: Provenance > ,
612
586
) -> InterpResult < ' tcx , ImmTy < ' tcx , M :: Provenance > > {
613
587
if !matches ! (
614
588
op. layout( ) . abi,
@@ -627,7 +601,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
627
601
/// Read a scalar from a place
628
602
pub fn read_scalar (
629
603
& self ,
630
- op : & impl Readable < ' tcx , M :: Provenance > ,
604
+ op : & impl Projectable < ' tcx , M :: Provenance > ,
631
605
) -> InterpResult < ' tcx , Scalar < M :: Provenance > > {
632
606
Ok ( self . read_immediate ( op) ?. to_scalar ( ) )
633
607
}
@@ -638,21 +612,21 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
638
612
/// Read a pointer from a place.
639
613
pub fn read_pointer (
640
614
& self ,
641
- op : & impl Readable < ' tcx , M :: Provenance > ,
615
+ op : & impl Projectable < ' tcx , M :: Provenance > ,
642
616
) -> InterpResult < ' tcx , Pointer < Option < M :: Provenance > > > {
643
617
self . read_scalar ( op) ?. to_pointer ( self )
644
618
}
645
619
/// Read a pointer-sized unsigned integer from a place.
646
620
pub fn read_target_usize (
647
621
& self ,
648
- op : & impl Readable < ' tcx , M :: Provenance > ,
622
+ op : & impl Projectable < ' tcx , M :: Provenance > ,
649
623
) -> InterpResult < ' tcx , u64 > {
650
624
self . read_scalar ( op) ?. to_target_usize ( self )
651
625
}
652
626
/// Read a pointer-sized signed integer from a place.
653
627
pub fn read_target_isize (
654
628
& self ,
655
- op : & impl Readable < ' tcx , M :: Provenance > ,
629
+ op : & impl Projectable < ' tcx , M :: Provenance > ,
656
630
) -> InterpResult < ' tcx , i64 > {
657
631
self . read_scalar ( op) ?. to_target_isize ( self )
658
632
}
0 commit comments