From 76679c1f91fc68134c850b2d77ff2b83b32a108f Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 31 Jan 2013 17:52:42 -0800 Subject: [PATCH] DO NOT COMMIT --- src/librustc/middle/trans/glue.rs | 21 +++++++++++++++++++++ src/librustc/middle/ty.rs | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index 4e557082e61..50aa478b74b 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -571,9 +571,30 @@ pub fn decr_refcnt_maybe_free(bcx: block, } } +pub fn copy_glue_should_never_be_called(bcx: block, t: ty::t) -> bool { + match ty::get(t).sty { + ty::ty_infer(*) + | ty::ty_type + | ty::ty_opaque_closure_ptr(*) + | ty::ty_opaque_box + | ty::ty_unboxed_vec(*) + | ty::ty_err => { + // Not sure under what scenarios these non-types get take glue + false + } + _ => !ty::type_is_copyable(bcx.tcx(), t) + } +} pub fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) { let _icx = bcx.insn_ctxt("make_take_glue"); + + if copy_glue_should_never_be_called(bcx, t) { + controlflow::trans_fail(bcx, bcx.fcx.span, + ~"calling take glue on non-copyable"); + return; + } + // NB: v is a *pointer* to type t here, not a direct value. let bcx = match ty::get(t).sty { ty::ty_box(_) | ty::ty_opaque_box | diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index b07e3ef7b81..48e6a3145f0 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2181,7 +2181,8 @@ pub fn type_kind_ext(cx: ctxt, ty: t, allow_ty_var: bool) -> Kind { ty_type | ty_opaque_closure_ptr(_) | ty_opaque_box | ty_unboxed_vec(_) | ty_err => { - cx.sess.bug(~"Asked to compute kind of fictitious type"); + kind_copyable() + //cx.sess.bug(~"Asked to compute kind of fictitious type"); } };