Skip to content

Commit 84cb71b

Browse files
committed
Audit integer type usage in core::ptr
1 parent cf636c2 commit 84cb71b

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/libcore/ptr.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
//! ## 1. Coerce a reference (`&T`) or mutable reference (`&mut T`).
2828
//!
2929
//! ```
30-
//! let my_num: int = 10;
31-
//! let my_num_ptr: *const int = &my_num;
32-
//! let mut my_speed: int = 88;
33-
//! let my_speed_ptr: *mut int = &mut my_speed;
30+
//! let my_num: i32 = 10;
31+
//! let my_num_ptr: *const i32 = &my_num;
32+
//! let mut my_speed: i32 = 88;
33+
//! let my_speed_ptr: *mut i32 = &mut my_speed;
3434
//! ```
3535
//!
3636
//! This does not take ownership of the original allocation
@@ -49,15 +49,15 @@
4949
//! use std::mem;
5050
//!
5151
//! unsafe {
52-
//! let my_num: Box<int> = Box::new(10);
53-
//! let my_num: *const int = mem::transmute(my_num);
54-
//! let my_speed: Box<int> = Box::new(88);
55-
//! let my_speed: *mut int = mem::transmute(my_speed);
52+
//! let my_num: Box<i32> = Box::new(10);
53+
//! let my_num: *const i32 = mem::transmute(my_num);
54+
//! let my_speed: Box<i32> = Box::new(88);
55+
//! let my_speed: *mut i32 = mem::transmute(my_speed);
5656
//!
5757
//! // By taking ownership of the original `Box<T>` though
5858
//! // we are obligated to transmute it back later to be destroyed.
59-
//! drop(mem::transmute::<_, Box<int>>(my_speed));
60-
//! drop(mem::transmute::<_, Box<int>>(my_num));
59+
//! drop(mem::transmute::<_, Box<i32>>(my_speed));
60+
//! drop(mem::transmute::<_, Box<i32>>(my_num));
6161
//! }
6262
//! ```
6363
//!
@@ -73,7 +73,7 @@
7373
//!
7474
//! fn main() {
7575
//! unsafe {
76-
//! let my_num: *mut int = libc::malloc(mem::size_of::<int>() as libc::size_t) as *mut int;
76+
//! let my_num: *mut i32 = libc::malloc(mem::size_of::<i32>() as libc::size_t) as *mut i32;
7777
//! if my_num.is_null() {
7878
//! panic!("failed to allocate memory");
7979
//! }
@@ -117,7 +117,7 @@ pub use intrinsics::set_memory;
117117
/// ```
118118
/// use std::ptr;
119119
///
120-
/// let p: *const int = ptr::null();
120+
/// let p: *const i32 = ptr::null();
121121
/// assert!(p.is_null());
122122
/// ```
123123
#[inline]
@@ -131,7 +131,7 @@ pub fn null<T>() -> *const T { 0 as *const T }
131131
/// ```
132132
/// use std::ptr;
133133
///
134-
/// let p: *mut int = ptr::null_mut();
134+
/// let p: *mut i32 = ptr::null_mut();
135135
/// assert!(p.is_null());
136136
/// ```
137137
#[inline]
@@ -148,7 +148,7 @@ pub fn null_mut<T>() -> *mut T { 0 as *mut T }
148148
#[inline]
149149
#[unstable(feature = "core",
150150
reason = "may play a larger role in std::ptr future extensions")]
151-
pub unsafe fn zero_memory<T>(dst: *mut T, count: uint) {
151+
pub unsafe fn zero_memory<T>(dst: *mut T, count: usize) {
152152
set_memory(dst, 0, count);
153153
}
154154

@@ -276,7 +276,7 @@ pub trait PtrExt: Sized {
276276
/// Otherwise `offset` invokes Undefined Behaviour, regardless of whether
277277
/// the pointer is used.
278278
#[stable(feature = "rust1", since = "1.0.0")]
279-
unsafe fn offset(self, count: int) -> Self;
279+
unsafe fn offset(self, count: isize) -> Self;
280280
}
281281

282282
/// Methods on mutable raw pointers
@@ -303,11 +303,11 @@ impl<T> PtrExt for *const T {
303303

304304
#[inline]
305305
#[stable(feature = "rust1", since = "1.0.0")]
306-
fn is_null(self) -> bool { self as uint == 0 }
306+
fn is_null(self) -> bool { self as usize == 0 }
307307

308308
#[inline]
309309
#[stable(feature = "rust1", since = "1.0.0")]
310-
unsafe fn offset(self, count: int) -> *const T {
310+
unsafe fn offset(self, count: isize) -> *const T {
311311
intrinsics::offset(self, count)
312312
}
313313

@@ -330,11 +330,11 @@ impl<T> PtrExt for *mut T {
330330

331331
#[inline]
332332
#[stable(feature = "rust1", since = "1.0.0")]
333-
fn is_null(self) -> bool { self as uint == 0 }
333+
fn is_null(self) -> bool { self as usize == 0 }
334334

335335
#[inline]
336336
#[stable(feature = "rust1", since = "1.0.0")]
337-
unsafe fn offset(self, count: int) -> *mut T {
337+
unsafe fn offset(self, count: isize) -> *mut T {
338338
intrinsics::offset(self, count) as *mut T
339339
}
340340

@@ -553,7 +553,7 @@ impl<T> Unique<T> {
553553
/// Return an (unsafe) pointer into the memory owned by `self`.
554554
#[unstable(feature = "core",
555555
reason = "recently added to this module")]
556-
pub unsafe fn offset(self, offset: int) -> *mut T {
556+
pub unsafe fn offset(self, offset: isize) -> *mut T {
557557
self.ptr.offset(offset)
558558
}
559559
}

0 commit comments

Comments
 (0)