about summary refs log tree commit diff
path: root/src/libstd/rt
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-12-11 17:04:50 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-12-15 10:41:15 -0800
commita87786e3e993564b444763f99dae24cdcb44a791 (patch)
tree266903ba1a444bc9a1d2220055d32910e7aa194f /src/libstd/rt
parent8d52dfbace05c46754f4f6bb5a25f55906c9d7b0 (diff)
downloadrust-a87786e3e993564b444763f99dae24cdcb44a791.tar.gz
rust-a87786e3e993564b444763f99dae24cdcb44a791.zip
librustc: Remove identifiers named `box`, since it's about to become a keyword.
Diffstat (limited to 'src/libstd/rt')
-rw-r--r--src/libstd/rt/borrowck.rs17
-rw-r--r--src/libstd/rt/deque.rs6
-rw-r--r--src/libstd/rt/global_heap.rs6
-rw-r--r--src/libstd/rt/local_heap.rs40
4 files changed, 37 insertions, 32 deletions
diff --git a/src/libstd/rt/borrowck.rs b/src/libstd/rt/borrowck.rs
index 82f92bdb803..423981d9e91 100644
--- a/src/libstd/rt/borrowck.rs
+++ b/src/libstd/rt/borrowck.rs
@@ -28,7 +28,7 @@ static ALL_BITS: uint = FROZEN_BIT | MUT_BIT;
 
 #[deriving(Eq)]
 pub struct BorrowRecord {
-    priv box: *mut raw::Box<()>,
+    priv alloc: *mut raw::Box<()>,
     file: *c_char,
     priv line: size_t
 }
@@ -55,8 +55,9 @@ pub fn clear_task_borrow_list() {
 }
 
 #[cold]
-unsafe fn fail_borrowed(box: *mut raw::Box<()>, file: *c_char, line: size_t) -> ! {
-    debug_borrow("fail_borrowed: ", box, 0, 0, file, line);
+unsafe fn fail_borrowed(alloc: *mut raw::Box<()>, file: *c_char, line: size_t)
+                        -> ! {
+    debug_borrow("fail_borrowed: ", alloc, 0, 0, file, line);
 
     match try_take_task_borrow_list() {
         None => { // not recording borrows
@@ -67,7 +68,7 @@ unsafe fn fail_borrowed(box: *mut raw::Box<()>, file: *c_char, line: size_t) ->
             let mut msg = ~"borrowed";
             let mut sep = " at ";
             for entry in borrow_list.rev_iter() {
-                if entry.box == box {
+                if entry.alloc == alloc {
                     msg.push_str(sep);
                     let filename = str::raw::from_c_str(entry.file);
                     msg.push_str(filename);
@@ -153,7 +154,11 @@ pub unsafe fn record_borrow(a: *u8, old_ref_count: uint,
         debug_borrow("record_borrow:", a, old_ref_count, 0, file, line);
         swap_task_borrow_list(|borrow_list| {
             let mut borrow_list = borrow_list;
-            borrow_list.push(BorrowRecord {box: a, file: file, line: line});
+            borrow_list.push(BorrowRecord {
+                alloc: a,
+                file: file,
+                line: line,
+            });
             borrow_list
         })
     }
@@ -172,7 +177,7 @@ pub unsafe fn unrecord_borrow(a: *u8,
             let mut borrow_list = borrow_list;
             assert!(!borrow_list.is_empty());
             let br = borrow_list.pop();
-            if br.box != a || br.file != file || br.line != line {
+            if br.alloc != a || br.file != file || br.line != line {
                 let err = format!("wrong borrow found, br={:?}", br);
                 err.with_c_str(|msg_p| {
                     task::begin_unwind_raw(msg_p, file, line)
diff --git a/src/libstd/rt/deque.rs b/src/libstd/rt/deque.rs
index 44672984b64..770fc9ffa12 100644
--- a/src/libstd/rt/deque.rs
+++ b/src/libstd/rt/deque.rs
@@ -599,9 +599,9 @@ mod tests {
 
         let (threads, hits) = vec::unzip(range(0, NTHREADS).map(|_| {
             let s = s.clone();
-            let box = ~AtomicUint::new(0);
+            let unique_box = ~AtomicUint::new(0);
             let thread_box = unsafe {
-                *cast::transmute::<&~AtomicUint, **mut AtomicUint>(&box)
+                *cast::transmute::<&~AtomicUint,**mut AtomicUint>(&unique_box)
             };
             (do Thread::start {
                 unsafe {
@@ -617,7 +617,7 @@ mod tests {
                         }
                     }
                 }
-            }, box)
+            }, unique_box)
         }));
 
         let mut rng = rand::task_rng();
diff --git a/src/libstd/rt/global_heap.rs b/src/libstd/rt/global_heap.rs
index 3147e3c8a07..385bb0b276c 100644
--- a/src/libstd/rt/global_heap.rs
+++ b/src/libstd/rt/global_heap.rs
@@ -78,10 +78,10 @@ pub unsafe fn closure_exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
     let total_size = get_box_size(size, (*td).align);
     let p = malloc_raw(total_size as uint);
 
-    let box = p as *mut raw::Box<()>;
-    (*box).type_desc = td;
+    let alloc = p as *mut raw::Box<()>;
+    (*alloc).type_desc = td;
 
-    box as *c_char
+    alloc as *c_char
 }
 
 // NB: Calls to free CANNOT be allowed to fail, as throwing an exception from
diff --git a/src/libstd/rt/local_heap.rs b/src/libstd/rt/local_heap.rs
index e364137de45..f2edc6e7ede 100644
--- a/src/libstd/rt/local_heap.rs
+++ b/src/libstd/rt/local_heap.rs
@@ -59,10 +59,10 @@ impl LocalHeap {
 
     pub fn alloc(&mut self, td: *TyDesc, size: uint) -> *mut Box {
         let total_size = global_heap::get_box_size(size, unsafe { (*td).align });
-        let box = self.memory_region.malloc(total_size);
+        let alloc = self.memory_region.malloc(total_size);
         {
             // Make sure that we can't use `mybox` outside of this scope
-            let mybox: &mut Box = unsafe { cast::transmute(box) };
+            let mybox: &mut Box = unsafe { cast::transmute(alloc) };
             // Clear out this box, and move it to the front of the live
             // allocations list
             mybox.type_desc = td;
@@ -70,11 +70,11 @@ impl LocalHeap {
             mybox.prev = ptr::mut_null();
             mybox.next = self.live_allocs;
             if !self.live_allocs.is_null() {
-                unsafe { (*self.live_allocs).prev = box; }
+                unsafe { (*self.live_allocs).prev = alloc; }
             }
-            self.live_allocs = box;
+            self.live_allocs = alloc;
         }
-        return box;
+        return alloc;
     }
 
     pub fn realloc(&mut self, ptr: *mut Box, size: uint) -> *mut Box {
@@ -97,10 +97,10 @@ impl LocalHeap {
         return new_box;
     }
 
-    pub fn free(&mut self, box: *mut Box) {
+    pub fn free(&mut self, alloc: *mut Box) {
         {
             // Make sure that we can't use `mybox` outside of this scope
-            let mybox: &mut Box = unsafe { cast::transmute(box) };
+            let mybox: &mut Box = unsafe { cast::transmute(alloc) };
             assert!(!mybox.type_desc.is_null());
 
             // Unlink it from the linked list
@@ -110,7 +110,7 @@ impl LocalHeap {
             if !mybox.next.is_null() {
                 unsafe { (*mybox.next).prev = mybox.prev; }
             }
-            if self.live_allocs == box {
+            if self.live_allocs == alloc {
                 self.live_allocs = mybox.next;
             }
 
@@ -126,7 +126,7 @@ impl LocalHeap {
             mybox.type_desc = ptr::null();
         }
 
-        self.memory_region.free(box);
+        self.memory_region.free(alloc);
     }
 }
 
@@ -175,7 +175,7 @@ impl AllocHeader {
     #[cfg(not(rtdebug))]
     fn update_size(&mut self, _size: u32) {}
 
-    fn box(&mut self) -> *mut Box {
+    fn as_box(&mut self) -> *mut Box {
         let myaddr: uint = unsafe { cast::transmute(self) };
         (myaddr + AllocHeader::size()) as *mut Box
     }
@@ -187,8 +187,8 @@ impl AllocHeader {
         return (header_size + ptr_size - 1) / ptr_size * ptr_size;
     }
 
-    fn from(box: *mut Box) -> *mut AllocHeader {
-        (box as uint - AllocHeader::size()) as *mut AllocHeader
+    fn from(a_box: *mut Box) -> *mut AllocHeader {
+        (a_box as uint - AllocHeader::size()) as *mut AllocHeader
     }
 }
 
@@ -204,12 +204,12 @@ impl MemoryRegion {
         self.claim(alloc);
         self.live_allocations += 1;
 
-        return alloc.box();
+        return alloc.as_box();
     }
 
-    fn realloc(&mut self, box: *mut Box, size: uint) -> *mut Box {
-        rtassert!(!box.is_null());
-        let orig_alloc = AllocHeader::from(box);
+    fn realloc(&mut self, alloc: *mut Box, size: uint) -> *mut Box {
+        rtassert!(!alloc.is_null());
+        let orig_alloc = AllocHeader::from(alloc);
         unsafe { (*orig_alloc).assert_sane(); }
 
         let total_size = size + AllocHeader::size();
@@ -222,12 +222,12 @@ impl MemoryRegion {
         alloc.assert_sane();
         alloc.update_size(size as u32);
         self.update(alloc, orig_alloc as *AllocHeader);
-        return alloc.box();
+        return alloc.as_box();
     }
 
-    fn free(&mut self, box: *mut Box) {
-        rtassert!(!box.is_null());
-        let alloc = AllocHeader::from(box);
+    fn free(&mut self, alloc: *mut Box) {
+        rtassert!(!alloc.is_null());
+        let alloc = AllocHeader::from(alloc);
         unsafe {
             (*alloc).assert_sane();
             self.release(cast::transmute(alloc));