Skip to content

Audit core mem, nonzero, and cell modules for proper integer usage #22401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@
//! use std::cell::RefCell;
//!
//! struct Graph {
//! edges: Vec<(uint, uint)>,
//! span_tree_cache: RefCell<Option<Vec<(uint, uint)>>>
//! edges: Vec<(i32, i32)>,
//! span_tree_cache: RefCell<Option<Vec<(i32, i32)>>>
//! }
//!
//! impl Graph {
//! fn minimum_spanning_tree(&self) -> Vec<(uint, uint)> {
//! fn minimum_spanning_tree(&self) -> Vec<(i32, i32)> {
//! // Create a new scope to contain the lifetime of the
//! // dynamic borrow
//! {
Expand All @@ -104,7 +104,7 @@
//! // This is the major hazard of using `RefCell`.
//! self.minimum_spanning_tree()
//! }
//! # fn calc_span_tree(&self) -> Vec<(uint, uint)> { vec![] }
//! # fn calc_span_tree(&self) -> Vec<(i32, i32)> { vec![] }
//! }
//! ```
//!
Expand All @@ -125,7 +125,7 @@
//!
//! struct RcBox<T> {
//! value: T,
//! refcount: Cell<uint>
//! refcount: Cell<usize>
//! }
//!
//! impl<T> Clone for Rc<T> {
Expand Down Expand Up @@ -279,8 +279,8 @@ pub enum BorrowState {
}

// Values [1, MAX-1] represent the number of `Ref` active
// (will not outgrow its range since `uint` is the size of the address space)
type BorrowFlag = uint;
// (will not outgrow its range since `usize` is the size of the address space)
type BorrowFlag = usize;
const UNUSED: BorrowFlag = 0;
const WRITING: BorrowFlag = -1;

Expand Down
16 changes: 8 additions & 8 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub use intrinsics::forget;
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn size_of<T>() -> uint {
pub fn size_of<T>() -> usize {
unsafe { intrinsics::size_of::<T>() }
}

Expand All @@ -58,7 +58,7 @@ pub fn size_of<T>() -> uint {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn size_of_val<T>(_val: &T) -> uint {
pub fn size_of_val<T>(_val: &T) -> usize {
size_of::<T>()
}

Expand All @@ -75,7 +75,7 @@ pub fn size_of_val<T>(_val: &T) -> uint {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn min_align_of<T>() -> uint {
pub fn min_align_of<T>() -> usize {
unsafe { intrinsics::min_align_of::<T>() }
}

Expand All @@ -90,7 +90,7 @@ pub fn min_align_of<T>() -> uint {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn min_align_of_val<T>(_val: &T) -> uint {
pub fn min_align_of_val<T>(_val: &T) -> usize {
min_align_of::<T>()
}

Expand All @@ -108,7 +108,7 @@ pub fn min_align_of_val<T>(_val: &T) -> uint {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn align_of<T>() -> uint {
pub fn align_of<T>() -> usize {
// We use the preferred alignment as the default alignment for a type. This
// appears to be what clang migrated towards as well:
//
Expand All @@ -130,7 +130,7 @@ pub fn align_of<T>() -> uint {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn align_of_val<T>(_val: &T) -> uint {
pub fn align_of_val<T>(_val: &T) -> usize {
align_of::<T>()
}

Expand All @@ -150,7 +150,7 @@ pub fn align_of_val<T>(_val: &T) -> uint {
/// ```
/// use std::mem;
///
/// let x: int = unsafe { mem::zeroed() };
/// let x: i32 = unsafe { mem::zeroed() };
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -171,7 +171,7 @@ pub unsafe fn zeroed<T>() -> T {
/// ```
/// use std::mem;
///
/// let x: int = unsafe { mem::uninitialized() };
/// let x: i32 = unsafe { mem::uninitialized() };
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/nonzero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pub unsafe trait Zeroable {}
unsafe impl<T> Zeroable for *const T {}
unsafe impl<T> Zeroable for *mut T {}
unsafe impl<T> Zeroable for Unique<T> { }
unsafe impl Zeroable for int {}
unsafe impl Zeroable for uint {}
unsafe impl Zeroable for isize {}
unsafe impl Zeroable for usize {}
unsafe impl Zeroable for i8 {}
unsafe impl Zeroable for u8 {}
unsafe impl Zeroable for i16 {}
Expand Down