about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-02-28 09:27:21 +0100
committerRalf Jung <post@ralfj.de>2020-02-28 09:28:30 +0100
commite9ab099d6f30328b03ec2d5515bd11e4852d1eca (patch)
tree2929bf35711740c0ded866bc7b4d7d42c703e51f
parentf9644c16f3156025d83d3dc1262ac35d9ae89588 (diff)
downloadrust-e9ab099d6f30328b03ec2d5515bd11e4852d1eca.tar.gz
rust-e9ab099d6f30328b03ec2d5515bd11e4852d1eca.zip
get rid of to_ptr
-rw-r--r--src/librustc/mir/interpret/value.rs14
1 files changed, 3 insertions, 11 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,22 +406,14 @@ impl<'tcx, Tag> Scalar<Tag> {
         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<Tag>> {
+    pub fn assert_ptr(self) -> Pointer<Tag> {
         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<Tag> {
-        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 {