Skip to content

Commit b914162

Browse files
committed
add a contains_managed intrinsic
1 parent b883d6a commit b914162

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

src/librustc/middle/trans/foreign.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,12 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
751751
C_bool(ty::type_needs_drop(ccx.tcx, tp_ty)),
752752
fcx.llretptr.get());
753753
}
754+
"contains_managed" => {
755+
let tp_ty = substs.tys[0];
756+
Store(bcx,
757+
C_bool(ty::type_contents(ccx.tcx, tp_ty).contains_managed()),
758+
fcx.llretptr.get());
759+
}
754760
"visit_tydesc" => {
755761
let td = get_param(decl, first_real_arg);
756762
let visitor = get_param(decl, first_real_arg + 1u);

src/librustc/middle/trans/type_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub fn type_uses_for(ccx: @mut CrateContext, fn_id: def_id, n_tps: uint)
127127
"uninit" | "init" | "transmute" | "move_val" |
128128
"move_val_init" => use_repr,
129129

130-
"get_tydesc" | "needs_drop" => use_tydesc,
130+
"get_tydesc" | "needs_drop" | "contains_managed" => use_tydesc,
131131

132132
"visit_tydesc" | "forget" | "frame_address" |
133133
"morestack_addr" => 0,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3540,7 +3540,7 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
35403540
ty::mk_nil())
35413541
}
35423542
"needs_drop" => (1u, ~[], ty::mk_bool()),
3543-
3543+
"contains_managed" => (1u, ~[], ty::mk_bool()),
35443544
"atomic_xchg" | "atomic_xadd" | "atomic_xsub" |
35453545
"atomic_xchg_acq" | "atomic_xadd_acq" | "atomic_xsub_acq" |
35463546
"atomic_xchg_rel" | "atomic_xadd_rel" | "atomic_xsub_rel" => {

src/libstd/unstable/intrinsics.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ pub extern "rust-intrinsic" {
308308
/// Returns `true` if a type requires drop glue.
309309
pub fn needs_drop<T>() -> bool;
310310

311+
/// Returns `true` if a type is managed (will be allocated on the local heap)
312+
#[cfg(not(stage0))]
313+
pub fn contains_managed<T>() -> bool;
314+
311315
#[cfg(not(stage0))]
312316
pub fn visit_tydesc(td: *TyDesc, tv: @TyVisitor);
313317

0 commit comments

Comments
 (0)