From: Ralf Jung Date: Fri, 28 Feb 2020 08:27:21 +0000 (+0100) Subject: get rid of to_ptr X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=e9ab099d6f30328b03ec2d5515bd11e4852d1eca;p=rust.git get rid of to_ptr --- 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,22 +406,14 @@ 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> { + pub fn assert_ptr(self) -> Pointer { match self { - Scalar::Raw { data: 0, .. } => throw_unsup!(InvalidNullPointerUsage), - Scalar::Raw { .. } => throw_unsup!(ReadBytesAsPointer), - Scalar::Ptr(p) => Ok(p), + Scalar::Ptr(p) => p, + Scalar::Raw { .. } => bug!("expected a Pointer but got Raw bits") } } - #[inline(always)] - pub fn assert_ptr(self) -> Pointer { - self.to_ptr().expect("expected a Pointer but got Raw bits") - } - /// Do not call this method! Dispatch based on the type instead. #[inline] pub fn is_bits(self) -> bool {