@@ -121,11 +121,19 @@ use mem::size_of;
121
121
use uint;
122
122
use unstable:: finally:: Finally ;
123
123
use unstable:: intrinsics;
124
- use unstable:: intrinsics:: { get_tydesc, contains_managed } ;
124
+ use unstable:: intrinsics:: { get_tydesc} ;
125
125
use unstable:: raw:: { Box , Repr , Slice , Vec } ;
126
126
use vec;
127
127
use util;
128
128
129
+ #[ cfg( not( stage0) ) ]
130
+ use unstable:: intrinsics:: owns_managed;
131
+
132
+ #[ cfg( stage0) ]
133
+ unsafe fn owns_managed < T > ( ) -> bool {
134
+ intrinsics:: contains_managed :: < T > ( )
135
+ }
136
+
129
137
/**
130
138
* Creates and initializes an owned vector.
131
139
*
@@ -180,7 +188,7 @@ pub fn from_elem<T:Clone>(n_elts: uint, t: T) -> ~[T] {
180
188
#[ inline]
181
189
pub fn with_capacity < T > ( capacity : uint ) -> ~[ T ] {
182
190
unsafe {
183
- if contains_managed :: < T > ( ) {
191
+ if owns_managed :: < T > ( ) {
184
192
let mut vec = ~[ ] ;
185
193
vec. reserve ( capacity) ;
186
194
vec
@@ -1401,7 +1409,7 @@ impl<T> OwnedVector<T> for ~[T] {
1401
1409
if self . capacity ( ) < n {
1402
1410
unsafe {
1403
1411
let td = get_tydesc :: < T > ( ) ;
1404
- if contains_managed :: < T > ( ) {
1412
+ if owns_managed :: < T > ( ) {
1405
1413
let ptr: * mut * mut Box < Vec < ( ) > > = cast:: transmute ( self ) ;
1406
1414
:: at_vec:: raw:: reserve_raw ( td, ptr, n) ;
1407
1415
} else {
@@ -1437,7 +1445,7 @@ impl<T> OwnedVector<T> for ~[T] {
1437
1445
#[ inline]
1438
1446
fn capacity ( & self ) -> uint {
1439
1447
unsafe {
1440
- if contains_managed :: < T > ( ) {
1448
+ if owns_managed :: < T > ( ) {
1441
1449
let repr: * * Box < Vec < ( ) > > = cast:: transmute ( self ) ;
1442
1450
( * * repr) . data . alloc / mem:: nonzero_size_of :: < T > ( )
1443
1451
} else {
@@ -1460,7 +1468,7 @@ impl<T> OwnedVector<T> for ~[T] {
1460
1468
#[ inline]
1461
1469
fn push ( & mut self , t : T ) {
1462
1470
unsafe {
1463
- if contains_managed :: < T > ( ) {
1471
+ if owns_managed :: < T > ( ) {
1464
1472
let repr: * * Box < Vec < ( ) > > = cast:: transmute ( & mut * self ) ;
1465
1473
let fill = ( * * repr) . data . fill ;
1466
1474
if ( * * repr) . data . alloc <= fill {
@@ -1482,7 +1490,7 @@ impl<T> OwnedVector<T> for ~[T] {
1482
1490
// This doesn't bother to make sure we have space.
1483
1491
#[ inline] // really pretty please
1484
1492
unsafe fn push_fast < T > ( this : & mut ~[ T ] , t : T ) {
1485
- if contains_managed :: < T > ( ) {
1493
+ if owns_managed :: < T > ( ) {
1486
1494
let repr: * * mut Box < Vec < u8 > > = cast:: transmute ( this) ;
1487
1495
let fill = ( * * repr) . data . fill ;
1488
1496
( * * repr) . data . fill += mem:: nonzero_size_of :: < T > ( ) ;
@@ -2057,9 +2065,14 @@ pub mod raw {
2057
2065
use mem;
2058
2066
use unstable:: intrinsics;
2059
2067
use vec:: { with_capacity, ImmutableVector , MutableVector } ;
2060
- use unstable:: intrinsics:: contains_managed;
2061
2068
use unstable:: raw:: { Box , Vec , Slice } ;
2062
2069
2070
+ #[ cfg( not( stage0) ) ]
2071
+ use unstable:: intrinsics:: owns_managed;
2072
+
2073
+ #[ cfg( stage0) ]
2074
+ use vec:: owns_managed;
2075
+
2063
2076
/**
2064
2077
* Sets the length of a vector
2065
2078
*
@@ -2069,7 +2082,7 @@ pub mod raw {
2069
2082
*/
2070
2083
#[ inline]
2071
2084
pub unsafe fn set_len < T > ( v : & mut ~[ T ] , new_len : uint ) {
2072
- if contains_managed :: < T > ( ) {
2085
+ if owns_managed :: < T > ( ) {
2073
2086
let repr: * * mut Box < Vec < ( ) > > = cast:: transmute ( v) ;
2074
2087
( * * repr) . data . fill = new_len * mem:: nonzero_size_of :: < T > ( ) ;
2075
2088
} else {
0 commit comments