Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 54452cd

Browse files
committedDec 29, 2014
std: Second pass stabilization for 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 `MutPtrExt` * 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::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. * `PtrExt::is_not_null` - use `!p.is_null()` instead.
1 parent 7112390 commit 54452cd

File tree

20 files changed

+119
-92
lines changed

20 files changed

+119
-92
lines changed
 

‎src/liballoc/arc.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 12 deletions
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

Lines changed: 1 addition & 1 deletion
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};

‎src/libcore/ptr.rs

Lines changed: 87 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
//! typically limited to a few patterns.
1717
//!
1818
//! Use the [`null` function](fn.null.html) to create null pointers,
19-
//! the [`is_null`](trait.RawPtr.html#tymethod.is_null)
20-
//! and [`is_not_null`](trait.RawPtr.html#method.is_not_null)
21-
//! methods of the [`RawPtr` trait](trait.RawPtr.html) to check for null.
22-
//! The `RawPtr` trait is imported by the prelude, so `is_null` etc.
23-
//! work everywhere. The `RawPtr` also defines the `offset` method,
19+
//! the [`is_null`](trait.PtrExt.html#tymethod.is_null)
20+
//! methods of the [`PtrExt` trait](trait.PtrExt.html) to check for null.
21+
//! The `PtrExt` trait is imported by the prelude, so `is_null` etc.
22+
//! work everywhere. The `PtrExt` also defines the `offset` method,
2423
//! for pointer math.
2524
//!
2625
//! # Common ways to create unsafe pointers
@@ -87,16 +86,16 @@
8786
//! but C APIs hand out a lot of pointers generally, so are a common source
8887
//! of unsafe pointers in Rust.
8988
89+
#![stable]
90+
9091
use mem;
9192
use clone::Clone;
9293
use intrinsics;
94+
use option::Option::{mod, Some, None};
9395
use kinds::{Send, Sync};
94-
use option::Option;
95-
use option::Option::{Some, None};
9696

9797
use cmp::{PartialEq, Eq, Ord, PartialOrd, Equiv};
98-
use cmp::Ordering;
99-
use cmp::Ordering::{Less, Equal, Greater};
98+
use cmp::Ordering::{mod, Less, Equal, Greater};
10099

101100
// FIXME #19649: instrinsic docs don't render, so these have no docs :(
102101

@@ -121,7 +120,7 @@ pub use intrinsics::set_memory;
121120
/// assert!(p.is_null());
122121
/// ```
123122
#[inline]
124-
#[unstable = "may need a different name after pending changes to pointer types"]
123+
#[stable]
125124
pub fn null<T>() -> *const T { 0 as *const T }
126125

127126
/// Creates a null mutable raw pointer.
@@ -135,31 +134,31 @@ pub fn null<T>() -> *const T { 0 as *const T }
135134
/// assert!(p.is_null());
136135
/// ```
137136
#[inline]
138-
#[unstable = "may need a different name after pending changes to pointer types"]
137+
#[stable]
139138
pub fn null_mut<T>() -> *mut T { 0 as *mut T }
140139

141-
/// Zeroes out `count * size_of::<T>` bytes of memory at `dst`. `count` may be `0`.
140+
/// Zeroes out `count * size_of::<T>` bytes of memory at `dst`. `count` may be
141+
/// `0`.
142142
///
143143
/// # Safety
144144
///
145-
/// Beyond accepting a raw pointer, this is unsafe because it will not drop the contents of `dst`,
146-
/// and may be used to create invalid instances of `T`.
145+
/// Beyond accepting a raw pointer, this is unsafe because it will not drop the
146+
/// contents of `dst`, and may be used to create invalid instances of `T`.
147147
#[inline]
148-
#[experimental = "uncertain about naming and semantics"]
149-
#[allow(experimental)]
148+
#[unstable = "may play a larger role in std::ptr future extensions"]
150149
pub unsafe fn zero_memory<T>(dst: *mut T, count: uint) {
151150
set_memory(dst, 0, count);
152151
}
153152

154153
/// Swaps the values at two mutable locations of the same type, without
155-
/// deinitialising either. They may overlap, unlike `mem::swap` which is otherwise
156-
/// equivalent.
154+
/// deinitialising either. They may overlap, unlike `mem::swap` which is
155+
/// otherwise equivalent.
157156
///
158157
/// # Safety
159158
///
160159
/// This is only unsafe because it accepts a raw pointer.
161160
#[inline]
162-
#[unstable]
161+
#[stable]
163162
pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
164163
// Give ourselves some scratch space to work with
165164
let mut tmp: T = mem::uninitialized();
@@ -183,7 +182,7 @@ pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
183182
/// This is only unsafe because it accepts a raw pointer.
184183
/// Otherwise, this operation is identical to `mem::replace`.
185184
#[inline]
186-
#[unstable]
185+
#[stable]
187186
pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
188187
mem::swap(mem::transmute(dest), &mut src); // cannot overlap
189188
src
@@ -201,7 +200,7 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
201200
/// `zero_memory`, or `copy_memory`). Note that `*src = foo` counts as a use
202201
/// because it will attempt to drop the value previously at `*src`.
203202
#[inline(always)]
204-
#[unstable]
203+
#[stable]
205204
pub unsafe fn read<T>(src: *const T) -> T {
206205
let mut tmp: T = mem::uninitialized();
207206
copy_nonoverlapping_memory(&mut tmp, src, 1);
@@ -214,8 +213,7 @@ pub unsafe fn read<T>(src: *const T) -> T {
214213
///
215214
/// This is unsafe for the same reasons that `read` is unsafe.
216215
#[inline(always)]
217-
#[experimental]
218-
#[allow(experimental)]
216+
#[unstable = "may play a larger role in std::ptr future extensions"]
219217
pub unsafe fn read_and_zero<T>(dest: *mut T) -> T {
220218
// Copy the data out from `dest`:
221219
let tmp = read(&*dest);
@@ -226,85 +224,105 @@ pub unsafe fn read_and_zero<T>(dest: *mut T) -> T {
226224
tmp
227225
}
228226

229-
/// Overwrites a memory location with the given value without reading or dropping
230-
/// the old value.
227+
/// Overwrites a memory location with the given value without reading or
228+
/// dropping the old value.
231229
///
232230
/// # Safety
233231
///
234232
/// Beyond accepting a raw pointer, this operation is unsafe because it does
235233
/// not drop the contents of `dst`. This could leak allocations or resources,
236234
/// so care must be taken not to overwrite an object that should be dropped.
237235
///
238-
/// This is appropriate for initializing uninitialized memory, or overwritting memory
239-
/// that has previously been `read` from.
236+
/// This is appropriate for initializing uninitialized memory, or overwritting
237+
/// memory that has previously been `read` from.
240238
#[inline]
241-
#[unstable]
239+
#[stable]
242240
pub unsafe fn write<T>(dst: *mut T, src: T) {
243241
intrinsics::move_val_init(&mut *dst, src)
244242
}
245243

246244
/// Methods on raw pointers
247-
pub trait RawPtr<T> {
248-
/// Returns a null raw pointer.
245+
#[stable]
246+
pub trait PtrExt<T> {
247+
/// Returns the null pointer.
248+
#[deprecated = "call ptr::null instead"]
249249
fn null() -> Self;
250250

251251
/// Returns true if the pointer is null.
252-
fn is_null(&self) -> bool;
252+
#[stable]
253+
fn is_null(self) -> bool;
253254

254-
/// Returns true if the pointer is not null.
255-
fn is_not_null(&self) -> bool { !self.is_null() }
255+
/// Returns true if the pointer is not equal to the null pointer.
256+
#[deprecated = "use !p.is_null() instead"]
257+
fn is_not_null(self) -> bool { !self.is_null() }
256258

257-
/// Returns the address of the pointer.
258-
fn to_uint(&self) -> uint;
259+
/// Returns true if the pointer is not null.
260+
#[deprecated = "use `as uint` instead"]
261+
fn to_uint(self) -> uint;
259262

260-
/// Returns `None` if the pointer is null, or else returns a reference to the
261-
/// value wrapped in `Some`.
263+
/// Returns `None` if the pointer is null, or else returns a reference to
264+
/// the value wrapped in `Some`.
262265
///
263266
/// # Safety
264267
///
265-
/// While this method and its mutable counterpart are useful for null-safety,
266-
/// it is important to note that this is still an unsafe operation because
267-
/// the returned value could be pointing to invalid memory.
268+
/// While this method and its mutable counterpart are useful for
269+
/// null-safety, it is important to note that this is still an unsafe
270+
/// operation because the returned value could be pointing to invalid
271+
/// memory.
272+
#[unstable = "Option is not clearly the right return type, and we may want \
273+
to tie the return lifetime to a borrow of the raw pointer"]
268274
unsafe fn as_ref<'a>(&self) -> Option<&'a T>;
269275

270276
/// Calculates the offset from a pointer. `count` is in units of T; e.g. a
271277
/// `count` of 3 represents a pointer offset of `3 * sizeof::<T>()` bytes.
272278
///
273279
/// # Safety
274280
///
275-
/// The offset must be in-bounds of the object, or one-byte-past-the-end. Otherwise
276-
/// `offset` invokes Undefined Behaviour, regardless of whether the pointer is used.
281+
/// The offset must be in-bounds of the object, or one-byte-past-the-end.
282+
/// Otherwise `offset` invokes Undefined Behaviour, regardless of whether
283+
/// the pointer is used.
284+
#[stable]
277285
unsafe fn offset(self, count: int) -> Self;
278286
}
279287

280288
/// Methods on mutable raw pointers
281-
pub trait RawMutPtr<T>{
282-
/// Returns `None` if the pointer is null, or else returns a mutable reference
283-
/// to the value wrapped in `Some`.
289+
#[stable]
290+
pub trait MutPtrExt<T>{
291+
/// Returns `None` if the pointer is null, or else returns a mutable
292+
/// reference to the value wrapped in `Some`.
284293
///
285294
/// # Safety
286295
///
287296
/// As with `as_ref`, this is unsafe because it cannot verify the validity
288297
/// of the returned pointer.
298+
#[unstable = "Option is not clearly the right return type, and we may want \
299+
to tie the return lifetime to a borrow of the raw pointer"]
289300
unsafe fn as_mut<'a>(&self) -> Option<&'a mut T>;
290301
}
291302

292-
impl<T> RawPtr<T> for *const T {
303+
#[stable]
304+
impl<T> PtrExt<T> for *const T {
293305
#[inline]
306+
#[deprecated = "call ptr::null instead"]
294307
fn null() -> *const T { null() }
295308

296309
#[inline]
297-
fn is_null(&self) -> bool { *self == RawPtr::null() }
310+
#[stable]
311+
fn is_null(self) -> bool { self as uint == 0 }
298312

299313
#[inline]
300-
fn to_uint(&self) -> uint { *self as uint }
314+
#[deprecated = "use `as uint` instead"]
315+
fn to_uint(self) -> uint { self as uint }
301316

302317
#[inline]
318+
#[stable]
303319
unsafe fn offset(self, count: int) -> *const T {
304320
intrinsics::offset(self, count)
305321
}
306322

307323
#[inline]
324+
#[unstable = "return value does not necessarily convey all possible \
325+
information"]
308326
unsafe fn as_ref<'a>(&self) -> Option<&'a T> {
309327
if self.is_null() {
310328
None
@@ -314,22 +332,29 @@ impl<T> RawPtr<T> for *const T {
314332
}
315333
}
316334

317-
impl<T> RawPtr<T> for *mut T {
335+
#[stable]
336+
impl<T> PtrExt<T> for *mut T {
318337
#[inline]
338+
#[deprecated = "call ptr::null instead"]
319339
fn null() -> *mut T { null_mut() }
320340

321341
#[inline]
322-
fn is_null(&self) -> bool { *self == RawPtr::null() }
342+
#[stable]
343+
fn is_null(self) -> bool { self as uint == 0 }
323344

324345
#[inline]
325-
fn to_uint(&self) -> uint { *self as uint }
346+
#[deprecated = "use `as uint` instead"]
347+
fn to_uint(self) -> uint { self as uint }
326348

327349
#[inline]
350+
#[stable]
328351
unsafe fn offset(self, count: int) -> *mut T {
329352
intrinsics::offset(self as *const T, count) as *mut T
330353
}
331354

332355
#[inline]
356+
#[unstable = "return value does not necessarily convey all possible \
357+
information"]
333358
unsafe fn as_ref<'a>(&self) -> Option<&'a T> {
334359
if self.is_null() {
335360
None
@@ -339,8 +364,11 @@ impl<T> RawPtr<T> for *mut T {
339364
}
340365
}
341366

342-
impl<T> RawMutPtr<T> for *mut T {
367+
#[stable]
368+
impl<T> MutPtrExt<T> for *mut T {
343369
#[inline]
370+
#[unstable = "return value does not necessarily convey all possible \
371+
information"]
344372
unsafe fn as_mut<'a>(&self) -> Option<&'a mut T> {
345373
if self.is_null() {
346374
None
@@ -510,28 +538,33 @@ impl<T> PartialOrd for *mut T {
510538
/// raw `*mut T` (which conveys no particular ownership semantics).
511539
/// Useful for building abstractions like `Vec<T>` or `Box<T>`, which
512540
/// internally use raw pointers to manage the memory that they own.
541+
#[unstable = "recently added to this module"]
513542
pub struct Unique<T>(pub *mut T);
514543

515544
/// `Unique` pointers are `Send` if `T` is `Send` because the data they
516545
/// reference is unaliased. Note that this aliasing invariant is
517546
/// unenforced by the type system; the abstraction using the
518547
/// `Unique` must enforce it.
548+
#[unstable = "recently added to this module"]
519549
unsafe impl<T:Send> Send for Unique<T> { }
520550

521551
/// `Unique` pointers are `Sync` if `T` is `Sync` because the data they
522552
/// reference is unaliased. Note that this aliasing invariant is
523553
/// unenforced by the type system; the abstraction using the
524554
/// `Unique` must enforce it.
555+
#[unstable = "recently added to this module"]
525556
unsafe impl<T:Sync> Sync for Unique<T> { }
526557

527558
impl<T> Unique<T> {
528559
/// Returns a null Unique.
560+
#[unstable = "recently added to this module"]
529561
pub fn null() -> Unique<T> {
530-
Unique(RawPtr::null())
562+
Unique(null_mut())
531563
}
532564

533565
/// Return an (unsafe) pointer into the memory owned by `self`.
566+
#[unstable = "recently added to this module"]
534567
pub unsafe fn offset(self, offset: int) -> *mut T {
535-
(self.0 as *const T).offset(offset) as *mut T
568+
self.0.offset(offset)
536569
}
537570
}

‎src/libcore/slice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use ops::{FnMut, mod};
4747
use option::Option;
4848
use option::Option::{None, Some};
4949
use ptr;
50-
use ptr::RawPtr;
50+
use ptr::PtrExt;
5151
use mem;
5252
use mem::size_of;
5353
use kinds::{Sized, marker};
@@ -1334,7 +1334,7 @@ pub unsafe fn from_raw_mut_buf<'a, T>(p: &'a *mut T, len: uint) -> &'a mut [T] {
13341334
#[deprecated]
13351335
pub mod raw {
13361336
use mem::transmute;
1337-
use ptr::RawPtr;
1337+
use ptr::PtrExt;
13381338
use raw::Slice;
13391339
use ops::FnOnce;
13401340
use option::Option;

‎src/libcore/str/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use mem;
2828
use num::Int;
2929
use ops::{Fn, FnMut};
3030
use option::Option::{mod, None, Some};
31-
use ptr::RawPtr;
31+
use ptr::PtrExt;
3232
use raw::{Repr, Slice};
3333
use result::Result::{mod, Ok, Err};
3434
use slice::{mod, SliceExt};
@@ -1072,7 +1072,7 @@ const TAG_CONT_U8: u8 = 0b1000_0000u8;
10721072
/// Unsafe operations
10731073
#[deprecated]
10741074
pub mod raw {
1075-
use ptr::RawPtr;
1075+
use ptr::PtrExt;
10761076
use raw::Slice;
10771077
use slice::SliceExt;
10781078
use str::StrExt;

‎src/librustc_trans/trans/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
501501
debug!("Store {} -> {}",
502502
self.ccx.tn().val_to_string(val),
503503
self.ccx.tn().val_to_string(ptr));
504-
assert!(self.llbuilder.is_not_null());
504+
assert!(!self.llbuilder.is_null());
505505
self.count_insn("store");
506506
unsafe {
507507
llvm::LLVMBuildStore(self.llbuilder, val, ptr);
@@ -512,7 +512,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
512512
debug!("Store {} -> {}",
513513
self.ccx.tn().val_to_string(val),
514514
self.ccx.tn().val_to_string(ptr));
515-
assert!(self.llbuilder.is_not_null());
515+
assert!(!self.llbuilder.is_null());
516516
self.count_insn("store.volatile");
517517
unsafe {
518518
let insn = llvm::LLVMBuildStore(self.llbuilder, val, ptr);

‎src/librustc_trans/trans/value.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub struct Value(pub ValueRef);
2020
macro_rules! opt_val { ($e:expr) => (
2121
unsafe {
2222
match $e {
23-
p if p.is_not_null() => Some(Value(p)),
23+
p if !p.is_null() => Some(Value(p)),
2424
_ => None
2525
}
2626
}
@@ -37,7 +37,7 @@ impl Value {
3737
pub fn get_parent(self) -> Option<BasicBlock> {
3838
unsafe {
3939
match llvm::LLVMGetInstructionParent(self.get()) {
40-
p if p.is_not_null() => Some(BasicBlock(p)),
40+
p if !p.is_null() => Some(BasicBlock(p)),
4141
_ => None
4242
}
4343
}
@@ -77,7 +77,7 @@ impl Value {
7777
pub fn get_first_use(self) -> Option<Use> {
7878
unsafe {
7979
match llvm::LLVMGetFirstUse(self.get()) {
80-
u if u.is_not_null() => Some(Use(u)),
80+
u if !u.is_null() => Some(Use(u)),
8181
_ => None
8282
}
8383
}
@@ -119,7 +119,7 @@ impl Value {
119119
/// Tests if this value is a terminator instruction
120120
pub fn is_a_terminator_inst(self) -> bool {
121121
unsafe {
122-
llvm::LLVMIsATerminatorInst(self.get()).is_not_null()
122+
!llvm::LLVMIsATerminatorInst(self.get()).is_null()
123123
}
124124
}
125125
}
@@ -142,7 +142,7 @@ impl Use {
142142
pub fn get_next_use(self) -> Option<Use> {
143143
unsafe {
144144
match llvm::LLVMGetNextUse(self.get()) {
145-
u if u.is_not_null() => Some(Use(u)),
145+
u if !u.is_null() => Some(Use(u)),
146146
_ => None
147147
}
148148
}

‎src/libstd/c_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use mem;
4040
use ops::{Drop, FnOnce};
4141
use option::Option;
4242
use option::Option::{Some, None};
43-
use ptr::RawPtr;
43+
use ptr::PtrExt;
4444
use ptr;
4545
use raw;
4646
use slice::AsSlice;

‎src/libstd/collections/hash/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use num::{Int, UnsignedInt};
2323
use ops::{Deref, DerefMut, Drop};
2424
use option::Option;
2525
use option::Option::{Some, None};
26-
use ptr::{Unique, RawPtr, copy_nonoverlapping_memory, zero_memory};
26+
use ptr::{Unique, PtrExt, copy_nonoverlapping_memory, zero_memory};
2727
use ptr;
2828
use rt::heap::{allocate, deallocate};
2929

‎src/libstd/io/extensions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use num::Int;
2222
use ops::FnOnce;
2323
use option::Option;
2424
use option::Option::{Some, None};
25-
use ptr::RawPtr;
25+
use ptr::PtrExt;
2626
use result::Result::{Ok, Err};
2727
use slice::{SliceExt, AsSlice};
2828

‎src/libstd/io/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ impl<'a> Reader for &'a mut (Reader+'a) {
935935
// API yet. If so, it should be a method on Vec.
936936
unsafe fn slice_vec_capacity<'a, T>(v: &'a mut Vec<T>, start: uint, end: uint) -> &'a mut [T] {
937937
use raw::Slice;
938-
use ptr::RawPtr;
938+
use ptr::PtrExt;
939939

940940
assert!(start <= end);
941941
assert!(end <= v.capacity());

‎src/libstd/os.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ use option::Option;
4646
use option::Option::{Some, None};
4747
use path::{Path, GenericPath, BytesContainer};
4848
use sys;
49-
use ptr::RawPtr;
49+
use sys::os as os_imp;
50+
use ptr::PtrExt;
5051
use ptr;
5152
use result::Result;
5253
use result::Result::{Err, Ok};

‎src/libstd/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
#[doc(no_inline)] pub use option::Option;
7474
#[doc(no_inline)] pub use option::Option::{Some, None};
7575
#[doc(no_inline)] pub use path::{GenericPath, Path, PosixPath, WindowsPath};
76-
#[doc(no_inline)] pub use ptr::{RawPtr, RawMutPtr};
76+
#[doc(no_inline)] pub use ptr::{PtrExt, MutPtrExt};
7777
#[doc(no_inline)] pub use result::Result;
7878
#[doc(no_inline)] pub use result::Result::{Ok, Err};
7979
#[doc(no_inline)] pub use io::{Buffer, Writer, Reader, Seek, BufferPrelude};

‎src/libstd/sys/common/net.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ pub fn get_host_addresses(host: Option<&str>, servname: Option<&str>,
269269
// Collect all the results we found
270270
let mut addrs = Vec::new();
271271
let mut rp = res;
272-
while rp.is_not_null() {
272+
while !rp.is_null() {
273273
unsafe {
274274
let addr = try!(sockaddr_to_addr(mem::transmute((*rp).ai_addr),
275275
(*rp).ai_addrlen as uint));

‎src/libstd/sys/unix/backtrace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ fn print(w: &mut Writer, idx: int, addr: *mut libc::c_void) -> IoResult<()> {
244244
use iter::{Iterator, IteratorExt};
245245
use os;
246246
use path::GenericPath;
247-
use ptr::RawPtr;
247+
use ptr::PtrExt;
248248
use ptr;
249249
use slice::SliceExt;
250250

0 commit comments

Comments
 (0)
Please sign in to comment.