From 398947d766482ac6cfdb5780e01c361ec0264f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Li=C3=A9tar?= Date: Thu, 5 Oct 2017 02:12:59 +0200 Subject: [PATCH] Undo changes to core::ptr --- src/libcore/ptr.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 4a52ec5ee784..01990f61feeb 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -485,9 +485,8 @@ impl *const T { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn is_null(self) -> bool { - // cast to () pointer, as T may not be sized - self as *const () == null() + pub fn is_null(self) -> bool where T: Sized { + self == null() } /// Returns `None` if the pointer is null, or else returns a reference to @@ -518,7 +517,7 @@ impl *const T { /// ``` #[stable(feature = "ptr_as_ref", since = "1.9.0")] #[inline] - pub unsafe fn as_ref<'a>(self) -> Option<&'a T> { + pub unsafe fn as_ref<'a>(self) -> Option<&'a T> where T: Sized { if self.is_null() { None } else { @@ -1117,9 +1116,8 @@ impl *mut T { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn is_null(self) -> bool { - // cast to () pointer, as T may not be sized - self as *mut () == null_mut() + pub fn is_null(self) -> bool where T: Sized { + self == null_mut() } /// Returns `None` if the pointer is null, or else returns a reference to @@ -1150,7 +1148,7 @@ impl *mut T { /// ``` #[stable(feature = "ptr_as_ref", since = "1.9.0")] #[inline] - pub unsafe fn as_ref<'a>(self) -> Option<&'a T> { + pub unsafe fn as_ref<'a>(self) -> Option<&'a T> where T: Sized { if self.is_null() { None } else { @@ -1274,7 +1272,7 @@ impl *mut T { /// ``` #[stable(feature = "ptr_as_ref", since = "1.9.0")] #[inline] - pub unsafe fn as_mut<'a>(self) -> Option<&'a mut T> { + pub unsafe fn as_mut<'a>(self) -> Option<&'a mut T> where T: Sized { if self.is_null() { None } else {