From f82e2310b3b35bc1d137712576d2d16b82e03fcb Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Wed, 18 Feb 2015 14:37:05 +0100 Subject: [PATCH 1/4] Audit `core::borrow` for use of `int/uint`: use `i32` in doc example. --- src/libcore/borrow.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/borrow.rs b/src/libcore/borrow.rs index 035443e9c3f35..3131952d94dbb 100644 --- a/src/libcore/borrow.rs +++ b/src/libcore/borrow.rs @@ -124,7 +124,7 @@ impl ToOwned for T where T: Clone { /// ```rust /// use std::borrow::Cow; /// -/// fn abs_all(input: &mut Cow, [int]>) { +/// fn abs_all(input: &mut Cow, [i32]>) { /// for i in 0..input.len() { /// let v = input[i]; /// if v < 0 { From 343909bca1a3903bc6df51007723601ac5a103c0 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Wed, 18 Feb 2015 14:39:06 +0100 Subject: [PATCH 2/4] Audit `core::cmp` for `int/uint`. * cast 3-valued `core::cmp::Ordering` to `i32`, not `int`. * use `isize`/`usize` in the impl macros. --- src/libcore/cmp.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 19ec245300d02..b37bad5f7546c 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -215,7 +215,7 @@ impl Ord for Ordering { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn cmp(&self, other: &Ordering) -> Ordering { - (*self as int).cmp(&(*other as int)) + (*self as i32).cmp(&(*other as i32)) } } @@ -224,7 +224,7 @@ impl PartialOrd for Ordering { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn partial_cmp(&self, other: &Ordering) -> Option { - (*self as int).partial_cmp(&(*other as int)) + (*self as i32).partial_cmp(&(*other as i32)) } } @@ -482,7 +482,7 @@ mod impls { } partial_eq_impl! { - bool char uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 + bool char usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } macro_rules! eq_impl { @@ -492,7 +492,7 @@ mod impls { )*) } - eq_impl! { () bool char uint u8 u16 u32 u64 int i8 i16 i32 i64 } + eq_impl! { () bool char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } macro_rules! partial_ord_impl { ($($t:ty)*) => ($( @@ -535,7 +535,7 @@ mod impls { } } - partial_ord_impl! { char uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } + partial_ord_impl! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } macro_rules! ord_impl { ($($t:ty)*) => ($( @@ -565,7 +565,7 @@ mod impls { } } - ord_impl! { char uint u8 u16 u32 u64 int i8 i16 i32 i64 } + ord_impl! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } // & pointers From e240cb919b58975a0b647a613841da8819b672cf Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Wed, 18 Feb 2015 14:41:13 +0100 Subject: [PATCH 3/4] Audit `core::default` for `int`/`uint` usage. * Use `i32` (`u32`) in doc examples, not `int` (`u32`). * Switch impl macros to use `isize`/`usize` rather than `int`/`uint`. --- src/libcore/default.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libcore/default.rs b/src/libcore/default.rs index d79b613f58949..7f46d9cbe5021 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs @@ -16,7 +16,7 @@ //! //! ``` //! struct SomeOptions { -//! foo: int, +//! foo: i32, //! bar: f32, //! } //! ``` @@ -28,7 +28,7 @@ //! //! #[derive(Default)] //! struct SomeOptions { -//! foo: int, +//! foo: i32, //! bar: f32, //! } //! @@ -56,7 +56,7 @@ //! //! #[derive(Default)] //! struct SomeOptions { -//! foo: int, +//! foo: i32, //! bar: f32, //! baz: Kind, //! } @@ -73,7 +73,7 @@ //! # use std::default::Default; //! # #[derive(Default)] //! # struct SomeOptions { -//! # foo: int, +//! # foo: i32, //! # bar: f32, //! # } //! fn main() { @@ -93,7 +93,7 @@ /// ``` /// #[derive(Default)] /// struct SomeOptions { -/// foo: int, +/// foo: i32, /// bar: f32, /// } /// ``` @@ -113,7 +113,7 @@ pub trait Default { /// /// let i: i8 = Default::default(); /// let (x, y): (Option, f64) = Default::default(); - /// let (a, b, (c, d)): (int, uint, (bool, bool)) = Default::default(); + /// let (a, b, (c, d)): (i32, u32, (bool, bool)) = Default::default(); /// ``` /// /// Making your own: @@ -150,13 +150,13 @@ default_impl! { (), () } default_impl! { bool, false } default_impl! { char, '\x00' } -default_impl! { uint, 0 } +default_impl! { usize, 0 } default_impl! { u8, 0 } default_impl! { u16, 0 } default_impl! { u32, 0 } default_impl! { u64, 0 } -default_impl! { int, 0 } +default_impl! { isize, 0 } default_impl! { i8, 0 } default_impl! { i16, 0 } default_impl! { i32, 0 } From fc0f6e86b6aead84fa0692340a30cce6d3622365 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Wed, 18 Feb 2015 14:43:43 +0100 Subject: [PATCH 4/4] Audit `core::intrinsics` for `int`/`uint`: `size_of`/`align_of` use `usize`. Likewise, `fn offset` takes an `isize`. --- src/libcore/intrinsics.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 050c144b74299..b2ee95963878e 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -50,10 +50,10 @@ pub type GlueFn = extern "Rust" fn(*const i8); #[derive(Copy)] pub struct TyDesc { // sizeof(T) - pub size: uint, + pub size: usize, // alignof(T) - pub align: uint, + pub align: usize, // Called when a value of type `T` is no longer needed pub drop_glue: GlueFn, @@ -186,15 +186,15 @@ extern "rust-intrinsic" { /// would *exactly* overwrite a value. When laid out in vectors /// and structures there may be additional padding between /// elements. - pub fn size_of() -> uint; + pub fn size_of() -> usize; /// Move a value to an uninitialized memory location. /// /// Drop glue is not run on the destination. pub fn move_val_init(dst: &mut T, src: T); - pub fn min_align_of() -> uint; - pub fn pref_align_of() -> uint; + pub fn min_align_of() -> usize; + pub fn pref_align_of() -> usize; /// Get a static pointer to a type descriptor. pub fn get_tydesc() -> *const TyDesc; @@ -253,7 +253,7 @@ extern "rust-intrinsic" { /// /// This is implemented as an intrinsic to avoid converting to and from an /// integer, since the conversion would throw away aliasing information. - pub fn offset(dst: *const T, offset: int) -> *const T; + pub fn offset(dst: *const T, offset: isize) -> *const T; /// Copies `count * size_of` bytes from `src` to `dst`. The source /// and destination may *not* overlap. @@ -294,7 +294,7 @@ extern "rust-intrinsic" { /// } /// ``` #[unstable(feature = "core")] - pub fn copy_nonoverlapping_memory(dst: *mut T, src: *const T, count: uint); + pub fn copy_nonoverlapping_memory(dst: *mut T, src: *const T, count: usize); /// Copies `count * size_of` bytes from `src` to `dst`. The source /// and destination may overlap. @@ -324,13 +324,13 @@ extern "rust-intrinsic" { /// ``` /// #[unstable(feature = "core")] - pub fn copy_memory(dst: *mut T, src: *const T, count: uint); + pub fn copy_memory(dst: *mut T, src: *const T, count: usize); /// Invokes memset on the specified pointer, setting `count * size_of::()` /// bytes of memory starting at `dst` to `c`. #[unstable(feature = "core", reason = "uncertain about naming and semantics")] - pub fn set_memory(dst: *mut T, val: u8, count: uint); + pub fn set_memory(dst: *mut T, val: u8, count: usize); /// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with /// a size of `count` * `size_of::()` and an alignment of @@ -338,19 +338,19 @@ extern "rust-intrinsic" { /// /// The volatile parameter parameter is set to `true`, so it will not be optimized out. pub fn volatile_copy_nonoverlapping_memory(dst: *mut T, src: *const T, - count: uint); + count: usize); /// Equivalent to the appropriate `llvm.memmove.p0i8.0i8.*` intrinsic, with /// a size of `count` * `size_of::()` and an alignment of /// `min_align_of::()` /// /// The volatile parameter parameter is set to `true`, so it will not be optimized out. - pub fn volatile_copy_memory(dst: *mut T, src: *const T, count: uint); + pub fn volatile_copy_memory(dst: *mut T, src: *const T, count: usize); /// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a /// size of `count` * `size_of::()` and an alignment of /// `min_align_of::()`. /// /// The volatile parameter parameter is set to `true`, so it will not be optimized out. - pub fn volatile_set_memory(dst: *mut T, val: u8, count: uint); + pub fn volatile_set_memory(dst: *mut T, val: u8, count: usize); /// Perform a volatile load from the `src` pointer. pub fn volatile_load(src: *const T) -> T;