@@ -504,139 +504,6 @@ impl<'tcx, Prov: Provenance> Scalar<Prov> {
504
504
}
505
505
}
506
506
507
- #[derive(Clone, Copy, Eq, PartialEq, TyEncodable, TyDecodable, HashStable, Hash)]
508
- pub enum ScalarMaybeUninit<Prov = AllocId> {
509
- Scalar(Scalar<Prov>),
510
- Uninit,
511
- }
512
-
513
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
514
- static_assert_size!(ScalarMaybeUninit, 24);
515
-
516
- impl<Prov> From<Scalar<Prov>> for ScalarMaybeUninit<Prov> {
517
- #[inline(always)]
518
- fn from(s: Scalar<Prov>) -> Self {
519
- ScalarMaybeUninit::Scalar(s)
520
- }
521
- }
522
-
523
- // We want the `Debug` output to be readable as it is used by `derive(Debug)` for
524
- // all the Miri types.
525
- impl<Prov: Provenance> fmt::Debug for ScalarMaybeUninit<Prov> {
526
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
527
- match self {
528
- ScalarMaybeUninit::Uninit => write!(f, "<uninitialized>"),
529
- ScalarMaybeUninit::Scalar(s) => write!(f, "{:?}", s),
530
- }
531
- }
532
- }
533
-
534
- impl<Prov: Provenance> fmt::LowerHex for ScalarMaybeUninit<Prov> {
535
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
536
- match self {
537
- ScalarMaybeUninit::Uninit => write!(f, "uninitialized bytes"),
538
- ScalarMaybeUninit::Scalar(s) => write!(f, "{:x}", s),
539
- }
540
- }
541
- }
542
-
543
- impl<Prov> ScalarMaybeUninit<Prov> {
544
- #[inline]
545
- pub fn from_pointer(ptr: Pointer<Prov>, cx: &impl HasDataLayout) -> Self {
546
- ScalarMaybeUninit::Scalar(Scalar::from_pointer(ptr, cx))
547
- }
548
-
549
- #[inline]
550
- pub fn from_maybe_pointer(ptr: Pointer<Option<Prov>>, cx: &impl HasDataLayout) -> Self {
551
- ScalarMaybeUninit::Scalar(Scalar::from_maybe_pointer(ptr, cx))
552
- }
553
-
554
- #[inline]
555
- pub fn check_init<'tcx>(self) -> InterpResult<'tcx, Scalar<Prov>> {
556
- match self {
557
- ScalarMaybeUninit::Scalar(scalar) => Ok(scalar),
558
- ScalarMaybeUninit::Uninit => throw_ub!(InvalidUninitBytes(None)),
559
- }
560
- }
561
- }
562
-
563
- impl<'tcx, Prov: Provenance> ScalarMaybeUninit<Prov> {
564
- #[inline(always)]
565
- pub fn to_pointer(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, Pointer<Option<Prov>>> {
566
- self.check_init()?.to_pointer(cx)
567
- }
568
-
569
- #[inline(always)]
570
- pub fn to_bool(self) -> InterpResult<'tcx, bool> {
571
- self.check_init()?.to_bool()
572
- }
573
-
574
- #[inline(always)]
575
- pub fn to_char(self) -> InterpResult<'tcx, char> {
576
- self.check_init()?.to_char()
577
- }
578
-
579
- #[inline(always)]
580
- pub fn to_f32(self) -> InterpResult<'tcx, Single> {
581
- self.check_init()?.to_f32()
582
- }
583
-
584
- #[inline(always)]
585
- pub fn to_f64(self) -> InterpResult<'tcx, Double> {
586
- self.check_init()?.to_f64()
587
- }
588
-
589
- #[inline(always)]
590
- pub fn to_u8(self) -> InterpResult<'tcx, u8> {
591
- self.check_init()?.to_u8()
592
- }
593
-
594
- #[inline(always)]
595
- pub fn to_u16(self) -> InterpResult<'tcx, u16> {
596
- self.check_init()?.to_u16()
597
- }
598
-
599
- #[inline(always)]
600
- pub fn to_u32(self) -> InterpResult<'tcx, u32> {
601
- self.check_init()?.to_u32()
602
- }
603
-
604
- #[inline(always)]
605
- pub fn to_u64(self) -> InterpResult<'tcx, u64> {
606
- self.check_init()?.to_u64()
607
- }
608
-
609
- #[inline(always)]
610
- pub fn to_machine_usize(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, u64> {
611
- self.check_init()?.to_machine_usize(cx)
612
- }
613
-
614
- #[inline(always)]
615
- pub fn to_i8(self) -> InterpResult<'tcx, i8> {
616
- self.check_init()?.to_i8()
617
- }
618
-
619
- #[inline(always)]
620
- pub fn to_i16(self) -> InterpResult<'tcx, i16> {
621
- self.check_init()?.to_i16()
622
- }
623
-
624
- #[inline(always)]
625
- pub fn to_i32(self) -> InterpResult<'tcx, i32> {
626
- self.check_init()?.to_i32()
627
- }
628
-
629
- #[inline(always)]
630
- pub fn to_i64(self) -> InterpResult<'tcx, i64> {
631
- self.check_init()?.to_i64()
632
- }
633
-
634
- #[inline(always)]
635
- pub fn to_machine_isize(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, i64> {
636
- self.check_init()?.to_machine_isize(cx)
637
- }
638
- }
639
-
640
507
/// Gets the bytes of a constant slice value.
641
508
pub fn get_slice_bytes<'tcx>(cx: &impl HasDataLayout, val: ConstValue<'tcx>) -> &'tcx [u8] {
642
509
if let ConstValue::Slice { data, start, end } = val {
0 commit comments