@@ -490,32 +490,6 @@ impl<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for OpTy<'tcx, Prov> {
490490 }
491491}
492492
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-
519493impl < ' tcx , M : Machine < ' tcx > > InterpCx < ' tcx , M > {
520494 /// Try reading an immediate in memory; this is interesting particularly for `ScalarPair`.
521495 /// 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> {
588562 /// ConstProp needs it, though.
589563 pub fn read_immediate_raw (
590564 & self ,
591- src : & impl Readable < ' tcx , M :: Provenance > ,
565+ src : & impl Projectable < ' tcx , M :: Provenance > ,
592566 ) -> 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 ( ) {
594568 Left ( ref mplace) => {
595569 if let Some ( val) = self . read_immediate_from_mplace_raw ( mplace) ? {
596570 Right ( val)
@@ -608,7 +582,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
608582 #[ inline( always) ]
609583 pub fn read_immediate (
610584 & self ,
611- op : & impl Readable < ' tcx , M :: Provenance > ,
585+ op : & impl Projectable < ' tcx , M :: Provenance > ,
612586 ) -> InterpResult < ' tcx , ImmTy < ' tcx , M :: Provenance > > {
613587 if !matches ! (
614588 op. layout( ) . abi,
@@ -627,7 +601,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
627601 /// Read a scalar from a place
628602 pub fn read_scalar (
629603 & self ,
630- op : & impl Readable < ' tcx , M :: Provenance > ,
604+ op : & impl Projectable < ' tcx , M :: Provenance > ,
631605 ) -> InterpResult < ' tcx , Scalar < M :: Provenance > > {
632606 Ok ( self . read_immediate ( op) ?. to_scalar ( ) )
633607 }
@@ -638,21 +612,21 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
638612 /// Read a pointer from a place.
639613 pub fn read_pointer (
640614 & self ,
641- op : & impl Readable < ' tcx , M :: Provenance > ,
615+ op : & impl Projectable < ' tcx , M :: Provenance > ,
642616 ) -> InterpResult < ' tcx , Pointer < Option < M :: Provenance > > > {
643617 self . read_scalar ( op) ?. to_pointer ( self )
644618 }
645619 /// Read a pointer-sized unsigned integer from a place.
646620 pub fn read_target_usize (
647621 & self ,
648- op : & impl Readable < ' tcx , M :: Provenance > ,
622+ op : & impl Projectable < ' tcx , M :: Provenance > ,
649623 ) -> InterpResult < ' tcx , u64 > {
650624 self . read_scalar ( op) ?. to_target_usize ( self )
651625 }
652626 /// Read a pointer-sized signed integer from a place.
653627 pub fn read_target_isize (
654628 & self ,
655- op : & impl Readable < ' tcx , M :: Provenance > ,
629+ op : & impl Projectable < ' tcx , M :: Provenance > ,
656630 ) -> InterpResult < ' tcx , i64 > {
657631 self . read_scalar ( op) ?. to_target_isize ( self )
658632 }
0 commit comments