Skip to content

Commit 3d1f3f4

Browse files
committed
Rename misleading contains_managed to owns_managed
1 parent f3191a4 commit 3d1f3f4

File tree

15 files changed

+44
-26
lines changed

15 files changed

+44
-26
lines changed

src/librustc/middle/trans/_match.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ fn compile_submatch_continue(mut bcx: @mut Block,
16001600
let pat_ty = node_id_type(bcx, pat_id);
16011601
let llbox = Load(bcx, val);
16021602
let unboxed = match ty::get(pat_ty).sty {
1603-
ty::ty_uniq(*) if !ty::type_contents(bcx.tcx(), pat_ty).contains_managed() => llbox,
1603+
ty::ty_uniq(*) if !ty::type_contents(bcx.tcx(), pat_ty).owns_managed() => llbox,
16041604
_ => GEPi(bcx, llbox, [0u, abi::box_field_body])
16051605
};
16061606
compile_submatch(bcx, enter_uniq(bcx, dm, m, col, val),
@@ -2220,7 +2220,7 @@ fn bind_irrefutable_pat(bcx: @mut Block,
22202220
let pat_ty = node_id_type(bcx, pat.id);
22212221
let llbox = Load(bcx, val);
22222222
let unboxed = match ty::get(pat_ty).sty {
2223-
ty::ty_uniq(*) if !ty::type_contents(bcx.tcx(), pat_ty).contains_managed() => llbox,
2223+
ty::ty_uniq(*) if !ty::type_contents(bcx.tcx(), pat_ty).owns_managed() => llbox,
22242224
_ => GEPi(bcx, llbox, [0u, abi::box_field_body])
22252225
};
22262226
bcx = bind_irrefutable_pat(bcx, inner, unboxed, binding_mode);

src/librustc/middle/trans/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ pub fn malloc_general(bcx: @mut Block, t: ty::t, heap: heap) -> MallocResult {
409409
}
410410

411411
pub fn heap_for_unique(bcx: @mut Block, t: ty::t) -> heap {
412-
if ty::type_contents(bcx.tcx(), t).contains_managed() {
412+
if ty::type_contents(bcx.tcx(), t).owns_managed() {
413413
heap_managed_unique
414414
} else {
415415
heap_exchange

src/librustc/middle/trans/closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub fn mk_closure_tys(tcx: ty::ctxt,
156156
}
157157

158158
fn heap_for_unique_closure(bcx: @mut Block, t: ty::t) -> heap {
159-
if ty::type_contents(bcx.tcx(), t).contains_managed() {
159+
if ty::type_contents(bcx.tcx(), t).owns_managed() {
160160
heap_managed_unique
161161
} else {
162162
heap_exchange_closure

src/librustc/middle/trans/datum.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ impl Datum {
566566
}
567567
};
568568

569-
if !header && !ty::type_contents(bcx.tcx(), content_ty).contains_managed() {
569+
if !header && !ty::type_contents(bcx.tcx(), content_ty).owns_managed() {
570570
let ptr = self.to_value_llval(bcx);
571571
let ty = type_of::type_of(bcx.ccx(), content_ty);
572572
let body = PointerCast(bcx, ptr, ty.ptr_to());

src/librustc/middle/trans/debuginfo.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2060,7 +2060,7 @@ fn type_metadata(cx: &mut CrateContext,
20602060
ty::vstore_fixed(len) => {
20612061
fixed_vec_metadata(cx, mt.ty, len, usage_site_span)
20622062
}
2063-
ty::vstore_uniq if ty::type_contents(cx.tcx, mt.ty).contains_managed() => {
2063+
ty::vstore_uniq if ty::type_contents(cx.tcx, mt.ty).owns_managed() => {
20642064
let boxed_vec_metadata = boxed_vec_metadata(cx, mt.ty, usage_site_span);
20652065
pointer_type_metadata(cx, t, boxed_vec_metadata)
20662066
}
@@ -2077,7 +2077,7 @@ fn type_metadata(cx: &mut CrateContext,
20772077
}
20782078
}
20792079
},
2080-
ty::ty_uniq(ref mt) if ty::type_contents(cx.tcx, mt.ty).contains_managed() => {
2080+
ty::ty_uniq(ref mt) if ty::type_contents(cx.tcx, mt.ty).owns_managed() => {
20812081
create_pointer_to_box_metadata(cx, t, mt.ty)
20822082
},
20832083
ty::ty_uniq(ref mt) |

src/librustc/middle/trans/glue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ pub fn declare_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info {
603603

604604
let has_header = match ty::get(t).sty {
605605
ty::ty_box(*) => true,
606-
ty::ty_uniq(*) => ty::type_contents(ccx.tcx, t).contains_managed(),
606+
ty::ty_uniq(*) => ty::type_contents(ccx.tcx, t).owns_managed(),
607607
_ => false
608608
};
609609

src/librustc/middle/trans/intrinsic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
387387
let tp_ty = substs.tys[0];
388388
Ret(bcx, C_bool(ty::type_needs_drop(ccx.tcx, tp_ty)));
389389
}
390-
"contains_managed" => {
390+
"owns_managed" => {
391391
let tp_ty = substs.tys[0];
392-
Ret(bcx, C_bool(ty::type_contents(ccx.tcx, tp_ty).contains_managed()));
392+
Ret(bcx, C_bool(ty::type_contents(ccx.tcx, tp_ty).owns_managed()));
393393
}
394394
"visit_tydesc" => {
395395
let td = get_param(decl, first_real_arg);

src/librustc/middle/trans/reflect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl Reflector {
183183
ty::ty_evec(ref mt, vst) => {
184184
let (name, extra) = self.vstore_name_and_extra(t, vst);
185185
let extra = extra + self.c_mt(mt);
186-
if "uniq" == name && ty::type_contents(bcx.tcx(), t).contains_managed() {
186+
if "uniq" == name && ty::type_contents(bcx.tcx(), t).owns_managed() {
187187
self.visit("evec_uniq_managed", extra)
188188
} else {
189189
self.visit(~"evec_" + name, extra)
@@ -195,7 +195,7 @@ impl Reflector {
195195
}
196196
ty::ty_uniq(ref mt) => {
197197
let extra = self.c_mt(mt);
198-
if ty::type_contents(bcx.tcx(), t).contains_managed() {
198+
if ty::type_contents(bcx.tcx(), t).owns_managed() {
199199
self.visit("uniq_managed", extra)
200200
} else {
201201
self.visit("uniq", extra)

src/librustc/middle/trans/tvec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub fn get_alloc(bcx: @mut Block, vptr: ValueRef) -> ValueRef {
6565
}
6666

6767
pub fn get_bodyptr(bcx: @mut Block, vptr: ValueRef, t: ty::t) -> ValueRef {
68-
if ty::type_contents(bcx.tcx(), t).contains_managed() {
68+
if ty::type_contents(bcx.tcx(), t).owns_managed() {
6969
GEPi(bcx, vptr, [0u, abi::box_field_body])
7070
} else {
7171
vptr

src/librustc/middle/trans/type_of.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ pub fn type_of(cx: &mut CrateContext, t: ty::t) -> Type {
226226
ty::ty_opaque_box => Type::opaque_box(cx).ptr_to(),
227227
ty::ty_uniq(ref mt) => {
228228
let ty = type_of(cx, mt.ty);
229-
if ty::type_contents(cx.tcx, mt.ty).contains_managed() {
229+
if ty::type_contents(cx.tcx, mt.ty).owns_managed() {
230230
Type::unique(cx, &ty).ptr_to()
231231
} else {
232232
ty.ptr_to()
@@ -235,7 +235,7 @@ pub fn type_of(cx: &mut CrateContext, t: ty::t) -> Type {
235235
ty::ty_evec(ref mt, ty::vstore_uniq) => {
236236
let ty = type_of(cx, mt.ty);
237237
let ty = Type::vec(cx.sess.targ_cfg.arch, &ty);
238-
if ty::type_contents(cx.tcx, mt.ty).contains_managed() {
238+
if ty::type_contents(cx.tcx, mt.ty).owns_managed() {
239239
Type::unique(cx, &ty).ptr_to()
240240
} else {
241241
ty.ptr_to()

src/librustc/middle/trans/uniq.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn make_free_glue(bcx: @mut Block, vptrptr: ValueRef, box_ty: ty::t)
2727
let body_datum = box_datum.box_body(bcx);
2828
let bcx = glue::drop_ty(bcx, body_datum.to_ref_llval(bcx),
2929
body_datum.ty);
30-
if ty::type_contents(bcx.tcx(), box_ty).contains_managed() {
30+
if ty::type_contents(bcx.tcx(), box_ty).owns_managed() {
3131
glue::trans_free(bcx, box_datum.val)
3232
} else {
3333
glue::trans_exchange_free(bcx, box_datum.val)

src/librustc/middle/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,7 @@ impl TypeContents {
19541954
!self.intersects(TC::Nonsendable)
19551955
}
19561956

1957-
pub fn contains_managed(&self) -> bool {
1957+
pub fn owns_managed(&self) -> bool {
19581958
self.intersects(TC::OwnsManaged)
19591959
}
19601960

src/librustc/middle/typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3732,7 +3732,7 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
37323732
ty::mk_nil())
37333733
}
37343734
"needs_drop" => (1u, ~[], ty::mk_bool()),
3735-
"contains_managed" => (1u, ~[], ty::mk_bool()),
3735+
"owns_managed" => (1u, ~[], ty::mk_bool()),
37363736
"atomic_xchg" | "atomic_xadd" | "atomic_xsub" |
37373737
"atomic_xchg_acq" | "atomic_xadd_acq" | "atomic_xsub_acq" |
37383738
"atomic_xchg_rel" | "atomic_xadd_rel" | "atomic_xsub_rel" => {

src/libstd/unstable/intrinsics.rs

+5
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,13 @@ extern "rust-intrinsic" {
337337
pub fn needs_drop<T>() -> bool;
338338

339339
/// Returns `true` if a type is managed (will be allocated on the local heap)
340+
#[cfg(stage0)]
340341
pub fn contains_managed<T>() -> bool;
341342

343+
/// Returns `true` if a type is managed (will be allocated on the local heap)
344+
#[cfg(not(stage0))]
345+
pub fn owns_managed<T>() -> bool;
346+
342347
pub fn visit_tydesc(td: *TyDesc, tv: &mut TyVisitor);
343348

344349
/// Get the address of the `__morestack` stack growth function.

src/libstd/vec.rs

+21-8
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,19 @@ use mem::size_of;
121121
use uint;
122122
use unstable::finally::Finally;
123123
use unstable::intrinsics;
124-
use unstable::intrinsics::{get_tydesc, contains_managed};
124+
use unstable::intrinsics::{get_tydesc};
125125
use unstable::raw::{Box, Repr, Slice, Vec};
126126
use vec;
127127
use util;
128128

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+
129137
/**
130138
* Creates and initializes an owned vector.
131139
*
@@ -180,7 +188,7 @@ pub fn from_elem<T:Clone>(n_elts: uint, t: T) -> ~[T] {
180188
#[inline]
181189
pub fn with_capacity<T>(capacity: uint) -> ~[T] {
182190
unsafe {
183-
if contains_managed::<T>() {
191+
if owns_managed::<T>() {
184192
let mut vec = ~[];
185193
vec.reserve(capacity);
186194
vec
@@ -1401,7 +1409,7 @@ impl<T> OwnedVector<T> for ~[T] {
14011409
if self.capacity() < n {
14021410
unsafe {
14031411
let td = get_tydesc::<T>();
1404-
if contains_managed::<T>() {
1412+
if owns_managed::<T>() {
14051413
let ptr: *mut *mut Box<Vec<()>> = cast::transmute(self);
14061414
::at_vec::raw::reserve_raw(td, ptr, n);
14071415
} else {
@@ -1437,7 +1445,7 @@ impl<T> OwnedVector<T> for ~[T] {
14371445
#[inline]
14381446
fn capacity(&self) -> uint {
14391447
unsafe {
1440-
if contains_managed::<T>() {
1448+
if owns_managed::<T>() {
14411449
let repr: **Box<Vec<()>> = cast::transmute(self);
14421450
(**repr).data.alloc / mem::nonzero_size_of::<T>()
14431451
} else {
@@ -1460,7 +1468,7 @@ impl<T> OwnedVector<T> for ~[T] {
14601468
#[inline]
14611469
fn push(&mut self, t: T) {
14621470
unsafe {
1463-
if contains_managed::<T>() {
1471+
if owns_managed::<T>() {
14641472
let repr: **Box<Vec<()>> = cast::transmute(&mut *self);
14651473
let fill = (**repr).data.fill;
14661474
if (**repr).data.alloc <= fill {
@@ -1482,7 +1490,7 @@ impl<T> OwnedVector<T> for ~[T] {
14821490
// This doesn't bother to make sure we have space.
14831491
#[inline] // really pretty please
14841492
unsafe fn push_fast<T>(this: &mut ~[T], t: T) {
1485-
if contains_managed::<T>() {
1493+
if owns_managed::<T>() {
14861494
let repr: **mut Box<Vec<u8>> = cast::transmute(this);
14871495
let fill = (**repr).data.fill;
14881496
(**repr).data.fill += mem::nonzero_size_of::<T>();
@@ -2057,9 +2065,14 @@ pub mod raw {
20572065
use mem;
20582066
use unstable::intrinsics;
20592067
use vec::{with_capacity, ImmutableVector, MutableVector};
2060-
use unstable::intrinsics::contains_managed;
20612068
use unstable::raw::{Box, Vec, Slice};
20622069

2070+
#[cfg(not(stage0))]
2071+
use unstable::intrinsics::owns_managed;
2072+
2073+
#[cfg(stage0)]
2074+
use vec::owns_managed;
2075+
20632076
/**
20642077
* Sets the length of a vector
20652078
*
@@ -2069,7 +2082,7 @@ pub mod raw {
20692082
*/
20702083
#[inline]
20712084
pub unsafe fn set_len<T>(v: &mut ~[T], new_len: uint) {
2072-
if contains_managed::<T>() {
2085+
if owns_managed::<T>() {
20732086
let repr: **mut Box<Vec<()>> = cast::transmute(v);
20742087
(**repr).data.fill = new_len * mem::nonzero_size_of::<T>();
20752088
} else {

0 commit comments

Comments
 (0)