]> git.lizzy.rs Git - rust.git/commitdiff
remove duplicate function from std::ptr (is_null, is_not_null, offset, mut_offset)
authorJeremyLetang <letang.jeremy@gmail.com>
Mon, 10 Feb 2014 21:50:42 +0000 (16:50 -0500)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 13 Feb 2014 20:54:17 +0000 (12:54 -0800)
14 files changed:
src/doc/guide-ffi.md
src/libarena/lib.rs
src/libextra/c_vec.rs
src/librustc/metadata/loader.rs
src/librustc/middle/trans/builder.rs
src/librustuv/lib.rs
src/libserialize/ebml.rs
src/libstd/c_str.rs
src/libstd/io/extensions.rs
src/libstd/ptr.rs
src/libstd/repr.rs
src/libstd/str.rs
src/libstd/vec.rs
src/libstd/vec_ng.rs

index e22f30871baa8639c519fb754aedb54e4f841554..053a8612694ab399aff710291f4f3af61e05d1f7 100644 (file)
@@ -195,7 +195,7 @@ impl<T: Send> Unique<T> {
     pub fn new(value: T) -> Unique<T> {
         unsafe {
             let ptr = malloc(std::mem::size_of::<T>() as size_t) as *mut T;
-            assert!(!ptr::is_null(ptr));
+            assert!(!ptr.is_null());
             // `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it
             // move_val_init moves a value into this memory without
             // attempting to drop the original value.
index 6ba1c86fdf28696c75e7b2294c4f1317392cf686..b41af9eb05430f19cbcc72c8fae978b5d069a01c 100644 (file)
@@ -34,7 +34,6 @@
 use std::cell::{Cell, RefCell};
 use std::mem;
 use std::num;
-use std::ptr;
 use std::kinds::marker;
 use std::rc::Rc;
 use std::rt::global_heap;
@@ -144,7 +143,7 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
     let fill = chunk.fill.get();
 
     while idx < fill {
-        let tydesc_data: *uint = transmute(ptr::offset(buf, idx as int));
+        let tydesc_data: *uint = transmute(buf.offset(idx as int));
         let (tydesc, is_done) = un_bitpack_tydesc_ptr(*tydesc_data);
         let (size, align) = ((*tydesc).size, (*tydesc).align);
 
@@ -155,7 +154,7 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
         //debug!("freeing object: idx = {}, size = {}, align = {}, done = {}",
         //       start, size, align, is_done);
         if is_done {
-            ((*tydesc).drop_glue)(ptr::offset(buf, start as int) as *i8);
+            ((*tydesc).drop_glue)(buf.offset(start as int) as *i8);
         }
 
         // Find where the next tydesc lives
@@ -261,7 +260,7 @@ fn alloc_nonpod_inner(&mut self, n_bytes: uint, align: uint)
             //       start, n_bytes, align, head.fill);
 
             let buf = self.head.as_ptr();
-            return (ptr::offset(buf, tydesc_start as int), ptr::offset(buf, start as int));
+            return (buf.offset(tydesc_start as int), buf.offset(start as int));
         }
     }
 
index 35a6ccaa7083cb119f08c96304738cbbfe5b503c..fec5b105c4b1893f4c9f406210511f606b85f983 100644 (file)
@@ -119,7 +119,7 @@ pub unsafe fn new_with_dtor(base: *mut T, len: uint, dtor: proc()) -> CVec<T> {
     pub fn get<'a>(&'a self, ofs: uint) -> &'a T {
         assert!(ofs < self.len);
         unsafe {
-            &*ptr::mut_offset(self.base, ofs as int)
+            &*self.base.offset(ofs as int)
         }
     }
 
@@ -131,7 +131,7 @@ pub fn get<'a>(&'a self, ofs: uint) -> &'a T {
     pub fn get_mut<'a>(&'a mut self, ofs: uint) -> &'a mut T {
         assert!(ofs < self.len);
         unsafe {
-            &mut *ptr::mut_offset(self.base, ofs as int)
+            &mut *self.base.offset(ofs as int)
         }
     }
 
index abcd650ced13152712cbe2a1a2c73b675c1a619e..70b93a9813535842c5791b7e16697395b18a3102 100644 (file)
@@ -30,7 +30,6 @@
 use std::num;
 use std::option;
 use std::os::consts::{macos, freebsd, linux, android, win32};
-use std::ptr;
 use std::str;
 use std::vec;
 use flate;
@@ -340,7 +339,7 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Option<MetadataBlob> {
                 });
                 if !version_ok { return None; }
 
-                let cvbuf1 = ptr::offset(cvbuf, vlen as int);
+                let cvbuf1 = cvbuf.offset(vlen as int);
                 debug!("inflating {} bytes of compressed metadata",
                        csz - vlen);
                 vec::raw::buf_as_slice(cvbuf1, csz-vlen, |bytes| {
index e4eeaa5fded7f7fbb500cf657bd1fc5e1ba0b2fb..b8d16f9bb8006d761ea7ba62801496141d676ccd 100644 (file)
@@ -21,7 +21,6 @@
 use std::hashmap::HashMap;
 use std::libc::{c_uint, c_ulonglong, c_char};
 use syntax::codemap::Span;
-use std::ptr::is_not_null;
 
 pub struct Builder<'a> {
     llbuilder: BuilderRef,
@@ -492,7 +491,7 @@ pub fn store(&self, val: ValueRef, ptr: ValueRef) {
         debug!("Store {} -> {}",
                self.ccx.tn.val_to_str(val),
                self.ccx.tn.val_to_str(ptr));
-        assert!(is_not_null(self.llbuilder));
+        assert!(self.llbuilder.is_not_null());
         self.count_insn("store");
         unsafe {
             llvm::LLVMBuildStore(self.llbuilder, val, ptr);
@@ -503,7 +502,7 @@ pub fn volatile_store(&self, val: ValueRef, ptr: ValueRef) {
         debug!("Store {} -> {}",
                self.ccx.tn.val_to_str(val),
                self.ccx.tn.val_to_str(ptr));
-        assert!(is_not_null(self.llbuilder));
+        assert!(self.llbuilder.is_not_null());
         self.count_insn("store.volatile");
         unsafe {
             let insn = llvm::LLVMBuildStore(self.llbuilder, val, ptr);
index b463bb7fd733db129ad429414e67b33bcdc9bb30..b71dbe05ad2b665a6b8f74057a4c08290df6cb6e 100644 (file)
@@ -426,7 +426,7 @@ fn test_slice_to_uv_buf() {
         unsafe {
             let base = transmute::<*u8, *mut u8>(buf.base);
             (*base) = 1;
-            (*ptr::mut_offset(base, 1)) = 2;
+            (*base.offset(1)) = 2;
         }
 
         assert!(slice[0] == 1);
index f08f943306fcf5a10d163d2f87a38a722ada64bd..3d57a32a830b2c867162c9ca85c6ae8dadb96bf9 100644 (file)
@@ -131,7 +131,6 @@ fn vuint_at_slow(data: &[u8], start: uint) -> Res {
     }
 
     pub fn vuint_at(data: &[u8], start: uint) -> Res {
-        use std::ptr::offset;
         use std::mem::from_be32;
 
         if data.len() - start < 4 {
@@ -163,7 +162,7 @@ pub fn vuint_at(data: &[u8], start: uint) -> Res {
 
         unsafe {
             let (ptr, _): (*u8, uint) = transmute(data);
-            let ptr = offset(ptr, start as int);
+            let ptr = ptr.offset(start as int);
             let ptr: *i32 = transmute(ptr);
             let val = from_be32(*ptr) as u32;
 
index cc6cd7666d642bbbce53ac37b5c6f924fafe8bf6..fe332a60efa4468ec3f37ef8e1df608323114be9 100644 (file)
@@ -310,7 +310,7 @@ unsafe fn to_c_str_unchecked(&self) -> CString {
         let buf = malloc_raw(self_len + 1);
 
         ptr::copy_memory(buf, self.as_ptr(), self_len);
-        *ptr::mut_offset(buf, self_len as int) = 0;
+        *buf.offset(self_len as int) = 0;
 
         CString::new(buf as *libc::c_char, true)
     }
@@ -368,7 +368,7 @@ fn next(&mut self) -> Option<libc::c_char> {
         if ch == 0 {
             None
         } else {
-            self.ptr = unsafe { ptr::offset(self.ptr, 1) };
+            self.ptr = unsafe { self.ptr.offset(1) };
             Some(ch)
         }
     }
@@ -429,18 +429,18 @@ fn test_str_multistring_parsing() {
     fn test_str_to_c_str() {
         "".to_c_str().with_ref(|buf| {
             unsafe {
-                assert_eq!(*ptr::offset(buf, 0), 0);
+                assert_eq!(*buf.offset(0), 0);
             }
         });
 
         "hello".to_c_str().with_ref(|buf| {
             unsafe {
-                assert_eq!(*ptr::offset(buf, 0), 'h' as libc::c_char);
-                assert_eq!(*ptr::offset(buf, 1), 'e' as libc::c_char);
-                assert_eq!(*ptr::offset(buf, 2), 'l' as libc::c_char);
-                assert_eq!(*ptr::offset(buf, 3), 'l' as libc::c_char);
-                assert_eq!(*ptr::offset(buf, 4), 'o' as libc::c_char);
-                assert_eq!(*ptr::offset(buf, 5), 0);
+                assert_eq!(*buf.offset(0), 'h' as libc::c_char);
+                assert_eq!(*buf.offset(1), 'e' as libc::c_char);
+                assert_eq!(*buf.offset(2), 'l' as libc::c_char);
+                assert_eq!(*buf.offset(3), 'l' as libc::c_char);
+                assert_eq!(*buf.offset(4), 'o' as libc::c_char);
+                assert_eq!(*buf.offset(5), 0);
             }
         })
     }
@@ -450,28 +450,28 @@ fn test_vec_to_c_str() {
         let b: &[u8] = [];
         b.to_c_str().with_ref(|buf| {
             unsafe {
-                assert_eq!(*ptr::offset(buf, 0), 0);
+                assert_eq!(*buf.offset(0), 0);
             }
         });
 
         let _ = bytes!("hello").to_c_str().with_ref(|buf| {
             unsafe {
-                assert_eq!(*ptr::offset(buf, 0), 'h' as libc::c_char);
-                assert_eq!(*ptr::offset(buf, 1), 'e' as libc::c_char);
-                assert_eq!(*ptr::offset(buf, 2), 'l' as libc::c_char);
-                assert_eq!(*ptr::offset(buf, 3), 'l' as libc::c_char);
-                assert_eq!(*ptr::offset(buf, 4), 'o' as libc::c_char);
-                assert_eq!(*ptr::offset(buf, 5), 0);
+                assert_eq!(*buf.offset(0), 'h' as libc::c_char);
+                assert_eq!(*buf.offset(1), 'e' as libc::c_char);
+                assert_eq!(*buf.offset(2), 'l' as libc::c_char);
+                assert_eq!(*buf.offset(3), 'l' as libc::c_char);
+                assert_eq!(*buf.offset(4), 'o' as libc::c_char);
+                assert_eq!(*buf.offset(5), 0);
             }
         });
 
         let _ = bytes!("foo", 0xff).to_c_str().with_ref(|buf| {
             unsafe {
-                assert_eq!(*ptr::offset(buf, 0), 'f' as libc::c_char);
-                assert_eq!(*ptr::offset(buf, 1), 'o' as libc::c_char);
-                assert_eq!(*ptr::offset(buf, 2), 'o' as libc::c_char);
-                assert_eq!(*ptr::offset(buf, 3), 0xff as i8);
-                assert_eq!(*ptr::offset(buf, 4), 0);
+                assert_eq!(*buf.offset(0), 'f' as libc::c_char);
+                assert_eq!(*buf.offset(1), 'o' as libc::c_char);
+                assert_eq!(*buf.offset(2), 'o' as libc::c_char);
+                assert_eq!(*buf.offset(3), 0xff as i8);
+                assert_eq!(*buf.offset(4), 0);
             }
         });
     }
@@ -634,7 +634,6 @@ mod bench {
     use extra::test::BenchHarness;
     use libc;
     use prelude::*;
-    use ptr;
 
     #[inline]
     fn check(s: &str, c_str: *libc::c_char) {
@@ -642,8 +641,8 @@ fn check(s: &str, c_str: *libc::c_char) {
         for i in range(0, s.len()) {
             unsafe {
                 assert_eq!(
-                    *ptr::offset(s_buf, i as int) as libc::c_char,
-                    *ptr::offset(c_str, i as int));
+                    *s_buf.offset(i as int) as libc::c_char,
+                    *c_str.offset(i as int));
             }
         }
     }
index 240f4c65501dc29fe024be036abe50c7692a2133..da4697d0e48804491a51e8801058a6044bac11b7 100644 (file)
@@ -18,6 +18,7 @@
 use option::Option;
 use io::Reader;
 use vec::{OwnedVector, ImmutableVector};
+use ptr::RawPtr;
 
 /// An iterator that reads a single byte on each iteration,
 /// until `.read_byte()` returns `None`.
@@ -104,7 +105,7 @@ pub fn u64_from_be_bytes(data: &[u8],
                          start: uint,
                          size: uint)
                       -> u64 {
-    use ptr::{copy_nonoverlapping_memory, offset, mut_offset};
+    use ptr::{copy_nonoverlapping_memory};
     use mem::from_be64;
     use vec::MutableVector;
 
@@ -116,9 +117,9 @@ pub fn u64_from_be_bytes(data: &[u8],
 
     let mut buf = [0u8, ..8];
     unsafe {
-        let ptr = offset(data.as_ptr(), start as int);
+        let ptr = data.as_ptr().offset(start as int);
         let out = buf.as_mut_ptr();
-        copy_nonoverlapping_memory(mut_offset(out, (8 - size) as int), ptr, size);
+        copy_nonoverlapping_memory(out.offset((8 - size) as int), ptr, size);
         from_be64(*(out as *i64)) as u64
     }
 }
index 80439d698992174a18aa9a44aa00591f185b9fe0..2ba6f7d4fd64d93fa45c48cb8753269b5d9151e9 100644 (file)
 
 #[cfg(not(test))] use cmp::{Eq, Ord};
 
-/// Calculate the offset from a pointer.
-/// The `count` argument is in units of T; e.g. a `count` of 3
-/// represents a pointer offset of `3 * sizeof::<T>()` bytes.
-#[inline]
-pub unsafe fn offset<T>(ptr: *T, count: int) -> *T {
-    intrinsics::offset(ptr, count)
-}
-
-/// Calculate the offset from a mut pointer. The count *must* be in bounds or
-/// otherwise the loads of this address are undefined.
-/// The `count` argument is in units of T; e.g. a `count` of 3
-/// represents a pointer offset of `3 * sizeof::<T>()` bytes.
-#[inline]
-pub unsafe fn mut_offset<T>(ptr: *mut T, count: int) -> *mut T {
-    intrinsics::offset(ptr as *T, count) as *mut T
-}
-
 /// Return the offset of the first null pointer in `buf`.
 #[inline]
 pub unsafe fn buf_len<T>(buf: **T) -> uint {
@@ -63,7 +46,7 @@ fn clone(&self) -> *mut T {
 pub unsafe fn position<T>(buf: *T, f: |&T| -> bool) -> uint {
     let mut i = 0;
     loop {
-        if f(&(*offset(buf, i as int))) { return i; }
+        if f(&(*buf.offset(i as int))) { return i; }
         else { i += 1; }
     }
 }
@@ -76,14 +59,6 @@ pub fn null<T>() -> *T { 0 as *T }
 #[inline]
 pub fn mut_null<T>() -> *mut T { 0 as *mut T }
 
-/// Returns true if the pointer is equal to the null pointer.
-#[inline]
-pub fn is_null<T,P:RawPtr<T>>(ptr: P) -> bool { ptr.is_null() }
-
-/// Returns true if the pointer is not equal to the null pointer.
-#[inline]
-pub fn is_not_null<T,P:RawPtr<T>>(ptr: P) -> bool { ptr.is_not_null() }
-
 /**
  * Copies data from one location to another.
  *
@@ -206,7 +181,7 @@ pub unsafe fn array_each_with_len<T>(arr: **T, len: uint, cb: |*T|) {
     }
     //let start_ptr = *arr;
     for e in range(0, len) {
-        let n = offset(arr, e as int);
+        let n = arr.offset(e as int);
         cb(*n);
     }
     debug!("array_each_with_len: after iterate");
@@ -278,7 +253,7 @@ unsafe fn to_option(&self) -> Option<&T> {
     /// Calculates the offset from a pointer. The offset *must* be in-bounds of
     /// the object, or one-byte-past-the-end.
     #[inline]
-    unsafe fn offset(self, count: int) -> *T { offset(self, count) }
+    unsafe fn offset(self, count: int) -> *T { intrinsics::offset(self, count) }
 }
 
 /// Extension methods for mutable pointers
@@ -323,7 +298,7 @@ unsafe fn to_option(&self) -> Option<&T> {
     /// This method should be preferred over `offset` when the guarantee can be
     /// satisfied, to enable better optimization.
     #[inline]
-    unsafe fn offset(self, count: int) -> *mut T { mut_offset(self, count) }
+    unsafe fn offset(self, count: int) -> *mut T { intrinsics::offset(self as *T, count) as *mut T }
 }
 
 // Equality for pointers
@@ -478,14 +453,14 @@ struct Pair {
             let v0 = ~[32000u16, 32001u16, 32002u16];
             let mut v1 = ~[0u16, 0u16, 0u16];
 
-            copy_memory(mut_offset(v1.as_mut_ptr(), 1),
-                        offset(v0.as_ptr(), 1), 1);
+            copy_memory(v1.as_mut_ptr().offset(1),
+                        v0.as_ptr().offset(1), 1);
             assert!((v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16));
             copy_memory(v1.as_mut_ptr(),
-                        offset(v0.as_ptr(), 2), 1);
+                        v0.as_ptr().offset(2), 1);
             assert!((v1[0] == 32002u16 && v1[1] == 32001u16 &&
                      v1[2] == 0u16));
-            copy_memory(mut_offset(v1.as_mut_ptr(), 2),
+            copy_memory(v1.as_mut_ptr().offset(2),
                         v0.as_ptr(), 1u);
             assert!((v1[0] == 32002u16 && v1[1] == 32001u16 &&
                      v1[2] == 32000u16));
@@ -525,7 +500,7 @@ fn test_is_null() {
         assert!(p.is_null());
         assert!(!p.is_not_null());
 
-        let q = unsafe { offset(p, 1) };
+        let q = unsafe { p.offset(1) };
         assert!(!q.is_null());
         assert!(q.is_not_null());
 
index dc745ff548f02b0a39de4254d3999a89b1b037c7..58c00177b90165578dd5f0bf23000352ee355125 100644 (file)
@@ -23,6 +23,7 @@
 use iter::Iterator;
 use option::{Some, None, Option};
 use ptr;
+use ptr::RawPtr;
 use reflect;
 use reflect::{MovePtr, align};
 use result::{Ok, Err};
@@ -221,7 +222,7 @@ pub fn write_vec_range(&mut self, ptr: *(), len: uint, inner: *TyDesc) -> bool {
                 if_ok!(self, self.writer.write(", ".as_bytes()));
             }
             self.visit_ptr_inner(p as *u8, inner);
-            p = align(unsafe { ptr::offset(p, sz as int) as uint }, al) as *u8;
+            p = align(unsafe { p.offset(sz as int) as uint }, al) as *u8;
             left -= dec;
         }
         if_ok!(self, self.writer.write([']' as u8]));
index 4daa3f8a36ad2b8f289511c5c9ff1f847d6a7234..0d263d94ccf0f26992fff841b83c63de0c51d0d2 100644 (file)
@@ -1242,7 +1242,7 @@ pub unsafe fn from_c_str(buf: *libc::c_char) -> ~str {
         let mut i = 0;
         while *curr != 0 {
             i += 1;
-            curr = ptr::offset(buf, i);
+            curr = buf.offset(i);
         }
         from_buf_len(buf as *u8, i as uint)
     }
@@ -1272,7 +1272,7 @@ pub unsafe fn c_str_to_static_slice(s: *libc::c_char) -> &'static str {
         let mut len = 0u;
         while *curr != 0u8 {
             len += 1u;
-            curr = ptr::offset(s, len as int);
+            curr = s.offset(len as int);
         }
         let v = Slice { data: s, len: len };
         assert!(is_utf8(::cast::transmute(v)));
@@ -2921,7 +2921,6 @@ fn default() -> ~str { ~"" }
 mod tests {
     use iter::AdditiveIterator;
     use prelude::*;
-    use ptr;
     use str::*;
 
     #[test]
@@ -3549,11 +3548,11 @@ fn test_as_bytes_fail() {
     fn test_as_ptr() {
         let buf = "hello".as_ptr();
         unsafe {
-            assert_eq!(*ptr::offset(buf, 0), 'h' as u8);
-            assert_eq!(*ptr::offset(buf, 1), 'e' as u8);
-            assert_eq!(*ptr::offset(buf, 2), 'l' as u8);
-            assert_eq!(*ptr::offset(buf, 3), 'l' as u8);
-            assert_eq!(*ptr::offset(buf, 4), 'o' as u8);
+            assert_eq!(*buf.offset(0), 'h' as u8);
+            assert_eq!(*buf.offset(1), 'e' as u8);
+            assert_eq!(*buf.offset(2), 'l' as u8);
+            assert_eq!(*buf.offset(3), 'l' as u8);
+            assert_eq!(*buf.offset(4), 'o' as u8);
         }
     }
 
index 75993cdada24d9ae0bd665b2910bbd59556af075..c67b19933d37fe352d09177988ae2f892747534a 100644 (file)
@@ -139,7 +139,7 @@ pub fn from_fn<T>(n_elts: uint, op: |uint| -> T) -> ~[T] {
             &mut i, (),
             |i, ()| while *i < n_elts {
                 mem::move_val_init(
-                    &mut(*ptr::mut_offset(p, *i as int)),
+                    &mut(*p.offset(*i as int)),
                     op(*i));
                 *i += 1u;
             },
@@ -167,7 +167,7 @@ pub fn from_elem<T:Clone>(n_elts: uint, t: T) -> ~[T] {
             &mut i, (),
             |i, ()| while *i < n_elts {
                 mem::move_val_init(
-                    &mut(*ptr::mut_offset(p, *i as int)),
+                    &mut(*p.offset(*i as int)),
                     t.clone());
                 *i += 1u;
             },
@@ -1497,7 +1497,7 @@ unsafe fn push_fast<T>(this: &mut ~[T], t: T) {
             let fill = (**repr).fill;
             (**repr).fill += mem::nonzero_size_of::<T>();
             let p = to_unsafe_ptr(&((**repr).data));
-            let p = ptr::offset(p, fill as int) as *mut T;
+            let p = p.offset(fill as int) as *mut T;
             mem::move_val_init(&mut(*p), t);
         }
     }
@@ -1511,7 +1511,7 @@ fn push_all_move(&mut self, mut rhs: ~[T]) {
         unsafe { // Note: infallible.
             let self_p = self.as_mut_ptr();
             let rhs_p = rhs.as_ptr();
-            ptr::copy_memory(ptr::mut_offset(self_p, self_len as int), rhs_p, rhs_len);
+            ptr::copy_memory(self_p.offset(self_len as int), rhs_p, rhs_len);
             self.set_len(new_len);
             rhs.set_len(0);
         }
@@ -1798,11 +1798,11 @@ fn dedup(&mut self) {
             let mut w = 1;
 
             while r < ln {
-                let p_r = ptr::mut_offset(p, r as int);
-                let p_wm1 = ptr::mut_offset(p, (w - 1) as int);
+                let p_r = p.offset(r as int);
+                let p_wm1 = p.offset((w - 1) as int);
                 if *p_r != *p_wm1 {
                     if r != w {
-                        let p_w = ptr::mut_offset(p_wm1, 1);
+                        let p_w = p_wm1.offset(1);
                         mem::swap(&mut *p_r, &mut *p_w);
                     }
                     w += 1;
@@ -2385,7 +2385,7 @@ fn move_from(self, mut src: ~[T], start: uint, end: uint) -> uint {
 
     #[inline]
     unsafe fn unsafe_mut_ref(self, index: uint) -> &'a mut T {
-        cast::transmute(ptr::mut_offset(self.repr().data as *mut T, index as int))
+        cast::transmute((self.repr().data as *mut T).offset(index as int))
     }
 
     #[inline]
@@ -2486,6 +2486,7 @@ pub unsafe fn from_buf<T>(ptr: *T, elts: uint) -> ~[T] {
 pub mod raw {
     use cast;
     use ptr;
+    use ptr::RawPtr;
     use vec::{with_capacity, MutableVector, OwnedVector};
     use unstable::raw::Slice;
 
@@ -2544,7 +2545,7 @@ pub unsafe fn from_buf_raw<T>(ptr: *T, elts: uint) -> ~[T] {
     pub unsafe fn shift_ptr<T>(slice: &mut Slice<T>) -> *T {
         if slice.len == 0 { fail!("shift on empty slice"); }
         let head: *T = slice.data;
-        slice.data = ptr::offset(slice.data, 1);
+        slice.data = slice.data.offset(1);
         slice.len -= 1;
         head
     }
@@ -2556,7 +2557,7 @@ pub unsafe fn shift_ptr<T>(slice: &mut Slice<T>) -> *T {
      */
     pub unsafe fn pop_ptr<T>(slice: &mut Slice<T>) -> *T {
         if slice.len == 0 { fail!("pop on empty slice"); }
-        let tail: *T = ptr::offset(slice.data, (slice.len - 1) as int);
+        let tail: *T = slice.data.offset((slice.len - 1) as int);
         slice.len -= 1;
         tail
     }
index 90bc5836240124e6c6c43e798f9367286a57e113..25ba45021b3fa0364bb9571ec92aa5f87e556727 100644 (file)
@@ -22,7 +22,8 @@
 use rt::global_heap::{malloc_raw, realloc_raw};
 use vec::{ImmutableVector, Items, MutableVector};
 use unstable::raw::Slice;
-use ptr::{offset, read_ptr};
+use ptr::read_ptr;
+use ptr::RawPtr;
 use libc::{free, c_void};
 
 pub struct Vec<T> {
@@ -135,7 +136,7 @@ pub fn push(&mut self, value: T) {
         }
 
         unsafe {
-            let end = offset(self.ptr as *T, self.len as int) as *mut T;
+            let end = (self.ptr as *T).offset(self.len as int) as *mut T;
             move_val_init(&mut *end, value);
             self.len += 1;
         }