From e9ab099d6f30328b03ec2d5515bd11e4852d1eca Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 28 Feb 2020 09:27:21 +0100 Subject: [PATCH] get rid of to_ptr --- src/librustc/mir/interpret/value.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs index 0e14089eebc..44a6fc5fb84 100644 --- a/src/librustc/mir/interpret/value.rs +++ b/src/librustc/mir/interpret/value.rs @@ -406,20 +406,12 @@ pub fn assert_bits(self, target_size: Size) -> u128 { self.to_bits(target_size).expect("expected Raw bits but got a Pointer") } - /// Do not call this method! Use either `assert_ptr` or `force_ptr`. - /// This method is intentionally private, do not make it public. #[inline] - fn to_ptr(self) -> InterpResult<'tcx, Pointer> { - match self { - Scalar::Raw { data: 0, .. } => throw_unsup!(InvalidNullPointerUsage), - Scalar::Raw { .. } => throw_unsup!(ReadBytesAsPointer), - Scalar::Ptr(p) => Ok(p), - } - } - - #[inline(always)] pub fn assert_ptr(self) -> Pointer { - self.to_ptr().expect("expected a Pointer but got Raw bits") + match self { + Scalar::Ptr(p) => p, + Scalar::Raw { .. } => bug!("expected a Pointer but got Raw bits") + } } /// Do not call this method! Dispatch based on the type instead.