Skip to content

Commit 398947d

Browse files
author
Paul Liétar
committed
Undo changes to core::ptr
1 parent 77f7e85 commit 398947d

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/libcore/ptr.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,8 @@ impl<T: ?Sized> *const T {
485485
/// ```
486486
#[stable(feature = "rust1", since = "1.0.0")]
487487
#[inline]
488-
pub fn is_null(self) -> bool {
489-
// cast to () pointer, as T may not be sized
490-
self as *const () == null()
488+
pub fn is_null(self) -> bool where T: Sized {
489+
self == null()
491490
}
492491

493492
/// Returns `None` if the pointer is null, or else returns a reference to
@@ -518,7 +517,7 @@ impl<T: ?Sized> *const T {
518517
/// ```
519518
#[stable(feature = "ptr_as_ref", since = "1.9.0")]
520519
#[inline]
521-
pub unsafe fn as_ref<'a>(self) -> Option<&'a T> {
520+
pub unsafe fn as_ref<'a>(self) -> Option<&'a T> where T: Sized {
522521
if self.is_null() {
523522
None
524523
} else {
@@ -1117,9 +1116,8 @@ impl<T: ?Sized> *mut T {
11171116
/// ```
11181117
#[stable(feature = "rust1", since = "1.0.0")]
11191118
#[inline]
1120-
pub fn is_null(self) -> bool {
1121-
// cast to () pointer, as T may not be sized
1122-
self as *mut () == null_mut()
1119+
pub fn is_null(self) -> bool where T: Sized {
1120+
self == null_mut()
11231121
}
11241122

11251123
/// Returns `None` if the pointer is null, or else returns a reference to
@@ -1150,7 +1148,7 @@ impl<T: ?Sized> *mut T {
11501148
/// ```
11511149
#[stable(feature = "ptr_as_ref", since = "1.9.0")]
11521150
#[inline]
1153-
pub unsafe fn as_ref<'a>(self) -> Option<&'a T> {
1151+
pub unsafe fn as_ref<'a>(self) -> Option<&'a T> where T: Sized {
11541152
if self.is_null() {
11551153
None
11561154
} else {
@@ -1274,7 +1272,7 @@ impl<T: ?Sized> *mut T {
12741272
/// ```
12751273
#[stable(feature = "ptr_as_ref", since = "1.9.0")]
12761274
#[inline]
1277-
pub unsafe fn as_mut<'a>(self) -> Option<&'a mut T> {
1275+
pub unsafe fn as_mut<'a>(self) -> Option<&'a mut T> where T: Sized {
12781276
if self.is_null() {
12791277
None
12801278
} else {

0 commit comments

Comments
 (0)