diff options
| author | bors <bors@rust-lang.org> | 2014-06-28 20:11:34 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-06-28 20:11:34 +0000 |
| commit | fe8bc178014dc2c5badd8443329c179478a40cc4 (patch) | |
| tree | b5bfc8f15cc996fe751306924595f81bcc558a27 /src/libcore | |
| parent | de337f3ddfbef800a8cf731e0b593e341af1e3e5 (diff) | |
| parent | 0dfc90ab15475aa64bea393671463a8e9784ae3f (diff) | |
| download | rust-fe8bc178014dc2c5badd8443329c179478a40cc4.tar.gz rust-fe8bc178014dc2c5badd8443329c179478a40cc4.zip | |
auto merge of #15208 : alexcrichton/rust/snapshots, r=pcwalton
This change registers new snapshots, allowing `*T` to be removed from the language. This is a large breaking change, and it is recommended that if compiler errors are seen that any FFI calls are audited to determine whether they should be actually taking `*mut T`.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/atomics.rs | 10 | ||||
| -rw-r--r-- | src/libcore/fmt/mod.rs | 14 | ||||
| -rw-r--r-- | src/libcore/intrinsics.rs | 56 | ||||
| -rw-r--r-- | src/libcore/kinds.rs | 2 | ||||
| -rw-r--r-- | src/libcore/lib.rs | 1 | ||||
| -rw-r--r-- | src/libcore/mem.rs | 12 | ||||
| -rw-r--r-- | src/libcore/ops.rs | 12 | ||||
| -rw-r--r-- | src/libcore/option.rs | 4 | ||||
| -rw-r--r-- | src/libcore/ptr.rs | 88 | ||||
| -rw-r--r-- | src/libcore/raw.rs | 14 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 28 | ||||
| -rw-r--r-- | src/libcore/str.rs | 14 | ||||
| -rw-r--r-- | src/libcore/ty.rs | 2 |
13 files changed, 126 insertions, 131 deletions
diff --git a/src/libcore/atomics.rs b/src/libcore/atomics.rs index 65ba11f89ad..13979bb648f 100644 --- a/src/libcore/atomics.rs +++ b/src/libcore/atomics.rs @@ -94,7 +94,7 @@ impl AtomicBool { /// Load the value #[inline] pub fn load(&self, order: Ordering) -> bool { - unsafe { atomic_load(self.v.get() as *uint, order) > 0 } + unsafe { atomic_load(self.v.get() as *const uint, order) > 0 } } /// Store the value @@ -295,7 +295,7 @@ impl AtomicInt { /// Load the value #[inline] pub fn load(&self, order: Ordering) -> int { - unsafe { atomic_load(self.v.get() as *int, order) } + unsafe { atomic_load(self.v.get() as *const int, order) } } /// Store the value @@ -407,7 +407,7 @@ impl AtomicUint { /// Load the value #[inline] pub fn load(&self, order: Ordering) -> uint { - unsafe { atomic_load(self.v.get() as *uint, order) } + unsafe { atomic_load(self.v.get() as *const uint, order) } } /// Store the value @@ -520,7 +520,7 @@ impl<T> AtomicPtr<T> { #[inline] pub fn load(&self, order: Ordering) -> *mut T { unsafe { - atomic_load(self.p.get() as **mut T, order) as *mut T + atomic_load(self.p.get() as *const *mut T, order) as *mut T } } @@ -560,7 +560,7 @@ unsafe fn atomic_store<T>(dst: *mut T, val: T, order:Ordering) { } #[inline] -unsafe fn atomic_load<T>(dst: *T, order:Ordering) -> T { +unsafe fn atomic_load<T>(dst: *const T, order:Ordering) -> T { match order { Acquire => intrinsics::atomic_load_acq(dst), Relaxed => intrinsics::atomic_load_relaxed(dst), diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index d778f3b47a1..1a66d952e9b 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -314,11 +314,11 @@ impl<'a> Formatter<'a> { rt::CountImplied => { None } rt::CountIsParam(i) => { let v = self.args[i].value; - unsafe { Some(*(v as *any::Void as *uint)) } + unsafe { Some(*(v as *const _ as *const uint)) } } rt::CountIsNextParam => { let v = self.curarg.next().unwrap().value; - unsafe { Some(*(v as *any::Void as *uint)) } + unsafe { Some(*(v as *const _ as *const uint)) } } } } @@ -565,7 +565,7 @@ impl Char for char { } } -impl<T> Pointer for *T { +impl<T> Pointer for *const T { fn fmt(&self, f: &mut Formatter) -> Result { f.flags |= 1 << (rt::FlagAlternate as uint); secret_lower_hex::<uint>(&(*self as uint), f) @@ -573,17 +573,17 @@ impl<T> Pointer for *T { } impl<T> Pointer for *mut T { fn fmt(&self, f: &mut Formatter) -> Result { - secret_pointer::<*T>(&(*self as *T), f) + secret_pointer::<*const T>(&(*self as *const T), f) } } impl<'a, T> Pointer for &'a T { fn fmt(&self, f: &mut Formatter) -> Result { - secret_pointer::<*T>(&(&**self as *T), f) + secret_pointer::<*const T>(&(&**self as *const T), f) } } impl<'a, T> Pointer for &'a mut T { fn fmt(&self, f: &mut Formatter) -> Result { - secret_pointer::<*T>(&(&**self as *T), f) + secret_pointer::<*const T>(&(&**self as *const T), f) } } @@ -669,7 +669,7 @@ delegate!(char to char) delegate!(f32 to float) delegate!(f64 to float) -impl<T> Show for *T { +impl<T> Show for *const T { fn fmt(&self, f: &mut Formatter) -> Result { secret_pointer(self, f) } } impl<T> Show for *mut T { diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 6519d3b749d..fd06ae95f1b 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -48,7 +48,7 @@ A quick refresher on memory ordering: #[cfg(test)] pub use realcore::intrinsics::{TyDesc, Opaque, TyVisitor, TypeId}; -pub type GlueFn = extern "Rust" fn(*i8); +pub type GlueFn = extern "Rust" fn(*const i8); #[lang="ty_desc"] #[cfg(not(test))] @@ -102,55 +102,58 @@ pub trait TyVisitor { fn visit_estr_slice(&mut self) -> bool; fn visit_estr_fixed(&mut self, n: uint, sz: uint, align: uint) -> bool; - fn visit_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool; - fn visit_uniq(&mut self, mtbl: uint, inner: *TyDesc) -> bool; - fn visit_ptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool; - fn visit_rptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool; + fn visit_box(&mut self, mtbl: uint, inner: *const TyDesc) -> bool; + fn visit_uniq(&mut self, mtbl: uint, inner: *const TyDesc) -> bool; + fn visit_ptr(&mut self, mtbl: uint, inner: *const TyDesc) -> bool; + fn visit_rptr(&mut self, mtbl: uint, inner: *const TyDesc) -> bool; - fn visit_evec_slice(&mut self, mtbl: uint, inner: *TyDesc) -> bool; + fn visit_evec_slice(&mut self, mtbl: uint, inner: *const TyDesc) -> bool; fn visit_evec_fixed(&mut self, n: uint, sz: uint, align: uint, - mtbl: uint, inner: *TyDesc) -> bool; + mtbl: uint, inner: *const TyDesc) -> bool; fn visit_enter_rec(&mut self, n_fields: uint, sz: uint, align: uint) -> bool; fn visit_rec_field(&mut self, i: uint, name: &str, - mtbl: uint, inner: *TyDesc) -> bool; + mtbl: uint, inner: *const TyDesc) -> bool; fn visit_leave_rec(&mut self, n_fields: uint, sz: uint, align: uint) -> bool; fn visit_enter_class(&mut self, name: &str, named_fields: bool, n_fields: uint, sz: uint, align: uint) -> bool; fn visit_class_field(&mut self, i: uint, name: &str, named: bool, - mtbl: uint, inner: *TyDesc) -> bool; + mtbl: uint, inner: *const TyDesc) -> bool; fn visit_leave_class(&mut self, name: &str, named_fields: bool, n_fields: uint, sz: uint, align: uint) -> bool; fn visit_enter_tup(&mut self, n_fields: uint, sz: uint, align: uint) -> bool; - fn visit_tup_field(&mut self, i: uint, inner: *TyDesc) -> bool; + fn visit_tup_field(&mut self, i: uint, inner: *const TyDesc) -> bool; fn visit_leave_tup(&mut self, n_fields: uint, sz: uint, align: uint) -> bool; fn visit_enter_enum(&mut self, n_variants: uint, - get_disr: unsafe extern fn(ptr: *Opaque) -> Disr, + get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr, sz: uint, align: uint) -> bool; fn visit_enter_enum_variant(&mut self, variant: uint, disr_val: Disr, n_fields: uint, name: &str) -> bool; - fn visit_enum_variant_field(&mut self, i: uint, offset: uint, inner: *TyDesc) -> bool; + fn visit_enum_variant_field(&mut self, i: uint, offset: uint, + inner: *const TyDesc) -> bool; fn visit_leave_enum_variant(&mut self, variant: uint, disr_val: Disr, n_fields: uint, name: &str) -> bool; fn visit_leave_enum(&mut self, n_variants: uint, - get_disr: unsafe extern fn(ptr: *Opaque) -> Disr, + get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr, sz: uint, align: uint) -> bool; fn visit_enter_fn(&mut self, purity: uint, proto: uint, n_inputs: uint, retstyle: uint) -> bool; - fn visit_fn_input(&mut self, i: uint, mode: uint, inner: *TyDesc) -> bool; - fn visit_fn_output(&mut self, retstyle: uint, variadic: bool, inner: *TyDesc) -> bool; + fn visit_fn_input(&mut self, i: uint, mode: uint, + inner: *const TyDesc) -> bool; + fn visit_fn_output(&mut self, retstyle: uint, variadic: bool, + inner: *const TyDesc) -> bool; fn visit_leave_fn(&mut self, purity: uint, proto: uint, n_inputs: uint, retstyle: uint) -> bool; @@ -170,9 +173,9 @@ extern "rust-intrinsic" { pub fn atomic_cxchg_acqrel<T>(dst: *mut T, old: T, src: T) -> T; pub fn atomic_cxchg_relaxed<T>(dst: *mut T, old: T, src: T) -> T; - pub fn atomic_load<T>(src: *T) -> T; - pub fn atomic_load_acq<T>(src: *T) -> T; - pub fn atomic_load_relaxed<T>(src: *T) -> T; + pub fn atomic_load<T>(src: *const T) -> T; + pub fn atomic_load_acq<T>(src: *const T) -> T; + pub fn atomic_load_relaxed<T>(src: *const T) -> T; pub fn atomic_store<T>(dst: *mut T, val: T); pub fn atomic_store_rel<T>(dst: *mut T, val: T); @@ -276,7 +279,7 @@ extern "rust-intrinsic" { pub fn pref_align_of<T>() -> uint; /// Get a static pointer to a type descriptor. - pub fn get_tydesc<T>() -> *TyDesc; + pub fn get_tydesc<T>() -> *const TyDesc; /// Gets an identifier which is globally unique to the specified type. This /// function will return the same value for a type regardless of whichever @@ -320,7 +323,7 @@ extern "rust-intrinsic" { /// Returns `true` if a type is managed (will be allocated on the local heap) pub fn owns_managed<T>() -> bool; - pub fn visit_tydesc(td: *TyDesc, tv: &mut TyVisitor); + pub fn visit_tydesc(td: *const TyDesc, tv: &mut TyVisitor); /// Calculates the offset from a pointer. The offset *must* be in-bounds of /// the object, or one-byte-past-the-end. An arithmetic overflow is also @@ -328,17 +331,17 @@ extern "rust-intrinsic" { /// /// This is implemented as an intrinsic to avoid converting to and from an /// integer, since the conversion would throw away aliasing information. - pub fn offset<T>(dst: *T, offset: int) -> *T; + pub fn offset<T>(dst: *const T, offset: int) -> *const T; /// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with /// a size of `count` * `size_of::<T>()` and an alignment of /// `min_align_of::<T>()` - pub fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *T, count: uint); + pub fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint); /// Equivalent to the appropriate `llvm.memmove.p0i8.0i8.*` intrinsic, with /// a size of `count` * `size_of::<T>()` and an alignment of /// `min_align_of::<T>()` - pub fn copy_memory<T>(dst: *mut T, src: *T, count: uint); + pub fn copy_memory<T>(dst: *mut T, src: *const T, count: uint); /// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a /// size of `count` * `size_of::<T>()` and an alignment of @@ -350,13 +353,14 @@ extern "rust-intrinsic" { /// `min_align_of::<T>()` /// /// The volatile parameter parameter is set to `true`, so it will not be optimized out. - pub fn volatile_copy_nonoverlapping_memory<T>(dst: *mut T, src: *T, count: uint); + pub fn volatile_copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, + count: uint); /// Equivalent to the appropriate `llvm.memmove.p0i8.0i8.*` intrinsic, with /// a size of `count` * `size_of::<T>()` and an alignment of /// `min_align_of::<T>()` /// /// The volatile parameter parameter is set to `true`, so it will not be optimized out. - pub fn volatile_copy_memory<T>(dst: *mut T, src: *T, count: uint); + pub fn volatile_copy_memory<T>(dst: *mut T, src: *const T, count: uint); /// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a /// size of `count` * `size_of::<T>()` and an alignment of /// `min_align_of::<T>()`. @@ -365,7 +369,7 @@ extern "rust-intrinsic" { pub fn volatile_set_memory<T>(dst: *mut T, val: u8, count: uint); /// Perform a volatile load from the `src` pointer. - pub fn volatile_load<T>(src: *T) -> T; + pub fn volatile_load<T>(src: *const T) -> T; /// Perform a volatile store to the `dst` pointer. pub fn volatile_store<T>(dst: *mut T, val: T); diff --git a/src/libcore/kinds.rs b/src/libcore/kinds.rs index 40b716181e6..9a6cdb1c769 100644 --- a/src/libcore/kinds.rs +++ b/src/libcore/kinds.rs @@ -155,7 +155,7 @@ pub mod marker { /// ``` /// use std::mem; /// - /// struct S<T> { x: *() } + /// struct S<T> { x: *const () } /// fn get<T>(s: &S<T>, v: T) { /// unsafe { /// let x: fn(T) = mem::transmute(s.x); diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index aa55f204f45..4dc45ceeb85 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -58,7 +58,6 @@ #![feature(globs, intrinsics, lang_items, macro_rules, managed_boxes, phase)] #![feature(simd, unsafe_destructor)] #![deny(missing_doc)] -#![allow(unknown_features)] // NOTE: remove after stage0 snapshot #[cfg(test)] extern crate realcore = "core"; #[cfg(test)] extern crate libc; diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index a2a3e09a93c..d1e2084243d 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -363,7 +363,7 @@ pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing) } #[inline] #[stable] pub unsafe fn transmute_copy<T, U>(src: &T) -> U { - ptr::read(src as *T as *U) + ptr::read(src as *const T as *const U) } /// Transforms lifetime of the second pointer to match the first. @@ -407,14 +407,14 @@ mod tests { #[cfg(target_arch = "mipsel")] fn size_of_32() { assert_eq!(size_of::<uint>(), 4u); - assert_eq!(size_of::<*uint>(), 4u); + assert_eq!(size_of::<*const uint>(), 4u); } #[test] #[cfg(target_arch = "x86_64")] fn size_of_64() { assert_eq!(size_of::<uint>(), 8u); - assert_eq!(size_of::<*uint>(), 8u); + assert_eq!(size_of::<*const uint>(), 8u); } #[test] @@ -439,14 +439,14 @@ mod tests { #[cfg(target_arch = "mipsel")] fn align_of_32() { assert_eq!(align_of::<uint>(), 4u); - assert_eq!(align_of::<*uint>(), 4u); + assert_eq!(align_of::<*const uint>(), 4u); } #[test] #[cfg(target_arch = "x86_64")] fn align_of_64() { assert_eq!(align_of::<uint>(), 8u); - assert_eq!(align_of::<*uint>(), 8u); + assert_eq!(align_of::<*const uint>(), 8u); } #[test] @@ -486,7 +486,7 @@ mod tests { let a = box 100i as Box<Foo>; unsafe { let x: raw::TraitObject = transmute(a); - assert!(*(x.data as *int) == 100); + assert!(*(x.data as *const int) == 100); let _x: Box<Foo> = transmute(x); } diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 14edd7c70a8..afa08f04cb2 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -570,12 +570,6 @@ pub trait Shl<RHS,Result> { macro_rules! shl_impl( ($($t:ty)*) => ($( - #[cfg(stage0)] - impl Shl<$t, $t> for $t { - #[inline] - fn shl(&self, other: &$t) -> $t { (*self) << (*other) } - } - #[cfg(not(stage0), not(test))] impl Shl<$t, $t> for $t { #[inline] fn shl(&self, other: &$t) -> $t { @@ -619,12 +613,6 @@ pub trait Shr<RHS,Result> { macro_rules! shr_impl( ($($t:ty)*) => ($( - #[cfg(stage0, not(test))] - impl Shr<$t, $t> for $t { - #[inline] - fn shr(&self, other: &$t) -> $t { (*self) >> (*other) } - } - #[cfg(not(stage0), not(test))] impl Shr<$t, $t> for $t { #[inline] fn shr(&self, other: &$t) -> $t { (*self) >> (*other as uint) } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index e9fb7c3dae3..9748235e94a 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -628,10 +628,10 @@ mod tests { fn test_get_ptr() { unsafe { let x = box 0; - let addr_x: *int = ::mem::transmute(&*x); + let addr_x: *const int = ::mem::transmute(&*x); let opt = Some(x); let y = opt.unwrap(); - let addr_y: *int = ::mem::transmute(&*y); + let addr_y: *const int = ::mem::transmute(&*y); assert_eq!(addr_x, addr_y); } } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 59d7bbfe52d..44e68952df2 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -10,7 +10,7 @@ // FIXME: talk about offset, copy_memory, copy_nonoverlapping_memory -//! Operations on unsafe pointers, `*T`, and `*mut T`. +//! Operations on unsafe pointers, `*const T`, and `*mut T`. //! //! Working with unsafe pointers in Rust is uncommon, //! typically limited to a few patterns. @@ -29,7 +29,7 @@ //! //! ``` //! let my_num: int = 10; -//! let my_num_ptr: *int = &my_num; +//! let my_num_ptr: *const int = &my_num; //! let mut my_speed: int = 88; //! let my_speed_ptr: *mut int = &mut my_speed; //! ``` @@ -42,7 +42,7 @@ //! //! The `transmute` function takes, by value, whatever it's given //! and returns it as whatever type is requested, as long as the -//! types are the same size. Because `Box<T>` and `*T` have the same +//! types are the same size. Because `Box<T>` and `*mut T` have the same //! representation they can be trivially, //! though unsafely, transformed from one type to the other. //! @@ -51,7 +51,7 @@ //! //! unsafe { //! let my_num: Box<int> = box 10; -//! let my_num: *int = mem::transmute(my_num); +//! let my_num: *const int = mem::transmute(my_num); //! let my_speed: Box<int> = box 88; //! let my_speed: *mut int = mem::transmute(my_speed); //! @@ -102,12 +102,12 @@ use option::{Some, None, Option}; /// ``` /// use std::ptr; /// -/// let p: *int = ptr::null(); +/// let p: *const int = ptr::null(); /// assert!(p.is_null()); /// ``` #[inline] #[unstable = "may need a different name after pending changes to pointer types"] -pub fn null<T>() -> *T { 0 as *T } +pub fn null<T>() -> *const T { 0 as *const T } /// Create an unsafe mutable null pointer. /// @@ -137,7 +137,7 @@ pub fn mut_null<T>() -> *mut T { 0 as *mut T } /// ``` /// use std::ptr; /// -/// unsafe fn from_buf_raw<T>(ptr: *T, elts: uint) -> Vec<T> { +/// unsafe fn from_buf_raw<T>(ptr: *const T, elts: uint) -> Vec<T> { /// let mut dst = Vec::with_capacity(elts); /// dst.set_len(elts); /// ptr::copy_memory(dst.as_mut_ptr(), ptr, elts); @@ -147,7 +147,7 @@ pub fn mut_null<T>() -> *mut T { 0 as *mut T } /// #[inline] #[unstable] -pub unsafe fn copy_memory<T>(dst: *mut T, src: *T, count: uint) { +pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) { intrinsics::copy_memory(dst, src, count) } @@ -190,7 +190,7 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *T, count: uint) { #[inline] #[unstable] pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, - src: *T, + src: *const T, count: uint) { intrinsics::copy_nonoverlapping_memory(dst, src, count) } @@ -242,7 +242,7 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T { /// Reads the value from `*src` and returns it. #[inline(always)] #[unstable] -pub unsafe fn read<T>(src: *T) -> T { +pub unsafe fn read<T>(src: *const T) -> T { let mut tmp: T = mem::uninitialized(); copy_nonoverlapping_memory(&mut tmp, src, 1); tmp @@ -275,11 +275,12 @@ pub unsafe fn write<T>(dst: *mut T, src: T) { intrinsics::move_val_init(&mut *dst, src) } -/// Given a **T (pointer to an array of pointers), -/// iterate through each *T, up to the provided `len`, +/// Given a *const *const T (pointer to an array of pointers), +/// iterate through each *const T, up to the provided `len`, /// passing to the provided callback function #[deprecated = "old-style iteration. use a loop and RawPtr::offset"] -pub unsafe fn array_each_with_len<T>(arr: **T, len: uint, cb: |*T|) { +pub unsafe fn array_each_with_len<T>(arr: *const *const T, len: uint, + cb: |*const T|) { if arr.is_null() { fail!("ptr::array_each_with_len failure: arr input is null pointer"); } @@ -290,8 +291,8 @@ pub unsafe fn array_each_with_len<T>(arr: **T, len: uint, cb: |*T|) { } } -/// Given a null-pointer-terminated **T (pointer to -/// an array of pointers), iterate through each *T, +/// Given a null-pointer-terminated *const *const T (pointer to +/// an array of pointers), iterate through each *const T, /// passing to the provided callback function /// /// # Safety Note @@ -300,7 +301,7 @@ pub unsafe fn array_each_with_len<T>(arr: **T, len: uint, cb: |*T|) { /// pointer array. #[deprecated = "old-style iteration. use a loop and RawPtr::offset"] #[allow(deprecated)] -pub unsafe fn array_each<T>(arr: **T, cb: |*T|) { +pub unsafe fn array_each<T>(arr: *const *const T, cb: |*const T|) { if arr.is_null() { fail!("ptr::array_each_with_len failure: arr input is null pointer"); } @@ -312,14 +313,14 @@ pub unsafe fn array_each<T>(arr: **T, cb: |*T|) { #[inline] #[deprecated = "use a loop and RawPtr::offset"] #[allow(deprecated)] -pub unsafe fn buf_len<T>(buf: **T) -> uint { +pub unsafe fn buf_len<T>(buf: *const *const T) -> uint { position(buf, |i| *i == null()) } /// Return the first offset `i` such that `f(buf[i]) == true`. #[inline] #[deprecated = "old-style iteration. use a loop and RawPtr::offset"] -pub unsafe fn position<T>(buf: *T, f: |&T| -> bool) -> uint { +pub unsafe fn position<T>(buf: *const T, f: |&T| -> bool) -> uint { let mut i = 0; loop { if f(&(*buf.offset(i as int))) { return i; } @@ -352,9 +353,9 @@ pub trait RawPtr<T> { unsafe fn offset(self, count: int) -> Self; } -impl<T> RawPtr<T> for *T { +impl<T> RawPtr<T> for *const T { #[inline] - fn null() -> *T { null() } + fn null() -> *const T { null() } #[inline] fn is_null(&self) -> bool { *self == RawPtr::null() } @@ -363,7 +364,9 @@ impl<T> RawPtr<T> for *T { fn to_uint(&self) -> uint { *self as uint } #[inline] - unsafe fn offset(self, count: int) -> *T { intrinsics::offset(self, count) } + unsafe fn offset(self, count: int) -> *const T { + intrinsics::offset(self, count) + } #[inline] unsafe fn to_option(&self) -> Option<&T> { @@ -387,7 +390,7 @@ impl<T> RawPtr<T> for *mut T { #[inline] unsafe fn offset(self, count: int) -> *mut T { - intrinsics::offset(self as *T, count) as *mut T + intrinsics::offset(self as *const T, count) as *mut T } #[inline] @@ -402,17 +405,17 @@ impl<T> RawPtr<T> for *mut T { // Equality for pointers #[cfg(not(test))] -impl<T> PartialEq for *T { +impl<T> PartialEq for *const T { #[inline] - fn eq(&self, other: &*T) -> bool { + fn eq(&self, other: &*const T) -> bool { *self == *other } #[inline] - fn ne(&self, other: &*T) -> bool { !self.eq(other) } + fn ne(&self, other: &*const T) -> bool { !self.eq(other) } } #[cfg(not(test))] -impl<T> Eq for *T {} +impl<T> Eq for *const T {} #[cfg(not(test))] impl<T> PartialEq for *mut T { @@ -429,22 +432,22 @@ impl<T> Eq for *mut T {} // Equivalence for pointers #[cfg(not(test))] -impl<T> Equiv<*mut T> for *T { +impl<T> Equiv<*mut T> for *const T { fn equiv(&self, other: &*mut T) -> bool { self.to_uint() == other.to_uint() } } #[cfg(not(test))] -impl<T> Equiv<*T> for *mut T { - fn equiv(&self, other: &*T) -> bool { +impl<T> Equiv<*const T> for *mut T { + fn equiv(&self, other: &*const T) -> bool { self.to_uint() == other.to_uint() } } -impl<T> Clone for *T { +impl<T> Clone for *const T { #[inline] - fn clone(&self) -> *T { + fn clone(&self) -> *const T { *self } } @@ -465,8 +468,8 @@ mod externfnpointers { impl<_R> PartialEq for extern "C" fn() -> _R { #[inline] fn eq(&self, other: &extern "C" fn() -> _R) -> bool { - let self_: *() = unsafe { mem::transmute(*self) }; - let other_: *() = unsafe { mem::transmute(*other) }; + let self_: *const () = unsafe { mem::transmute(*self) }; + let other_: *const () = unsafe { mem::transmute(*other) }; self_ == other_ } } @@ -475,8 +478,9 @@ mod externfnpointers { impl<_R,$($p),*> PartialEq for extern "C" fn($($p),*) -> _R { #[inline] fn eq(&self, other: &extern "C" fn($($p),*) -> _R) -> bool { - let self_: *() = unsafe { mem::transmute(*self) }; - let other_: *() = unsafe { mem::transmute(*other) }; + let self_: *const () = unsafe { mem::transmute(*self) }; + + let other_: *const () = unsafe { mem::transmute(*other) }; self_ == other_ } } @@ -491,9 +495,9 @@ mod externfnpointers { // Comparison for pointers #[cfg(not(test))] -impl<T> PartialOrd for *T { +impl<T> PartialOrd for *const T { #[inline] - fn lt(&self, other: &*T) -> bool { *self < *other } + fn lt(&self, other: &*const T) -> bool { *self < *other } } #[cfg(not(test))] @@ -587,7 +591,7 @@ pub mod test { #[test] fn test_is_null() { - let p: *int = null(); + let p: *const int = null(); assert!(p.is_null()); assert!(!p.is_not_null()); @@ -607,10 +611,10 @@ pub mod test { #[test] fn test_to_option() { unsafe { - let p: *int = null(); + let p: *const int = null(); assert_eq!(p.to_option(), None); - let q: *int = &2; + let q: *const int = &2; assert_eq!(q.to_option().unwrap(), &2); let p: *mut int = mut_null(); @@ -738,7 +742,7 @@ pub mod test { #[should_fail] fn test_ptr_array_each_with_len_null_ptr() { unsafe { - array_each_with_len(0 as **libc::c_char, 1, |e| { + array_each_with_len(0 as *const *const libc::c_char, 1, |e| { str::raw::from_c_str(e); }); } @@ -747,7 +751,7 @@ pub mod test { #[should_fail] fn test_ptr_array_each_null_ptr() { unsafe { - array_each(0 as **libc::c_char, |e| { + array_each(0 as *const *const libc::c_char, |e| { str::raw::from_c_str(e); }); } diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index 0a2a756c6b1..f32e6bd9c7c 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -31,20 +31,20 @@ pub struct Box<T> { /// The representation of a Rust slice pub struct Slice<T> { - pub data: *T, + pub data: *const T, pub len: uint, } /// The representation of a Rust closure pub struct Closure { - pub code: *(), - pub env: *(), + pub code: *mut (), + pub env: *mut (), } /// The representation of a Rust procedure (`proc()`) pub struct Procedure { - pub code: *(), - pub env: *(), + pub code: *mut (), + pub env: *mut (), } /// The representation of a Rust trait object. @@ -52,8 +52,8 @@ pub struct Procedure { /// This struct does not have a `Repr` implementation /// because there is no way to refer to all trait objects generically. pub struct TraitObject { - pub vtable: *(), - pub data: *(), + pub vtable: *mut (), + pub data: *mut (), } /// This trait is meant to map equivalences between raw structs and their diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 14b5f7a6d60..fea7986eee5 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -44,7 +44,7 @@ pub fn ref_slice<'a, A>(s: &'a A) -> &'a [A] { */ pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] { unsafe { - let ptr: *A = transmute(s); + let ptr: *const A = transmute(s); transmute(Slice { data: ptr, len: 1 }) } } @@ -439,7 +439,7 @@ pub trait ImmutableVector<'a, T> { * Modifying the vector may cause its buffer to be reallocated, which * would also make any pointers to it invalid. */ - fn as_ptr(&self) -> *T; + fn as_ptr(&self) -> *const T; /** * Binary search a sorted vector with a comparator function. @@ -520,7 +520,7 @@ impl<'a,T> ImmutableVector<'a, T> for &'a [T] { let p = self.as_ptr(); if mem::size_of::<T>() == 0 { Items{ptr: p, - end: (p as uint + self.len()) as *T, + end: (p as uint + self.len()) as *const T, marker: marker::ContravariantLifetime::<'a>} } else { Items{ptr: p, @@ -606,7 +606,7 @@ impl<'a,T> ImmutableVector<'a, T> for &'a [T] { } #[inline] - fn as_ptr(&self) -> *T { + fn as_ptr(&self) -> *const T { self.repr().data } @@ -936,7 +936,7 @@ impl<'a,T> MutableVector<'a, T> for &'a mut [T] { assert!(end <= self.len()); unsafe { transmute(Slice { - data: self.as_mut_ptr().offset(start as int) as *T, + data: self.as_mut_ptr().offset(start as int) as *const T, len: (end - start) }) } @@ -1115,7 +1115,7 @@ pub mod raw { * not bytes). */ #[inline] - pub unsafe fn buf_as_slice<T,U>(p: *T, len: uint, f: |v: &[T]| -> U) + pub unsafe fn buf_as_slice<T,U>(p: *const T, len: uint, f: |v: &[T]| -> U) -> U { f(transmute(Slice { data: p, @@ -1135,7 +1135,7 @@ pub mod raw { f: |v: &mut [T]| -> U) -> U { f(transmute(Slice { - data: p as *T, + data: p as *const T, len: len })) } @@ -1146,9 +1146,9 @@ pub mod raw { * if the slice is empty. O(1). */ #[inline] - pub unsafe fn shift_ptr<T>(slice: &mut Slice<T>) -> Option<*T> { + pub unsafe fn shift_ptr<T>(slice: &mut Slice<T>) -> Option<*const T> { if slice.len == 0 { return None; } - let head: *T = slice.data; + let head: *const T = slice.data; slice.data = slice.data.offset(1); slice.len -= 1; Some(head) @@ -1160,9 +1160,9 @@ pub mod raw { * if the slice is empty. O(1). */ #[inline] - pub unsafe fn pop_ptr<T>(slice: &mut Slice<T>) -> Option<*T> { + pub unsafe fn pop_ptr<T>(slice: &mut Slice<T>) -> Option<*const T> { if slice.len == 0 { return None; } - let tail: *T = slice.data.offset((slice.len - 1) as int); + let tail: *const T = slice.data.offset((slice.len - 1) as int); slice.len -= 1; Some(tail) } @@ -1201,8 +1201,8 @@ pub mod bytes { /// Immutable slice iterator pub struct Items<'a, T> { - ptr: *T, - end: *T, + ptr: *const T, + end: *const T, marker: marker::ContravariantLifetime<'a> } @@ -1289,7 +1289,7 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> { } } -iterator!{struct Items -> *T, &'a T} +iterator!{struct Items -> *const T, &'a T} impl<'a, T> ExactSize<&'a T> for Items<'a, T> {} impl<'a, T> ExactSize<&'a mut T> for MutItems<'a, T> {} diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 13efeab57d4..0d4b5f59074 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -568,10 +568,10 @@ Section: Comparing strings #[inline] fn eq_slice_(a: &str, b: &str) -> bool { #[allow(ctypes)] - extern { fn memcmp(s1: *i8, s2: *i8, n: uint) -> i32; } + extern { fn memcmp(s1: *const i8, s2: *const i8, n: uint) -> i32; } a.len() == b.len() && unsafe { - memcmp(a.as_ptr() as *i8, - b.as_ptr() as *i8, + memcmp(a.as_ptr() as *const i8, + b.as_ptr() as *const i8, a.len()) == 0 } } @@ -888,8 +888,8 @@ pub mod raw { /// Form a slice from a C string. Unsafe because the caller must ensure the /// C string has the static lifetime, or else the return value may be /// invalidated later. - pub unsafe fn c_str_to_static_slice(s: *i8) -> &'static str { - let s = s as *u8; + pub unsafe fn c_str_to_static_slice(s: *const i8) -> &'static str { + let s = s as *const u8; let mut curr = s; let mut len = 0u; while *curr != 0u8 { @@ -1618,7 +1618,7 @@ pub trait StrSlice<'a> { /// The caller must ensure that the string outlives this pointer, /// and that it is not reallocated (e.g. by pushing to the /// string). - fn as_ptr(&self) -> *u8; + fn as_ptr(&self) -> *const u8; } impl<'a> StrSlice<'a> for &'a str { @@ -1964,7 +1964,7 @@ impl<'a> StrSlice<'a> for &'a str { } #[inline] - fn as_ptr(&self) -> *u8 { + fn as_ptr(&self) -> *const u8 { self.repr().data } } diff --git a/src/libcore/ty.rs b/src/libcore/ty.rs index 47a2005fef1..5bdab6a78ca 100644 --- a/src/libcore/ty.rs +++ b/src/libcore/ty.rs @@ -62,7 +62,7 @@ impl<T> Unsafe<T> { /// Gets a mutable pointer to the wrapped value #[inline] - pub unsafe fn get(&self) -> *mut T { &self.value as *T as *mut T } + pub unsafe fn get(&self) -> *mut T { &self.value as *const T as *mut T } /// Unwraps the value #[inline] |
