]> git.lizzy.rs Git - rust.git/commitdiff
get rid of to_ptr
authorRalf Jung <post@ralfj.de>
Fri, 28 Feb 2020 08:27:21 +0000 (09:27 +0100)
committerRalf Jung <post@ralfj.de>
Fri, 28 Feb 2020 08:28:30 +0000 (09:28 +0100)
src/librustc/mir/interpret/value.rs

index 0e14089eebc3ebf37c628f6abb32358c8e3c523e..44a6fc5fb842ca30ed0f3e367ad4c24c978bc411 100644 (file)
@@ -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<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 {