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