Skip to content

Commit e5e76e9

Browse files
committed
Integer audit in libstd/thread_local/*, part of rust-lang#22240
1 parent f0f7ca2 commit e5e76e9

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

Diff for: src/libstd/thread_local/mod.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub mod __impl {
7474
/// use std::cell::RefCell;
7575
/// use std::thread;
7676
///
77-
/// thread_local!(static FOO: RefCell<uint> = RefCell::new(1));
77+
/// thread_local!(static FOO: RefCell<u32> = RefCell::new(1));
7878
///
7979
/// FOO.with(|f| {
8080
/// assert_eq!(*f.borrow(), 1);
@@ -501,7 +501,7 @@ mod imp {
501501
unsafe fn ptr(&'static self) -> Option<*mut T> {
502502
let ptr = self.os.get() as *mut Value<T>;
503503
if !ptr.is_null() {
504-
if ptr as uint == 1 {
504+
if ptr as usize == 1 {
505505
return None
506506
}
507507
return Some(&mut (*ptr).value as *mut T);
@@ -561,7 +561,7 @@ mod tests {
561561

562562
#[test]
563563
fn smoke_no_dtor() {
564-
thread_local!(static FOO: UnsafeCell<int> = UnsafeCell { value: 1 });
564+
thread_local!(static FOO: UnsafeCell<i32> = UnsafeCell { value: 1 });
565565

566566
FOO.with(|f| unsafe {
567567
assert_eq!(*f.get(), 1);
@@ -630,7 +630,7 @@ mod tests {
630630
thread_local!(static K2: UnsafeCell<Option<S2>> = UnsafeCell {
631631
value: None
632632
});
633-
static mut HITS: uint = 0;
633+
static mut HITS: u32 = 0;
634634

635635
impl Drop for S1 {
636636
fn drop(&mut self) {
@@ -721,8 +721,8 @@ mod dynamic_tests {
721721

722722
#[test]
723723
fn smoke() {
724-
fn square(i: int) -> int { i * i }
725-
thread_local!(static FOO: int = square(3));
724+
fn square(i: i32) -> i32 { i * i }
725+
thread_local!(static FOO: i32 = square(3));
726726

727727
FOO.with(|f| {
728728
assert_eq!(*f, 9);
@@ -731,12 +731,12 @@ mod dynamic_tests {
731731

732732
#[test]
733733
fn hashmap() {
734-
fn map() -> RefCell<HashMap<int, int>> {
734+
fn map() -> RefCell<HashMap<i32, i32>> {
735735
let mut m = HashMap::new();
736736
m.insert(1, 2);
737737
RefCell::new(m)
738738
}
739-
thread_local!(static FOO: RefCell<HashMap<int, int>> = map());
739+
thread_local!(static FOO: RefCell<HashMap<i32, i32>> = map());
740740

741741
FOO.with(|map| {
742742
assert_eq!(map.borrow()[1], 2);
@@ -745,7 +745,7 @@ mod dynamic_tests {
745745

746746
#[test]
747747
fn refcell_vec() {
748-
thread_local!(static FOO: RefCell<Vec<uint>> = RefCell::new(vec![1, 2, 3]));
748+
thread_local!(static FOO: RefCell<Vec<u32>> = RefCell::new(vec![1, 2, 3]));
749749

750750
FOO.with(|vec| {
751751
assert_eq!(vec.borrow().len(), 3);

Diff for: src/libstd/thread_local/scoped.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
//! # Example
2525
//!
2626
//! ```
27-
//! scoped_thread_local!(static FOO: uint);
27+
//! scoped_thread_local!(static FOO: u32);
2828
//!
2929
//! // Initially each scoped slot is empty.
3030
//! assert!(!FOO.is_set());
@@ -140,7 +140,7 @@ impl<T> Key<T> {
140140
/// # Example
141141
///
142142
/// ```
143-
/// scoped_thread_local!(static FOO: uint);
143+
/// scoped_thread_local!(static FOO: u32);
144144
///
145145
/// FOO.set(&100, || {
146146
/// let val = FOO.with(|v| *v);
@@ -192,7 +192,7 @@ impl<T> Key<T> {
192192
/// # Example
193193
///
194194
/// ```no_run
195-
/// scoped_thread_local!(static FOO: uint);
195+
/// scoped_thread_local!(static FOO: u32);
196196
///
197197
/// FOO.with(|slot| {
198198
/// // work with `slot`
@@ -269,11 +269,11 @@ mod tests {
269269
use cell::Cell;
270270
use prelude::v1::*;
271271

272-
scoped_thread_local!(static FOO: uint);
272+
scoped_thread_local!(static FOO: u32);
273273

274274
#[test]
275275
fn smoke() {
276-
scoped_thread_local!(static BAR: uint);
276+
scoped_thread_local!(static BAR: u32);
277277

278278
assert!(!BAR.is_set());
279279
BAR.set(&1, || {
@@ -287,7 +287,7 @@ mod tests {
287287

288288
#[test]
289289
fn cell_allowed() {
290-
scoped_thread_local!(static BAR: Cell<uint>);
290+
scoped_thread_local!(static BAR: Cell<u32>);
291291

292292
BAR.set(&Cell::new(1), || {
293293
BAR.with(|slot| {

0 commit comments

Comments
 (0)