From 3d1f3f4de087ccf7e30b795fbd73e054b4761c4f Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 5 Nov 2013 14:50:33 -0500 Subject: Rename misleading contains_managed to owns_managed --- src/libstd/unstable/intrinsics.rs | 5 +++++ src/libstd/vec.rs | 29 +++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) (limited to 'src/libstd') 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() -> bool; /// Returns `true` if a type is managed (will be allocated on the local heap) + #[cfg(stage0)] pub fn contains_managed() -> bool; + /// Returns `true` if a type is managed (will be allocated on the local heap) + #[cfg(not(stage0))] + pub fn owns_managed() -> 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() -> bool { + intrinsics::contains_managed::() +} + /** * Creates and initializes an owned vector. * @@ -180,7 +188,7 @@ pub fn from_elem(n_elts: uint, t: T) -> ~[T] { #[inline] pub fn with_capacity(capacity: uint) -> ~[T] { unsafe { - if contains_managed::() { + if owns_managed::() { let mut vec = ~[]; vec.reserve(capacity); vec @@ -1401,7 +1409,7 @@ impl OwnedVector for ~[T] { if self.capacity() < n { unsafe { let td = get_tydesc::(); - if contains_managed::() { + if owns_managed::() { let ptr: *mut *mut Box> = cast::transmute(self); ::at_vec::raw::reserve_raw(td, ptr, n); } else { @@ -1437,7 +1445,7 @@ impl OwnedVector for ~[T] { #[inline] fn capacity(&self) -> uint { unsafe { - if contains_managed::() { + if owns_managed::() { let repr: **Box> = cast::transmute(self); (**repr).data.alloc / mem::nonzero_size_of::() } else { @@ -1460,7 +1468,7 @@ impl OwnedVector for ~[T] { #[inline] fn push(&mut self, t: T) { unsafe { - if contains_managed::() { + if owns_managed::() { let repr: **Box> = cast::transmute(&mut *self); let fill = (**repr).data.fill; if (**repr).data.alloc <= fill { @@ -1482,7 +1490,7 @@ impl OwnedVector for ~[T] { // This doesn't bother to make sure we have space. #[inline] // really pretty please unsafe fn push_fast(this: &mut ~[T], t: T) { - if contains_managed::() { + if owns_managed::() { let repr: **mut Box> = cast::transmute(this); let fill = (**repr).data.fill; (**repr).data.fill += mem::nonzero_size_of::(); @@ -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(v: &mut ~[T], new_len: uint) { - if contains_managed::() { + if owns_managed::() { let repr: **mut Box> = cast::transmute(v); (**repr).data.fill = new_len * mem::nonzero_size_of::(); } else { -- cgit 1.4.1-3-g733a5