@@ -24,7 +24,7 @@ pub use self::error::{
2424 FrameInfo , ConstEvalResult ,
2525} ;
2626
27- pub use self :: value:: { Scalar , ConstValue } ;
27+ pub use self :: value:: { Scalar , ConstValue , ScalarMaybeUndef } ;
2828
2929pub use self :: allocation:: {
3030 Allocation , MemoryAccess , AllocationExtra ,
@@ -567,122 +567,3 @@ pub fn truncate(value: u128, size: Size) -> u128 {
567567 // truncate (shift left to drop out leftover values, shift right to fill with zeroes)
568568 ( value << shift) >> shift
569569}
570-
571- #[ derive( Clone , Copy , Debug , Eq , PartialEq , Ord , PartialOrd , RustcEncodable , RustcDecodable , Hash ) ]
572- pub enum ScalarMaybeUndef < Tag =( ) , Id =AllocId > {
573- Scalar ( Scalar < Tag , Id > ) ,
574- Undef ,
575- }
576-
577- impl < Tag > From < Scalar < Tag > > for ScalarMaybeUndef < Tag > {
578- #[ inline( always) ]
579- fn from ( s : Scalar < Tag > ) -> Self {
580- ScalarMaybeUndef :: Scalar ( s)
581- }
582- }
583-
584- impl < ' tcx > ScalarMaybeUndef < ( ) > {
585- #[ inline]
586- pub fn with_default_tag < Tag > ( self ) -> ScalarMaybeUndef < Tag >
587- where Tag : Default
588- {
589- match self {
590- ScalarMaybeUndef :: Scalar ( s) => ScalarMaybeUndef :: Scalar ( s. with_default_tag ( ) ) ,
591- ScalarMaybeUndef :: Undef => ScalarMaybeUndef :: Undef ,
592- }
593- }
594- }
595-
596- impl < ' tcx , Tag > ScalarMaybeUndef < Tag > {
597- #[ inline]
598- pub fn erase_tag ( self ) -> ScalarMaybeUndef
599- {
600- match self {
601- ScalarMaybeUndef :: Scalar ( s) => ScalarMaybeUndef :: Scalar ( s. erase_tag ( ) ) ,
602- ScalarMaybeUndef :: Undef => ScalarMaybeUndef :: Undef ,
603- }
604- }
605-
606- #[ inline]
607- pub fn not_undef ( self ) -> EvalResult < ' static , Scalar < Tag > > {
608- match self {
609- ScalarMaybeUndef :: Scalar ( scalar) => Ok ( scalar) ,
610- ScalarMaybeUndef :: Undef => err ! ( ReadUndefBytes ( Size :: from_bytes( 0 ) ) ) ,
611- }
612- }
613-
614- #[ inline( always) ]
615- pub fn to_ptr ( self ) -> EvalResult < ' tcx , Pointer < Tag > > {
616- self . not_undef ( ) ?. to_ptr ( )
617- }
618-
619- #[ inline( always) ]
620- pub fn to_bits ( self , target_size : Size ) -> EvalResult < ' tcx , u128 > {
621- self . not_undef ( ) ?. to_bits ( target_size)
622- }
623-
624- #[ inline( always) ]
625- pub fn to_bool ( self ) -> EvalResult < ' tcx , bool > {
626- self . not_undef ( ) ?. to_bool ( )
627- }
628-
629- #[ inline( always) ]
630- pub fn to_char ( self ) -> EvalResult < ' tcx , char > {
631- self . not_undef ( ) ?. to_char ( )
632- }
633-
634- #[ inline( always) ]
635- pub fn to_f32 ( self ) -> EvalResult < ' tcx , f32 > {
636- self . not_undef ( ) ?. to_f32 ( )
637- }
638-
639- #[ inline( always) ]
640- pub fn to_f64 ( self ) -> EvalResult < ' tcx , f64 > {
641- self . not_undef ( ) ?. to_f64 ( )
642- }
643-
644- #[ inline( always) ]
645- pub fn to_u8 ( self ) -> EvalResult < ' tcx , u8 > {
646- self . not_undef ( ) ?. to_u8 ( )
647- }
648-
649- #[ inline( always) ]
650- pub fn to_u32 ( self ) -> EvalResult < ' tcx , u32 > {
651- self . not_undef ( ) ?. to_u32 ( )
652- }
653-
654- #[ inline( always) ]
655- pub fn to_u64 ( self ) -> EvalResult < ' tcx , u64 > {
656- self . not_undef ( ) ?. to_u64 ( )
657- }
658-
659- #[ inline( always) ]
660- pub fn to_usize ( self , cx : impl HasDataLayout ) -> EvalResult < ' tcx , u64 > {
661- self . not_undef ( ) ?. to_usize ( cx)
662- }
663-
664- #[ inline( always) ]
665- pub fn to_i8 ( self ) -> EvalResult < ' tcx , i8 > {
666- self . not_undef ( ) ?. to_i8 ( )
667- }
668-
669- #[ inline( always) ]
670- pub fn to_i32 ( self ) -> EvalResult < ' tcx , i32 > {
671- self . not_undef ( ) ?. to_i32 ( )
672- }
673-
674- #[ inline( always) ]
675- pub fn to_i64 ( self ) -> EvalResult < ' tcx , i64 > {
676- self . not_undef ( ) ?. to_i64 ( )
677- }
678-
679- #[ inline( always) ]
680- pub fn to_isize ( self , cx : impl HasDataLayout ) -> EvalResult < ' tcx , i64 > {
681- self . not_undef ( ) ?. to_isize ( cx)
682- }
683- }
684-
685- impl_stable_hash_for ! ( enum :: mir:: interpret:: ScalarMaybeUndef {
686- Scalar ( v) ,
687- Undef
688- } ) ;
0 commit comments