Skip to content

Commit 52315a9

Browse files
committed
rollup merge of rust-lang#20042: alexcrichton/second-pass-ptr
This commit performs a second pass for stabilization over the `std::ptr` module. The specific actions taken were: * The `RawPtr` trait was renamed to `PtrExt` * The `RawMutPtr` trait was renamed to `PtrMutExt` * The module name `ptr` is now stable. * These functions were all marked `#[stable]` with no modification: * `null` * `null_mut` * `swap` * `replace` * `read` * `write` * `PtrExt::is_null` * `PtrExt::is_not_null` * `PtrExt::offset` * These functions remain unstable: * `as_ref`, `as_mut` - the return value of an `Option` is not fully expressive as null isn't the only bad value, and it's unclear whether we want to commit to these functions at this time. The reference/lifetime semantics as written are also problematic in how they encourage arbitrary lifetimes. * `zero_memory` - This function is currently not used at all in the distribution, and in general it plays a broader role in the "working with unsafe pointers" story. This story is not yet fully developed, so at this time the function remains unstable for now. * `read_and_zero` - This function remains unstable for largely the same reasons as `zero_memory`. * These functions are now all deprecated: * `PtrExt::null` - call `ptr::null` or `ptr::null_mut` instead. * `PtrExt::to_uint` - use an `as` expression instead.
2 parents cc20d60 + 54452cd commit 52315a9

File tree

20 files changed

+119
-92
lines changed

20 files changed

+119
-92
lines changed

src/liballoc/arc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ use core::nonzero::NonZero;
8080
use core::ops::{Drop, Deref};
8181
use core::option::Option;
8282
use core::option::Option::{Some, None};
83-
use core::ptr::{mod, RawPtr};
83+
use core::ptr::{mod, PtrExt};
8484
use heap::deallocate;
8585

8686
/// An atomically reference counted wrapper for shared state.

src/liballoc/heap.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use core::ptr::RawPtr;
11+
use core::ptr::PtrExt;
1212

1313
// FIXME: #13996: mark the `allocate` and `reallocate` return value as `noalias`
1414

@@ -371,7 +371,7 @@ mod imp {
371371
mod test {
372372
extern crate test;
373373
use self::test::Bencher;
374-
use core::ptr::RawPtr;
374+
use core::ptr::PtrExt;
375375
use heap;
376376

377377
#[test]

src/liballoc/rc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ use core::nonzero::NonZero;
154154
use core::ops::{Deref, Drop};
155155
use core::option::Option;
156156
use core::option::Option::{Some, None};
157-
use core::ptr::{mod, RawPtr};
157+
use core::ptr::{mod, PtrExt};
158158
use core::result::Result;
159159
use core::result::Result::{Ok, Err};
160160

src/libcollections/dlist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<T> Rawlink<T> {
9595
/// Convert the `Rawlink` into an Option value
9696
fn resolve_immut<'a>(&self) -> Option<&'a T> {
9797
unsafe {
98-
self.p.as_ref()
98+
mem::transmute(self.p.as_ref())
9999
}
100100
}
101101

src/libcollections/slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ use core::mem::size_of;
9696
use core::mem;
9797
use core::ops::FnMut;
9898
use core::prelude::{Clone, Greater, Iterator, IteratorExt, Less, None, Option};
99-
use core::prelude::{Ord, Ordering, RawPtr, Some, range};
99+
use core::prelude::{Ord, Ordering, PtrExt, Some, range};
100100
use core::ptr;
101101
use core::slice as core_slice;
102102
use self::Direction::*;

src/libcollections/str.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -1768,19 +1768,12 @@ impl StrExt for str {}
17681768

17691769
#[cfg(test)]
17701770
mod tests {
1771-
use std::iter::AdditiveIterator;
1772-
use std::iter::range;
1773-
use std::default::Default;
1774-
use std::char::Char;
1775-
use std::clone::Clone;
1776-
use std::cmp::{Ord, PartialOrd, Equiv};
1777-
use std::cmp::Ordering::{Equal, Greater, Less};
1778-
use std::option::Option::{mod, Some, None};
1779-
use std::result::Result::{Ok, Err};
1780-
use std::ptr::RawPtr;
1781-
use std::iter::{Iterator, IteratorExt, DoubleEndedIteratorExt};
1771+
use prelude::*;
17821772

1783-
use super::*;
1773+
use core::default::Default;
1774+
use core::iter::AdditiveIterator;
1775+
use super::{eq_slice, from_utf8, is_utf8, is_utf16, raw};
1776+
use super::truncate_utf16_at_nul;
17841777
use super::MaybeOwned::{Owned, Slice};
17851778
use std::slice::{AsSlice, SliceExt};
17861779
use string::{String, ToString};

src/libcore/prelude.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub use iter::{IteratorOrdExt, MutableDoubleEndedIterator, ExactSizeIterator};
5757
pub use num::{ToPrimitive, FromPrimitive};
5858
pub use option::Option;
5959
pub use option::Option::{Some, None};
60-
pub use ptr::RawPtr;
60+
pub use ptr::{PtrExt, MutPtrExt};
6161
pub use result::Result;
6262
pub use result::Result::{Ok, Err};
6363
pub use str::{Str, StrExt};

0 commit comments

Comments
 (0)