Skip to content

Commit a0fa099

Browse files
committed
Add a needs_drop intrinsic
Closes #2055
1 parent 35b8f87 commit a0fa099

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/rustc/middle/trans/native.rs

+4
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,10 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::native_item,
801801
"addr_of" {
802802
Store(bcx, get_param(decl, first_real_arg), fcx.llretptr);
803803
}
804+
"needs_drop" {
805+
Store(bcx, C_bool(ty::type_needs_drop(ccx.tcx, tp_ty)),
806+
fcx.llretptr);
807+
}
804808
}
805809
build_return(bcx);
806810
finish_fn(fcx, lltop);

src/rustc/middle/trans/type_use.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
7878
let flags = alt check i.ident {
7979
"size_of" | "align_of" | "init" |
8080
"reinterpret_cast" { use_repr }
81-
"get_tydesc" { use_tydesc }
81+
"get_tydesc" | "needs_drop" { use_tydesc }
8282
"forget" | "addr_of" { 0u }
8383
};
8484
uint::range(0u, n_tps) {|n| cx.uses[n] |= flags;}

src/rustc/middle/typeck.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1899,6 +1899,7 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::native_item) {
18991899
param(ccx, 1u)) }
19001900
"addr_of" { (1u, [arg(ast::by_ref, param(ccx, 0u))],
19011901
ty::mk_imm_ptr(tcx, param(ccx, 0u))) }
1902+
"needs_drop" { (1u, [], ty::mk_bool(tcx)) }
19021903
other {
19031904
tcx.sess.span_err(it.span, "unrecognized intrinsic function: `" +
19041905
other + "`");

0 commit comments

Comments
 (0)