about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/unstable/intrinsics.rs5
-rw-r--r--src/libstd/vec.rs29
2 files changed, 26 insertions, 8 deletions
diff --git a/src/libstd/unstable/intrinsics.rs b/src/libstd/unstable/intrinsics.rs
index 404ed85985c..030364c75af 100644
--- a/src/libstd/unstable/intrinsics.rs
+++ b/src/libstd/unstable/intrinsics.rs
@@ -337,8 +337,13 @@ extern "rust-intrinsic" {
     pub fn needs_drop<T>() -> bool;
 
     /// Returns `true` if a type is managed (will be allocated on the local heap)
+    #[cfg(stage0)]
     pub fn contains_managed<T>() -> bool;
 
+    /// Returns `true` if a type is managed (will be allocated on the local heap)
+    #[cfg(not(stage0))]
+    pub fn owns_managed<T>() -> bool;
+
     pub fn visit_tydesc(td: *TyDesc, tv: &mut TyVisitor);
 
     /// Get the address of the `__morestack` stack growth function.
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index b10d0ded5b4..c9d55735015 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -121,11 +121,19 @@ use mem::size_of;
 use uint;
 use unstable::finally::Finally;
 use unstable::intrinsics;
-use unstable::intrinsics::{get_tydesc, contains_managed};
+use unstable::intrinsics::{get_tydesc};
 use unstable::raw::{Box, Repr, Slice, Vec};
 use vec;
 use util;
 
+#[cfg(not(stage0))]
+use unstable::intrinsics::owns_managed;
+
+#[cfg(stage0)]
+unsafe fn owns_managed<T>() -> bool {
+    intrinsics::contains_managed::<T>()
+}
+
 /**
  * Creates and initializes an owned vector.
  *
@@ -180,7 +188,7 @@ pub fn from_elem<T:Clone>(n_elts: uint, t: T) -> ~[T] {
 #[inline]
 pub fn with_capacity<T>(capacity: uint) -> ~[T] {
     unsafe {
-        if contains_managed::<T>() {
+        if owns_managed::<T>() {
             let mut vec = ~[];
             vec.reserve(capacity);
             vec
@@ -1401,7 +1409,7 @@ impl<T> OwnedVector<T> for ~[T] {
         if self.capacity() < n {
             unsafe {
                 let td = get_tydesc::<T>();
-                if contains_managed::<T>() {
+                if owns_managed::<T>() {
                     let ptr: *mut *mut Box<Vec<()>> = cast::transmute(self);
                     ::at_vec::raw::reserve_raw(td, ptr, n);
                 } else {
@@ -1437,7 +1445,7 @@ impl<T> OwnedVector<T> for ~[T] {
     #[inline]
     fn capacity(&self) -> uint {
         unsafe {
-            if contains_managed::<T>() {
+            if owns_managed::<T>() {
                 let repr: **Box<Vec<()>> = cast::transmute(self);
                 (**repr).data.alloc / mem::nonzero_size_of::<T>()
             } else {
@@ -1460,7 +1468,7 @@ impl<T> OwnedVector<T> for ~[T] {
     #[inline]
     fn push(&mut self, t: T) {
         unsafe {
-            if contains_managed::<T>() {
+            if owns_managed::<T>() {
                 let repr: **Box<Vec<()>> = cast::transmute(&mut *self);
                 let fill = (**repr).data.fill;
                 if (**repr).data.alloc <= fill {
@@ -1482,7 +1490,7 @@ impl<T> OwnedVector<T> for ~[T] {
         // This doesn't bother to make sure we have space.
         #[inline] // really pretty please
         unsafe fn push_fast<T>(this: &mut ~[T], t: T) {
-            if contains_managed::<T>() {
+            if owns_managed::<T>() {
                 let repr: **mut Box<Vec<u8>> = cast::transmute(this);
                 let fill = (**repr).data.fill;
                 (**repr).data.fill += mem::nonzero_size_of::<T>();
@@ -2057,9 +2065,14 @@ pub mod raw {
     use mem;
     use unstable::intrinsics;
     use vec::{with_capacity, ImmutableVector, MutableVector};
-    use unstable::intrinsics::contains_managed;
     use unstable::raw::{Box, Vec, Slice};
 
+    #[cfg(not(stage0))]
+    use unstable::intrinsics::owns_managed;
+
+    #[cfg(stage0)]
+    use vec::owns_managed;
+
     /**
      * Sets the length of a vector
      *
@@ -2069,7 +2082,7 @@ pub mod raw {
      */
     #[inline]
     pub unsafe fn set_len<T>(v: &mut ~[T], new_len: uint) {
-        if contains_managed::<T>() {
+        if owns_managed::<T>() {
             let repr: **mut Box<Vec<()>> = cast::transmute(v);
             (**repr).data.fill = new_len * mem::nonzero_size_of::<T>();
         } else {