Skip to content

Commit 9b7c749

Browse files
committed
Rollup merge of rust-lang#22728 - vojtechkral:int-audit-thread-local, r=alexcrichton
Integer audit in `libstd/thread_local/*`, part of rust-lang#22240
2 parents 3ca5439 + e5e76e9 commit 9b7c749

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/libstd/thread_local/mod.rs

Lines changed: 9 additions & 9 deletions
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);
@@ -503,7 +503,7 @@ mod imp {
503503
unsafe fn ptr(&'static self) -> Option<*mut T> {
504504
let ptr = self.os.get() as *mut Value<T>;
505505
if !ptr.is_null() {
506-
if ptr as uint == 1 {
506+
if ptr as usize == 1 {
507507
return None
508508
}
509509
return Some(&mut (*ptr).value as *mut T);
@@ -563,7 +563,7 @@ mod tests {
563563

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

568568
FOO.with(|f| unsafe {
569569
assert_eq!(*f.get(), 1);
@@ -632,7 +632,7 @@ mod tests {
632632
thread_local!(static K2: UnsafeCell<Option<S2>> = UnsafeCell {
633633
value: None
634634
});
635-
static mut HITS: uint = 0;
635+
static mut HITS: u32 = 0;
636636

637637
impl Drop for S1 {
638638
fn drop(&mut self) {
@@ -723,8 +723,8 @@ mod dynamic_tests {
723723

724724
#[test]
725725
fn smoke() {
726-
fn square(i: int) -> int { i * i }
727-
thread_local!(static FOO: int = square(3));
726+
fn square(i: i32) -> i32 { i * i }
727+
thread_local!(static FOO: i32 = square(3));
728728

729729
FOO.with(|f| {
730730
assert_eq!(*f, 9);
@@ -733,12 +733,12 @@ mod dynamic_tests {
733733

734734
#[test]
735735
fn hashmap() {
736-
fn map() -> RefCell<HashMap<int, int>> {
736+
fn map() -> RefCell<HashMap<i32, i32>> {
737737
let mut m = HashMap::new();
738738
m.insert(1, 2);
739739
RefCell::new(m)
740740
}
741-
thread_local!(static FOO: RefCell<HashMap<int, int>> = map());
741+
thread_local!(static FOO: RefCell<HashMap<i32, i32>> = map());
742742

743743
FOO.with(|map| {
744744
assert_eq!(map.borrow()[1], 2);
@@ -747,7 +747,7 @@ mod dynamic_tests {
747747

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

752752
FOO.with(|vec| {
753753
assert_eq!(vec.borrow().len(), 3);

src/libstd/thread_local/scoped.rs

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