remove ty_closure

This commit is contained in:
Jorge Aparicio 2015-01-04 09:50:17 -05:00
parent 18e2026ff8
commit 5f7f2c9a05
32 changed files with 11 additions and 409 deletions

View File

@ -494,11 +494,7 @@ fn check_heap_type<'a, 'tcx>(&self, cx: &Context<'a, 'tcx>,
let mut n_uniq = 0i;
ty::fold_ty(cx.tcx, ty, |t| {
match t.sty {
ty::ty_uniq(_) |
ty::ty_closure(box ty::ClosureTy {
store: ty::UniqTraitStore,
..
}) => {
ty::ty_uniq(_) => {
n_uniq += 1;
}

View File

@ -119,10 +119,6 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
ty::ty_str => {
mywrite!(w, "v");
}
ty::ty_closure(ref f) => {
mywrite!(w, "f");
enc_closure_ty(w, cx, &**f);
}
ty::ty_bare_fn(Some(def_id), f) => {
mywrite!(w, "F");
mywrite!(w, "{}|", (cx.ds)(def_id));

View File

@ -33,7 +33,6 @@ enum UnsafeContext {
fn type_is_unsafe_function(ty: Ty) -> bool {
match ty.sty {
ty::ty_bare_fn(_, ref f) => f.unsafety == ast::Unsafety::Unsafe,
ty::ty_closure(ref f) => f.unsafety == ast::Unsafety::Unsafe,
_ => false,
}
}

View File

@ -656,19 +656,6 @@ fn walk_callee(&mut self, call: &ast::Expr, callee: &ast::Expr) {
ty::ty_bare_fn(..) => {
self.consume_expr(callee);
}
ty::ty_closure(ref f) => {
match f.onceness {
ast::Many => {
self.borrow_expr(callee,
ty::ReScope(call_scope),
ty::UniqueImmBorrow,
ClosureInvocation);
}
ast::Once => {
self.consume_expr(callee);
}
}
}
ty::ty_err => { }
_ => {
let overloaded_call_type =

View File

@ -80,9 +80,6 @@ pub fn simplify_type(tcx: &ty::ctxt,
ty::ty_tup(ref tys) => {
Some(TupleSimplifiedType(tys.len()))
}
ty::ty_closure(ref f) => {
Some(FunctionSimplifiedType(f.sig.0.inputs.len()))
}
ty::ty_bare_fn(_, ref f) => {
Some(FunctionSimplifiedType(f.sig.0.inputs.len()))
}

View File

@ -160,15 +160,6 @@ pub fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> CoerceResult<'tcx> {
};
}
ty::ty_closure(box ty::ClosureTy {
store: ty::RegionTraitStore(..),
..
}) => {
return self.unpack_actual_value(a, |a| {
self.coerce_borrowed_fn(a, b)
});
}
_ => {}
}
@ -511,21 +502,6 @@ fn coerce_from_fn_item(&self,
a.repr(self.tcx()), b.repr(self.tcx()));
match b.sty {
ty::ty_closure(ref f) => {
if fn_ty_a.abi != abi::Rust || fn_ty_a.unsafety != ast::Unsafety::Normal {
return self.subtype(a, b);
}
let fn_ty_b = (*f).clone();
let adj = ty::AdjustAddEnv(fn_def_id_a, fn_ty_b.store);
let a_closure = ty::mk_closure(self.tcx(),
ty::ClosureTy {
sig: fn_ty_a.sig.clone(),
.. *fn_ty_b
});
try!(self.subtype(a_closure, b));
Ok(Some(adj))
}
ty::ty_bare_fn(None, _) => {
let a_fn_pointer = ty::mk_bare_fn(self.tcx(), None, fn_ty_a);
try!(self.subtype(a_fn_pointer, b));

View File

@ -644,12 +644,6 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
Ok(ty::mk_bare_fn(tcx, a_opt_def_id, tcx.mk_bare_fn(fty)))
}
(&ty::ty_closure(ref a_fty), &ty::ty_closure(ref b_fty)) => {
this.closure_tys(&**a_fty, &**b_fty).and_then(|fty| {
Ok(ty::mk_closure(tcx, fty))
})
}
(&ty::ty_projection(ref a_data), &ty::ty_projection(ref b_data)) => {
let projection_ty = try!(this.projection_tys(a_data, b_data));
Ok(ty::mk_projection(tcx, projection_ty.trait_ref, projection_ty.item_name))

View File

@ -152,7 +152,6 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
ty::ty_ptr(..) |
ty::ty_rptr(..) |
ty::ty_bare_fn(..) |
ty::ty_closure(..) |
ty::ty_trait(..) |
ty::ty_struct(..) |
ty::ty_unboxed_closure(..) |

View File

@ -197,8 +197,7 @@ pub enum deref_kind {
// pointer adjustment).
pub fn deref_kind(t: Ty) -> McResult<deref_kind> {
match t.sty {
ty::ty_uniq(_) |
ty::ty_closure(box ty::ClosureTy {store: ty::UniqTraitStore, ..}) => {
ty::ty_uniq(_) => {
Ok(deref_ptr(Unique))
}
@ -207,13 +206,6 @@ pub fn deref_kind(t: Ty) -> McResult<deref_kind> {
Ok(deref_ptr(BorrowedPtr(kind, *r)))
}
ty::ty_closure(box ty::ClosureTy {
store: ty::RegionTraitStore(r, _),
..
}) => {
Ok(deref_ptr(BorrowedPtr(ty::ImmBorrow, r)))
}
ty::ty_ptr(ref mt) => {
Ok(deref_ptr(UnsafePtr(mt.mutbl)))
}
@ -592,25 +584,6 @@ pub fn cat_def(&self,
def::DefUpvar(var_id, fn_node_id, _) => {
let ty = try!(self.node_ty(fn_node_id));
match ty.sty {
ty::ty_closure(ref closure_ty) => {
// Translate old closure type info into unboxed
// closure kind/capture mode
let (mode, kind) = match (closure_ty.store, closure_ty.onceness) {
// stack closure
(ty::RegionTraitStore(..), ast::Many) => {
(ast::CaptureByRef, ty::FnMutUnboxedClosureKind)
}
// proc or once closure
(_, ast::Once) => {
(ast::CaptureByValue, ty::FnOnceUnboxedClosureKind)
}
// There should be no such old closure type
(ty::UniqTraitStore, ast::Many) => {
self.tcx().sess.span_bug(span, "Impossible closure type");
}
};
self.cat_upvar(id, span, var_id, fn_node_id, kind, mode, false)
}
ty::ty_unboxed_closure(closure_id, _, _) => {
let kind = self.typer.unboxed_closure_kind(closure_id);
let mode = self.typer.capture_mode(fn_node_id);

View File

@ -118,7 +118,6 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
ty::ty_float(..) |
ty::ty_str(..) |
ty::ty_bare_fn(..) |
ty::ty_closure(..) |
ty::ty_vec(..) |
ty::ty_ptr(..) |
ty::ty_rptr(..) |

View File

@ -1273,62 +1273,6 @@ fn builtin_bound(&mut self,
}
}
ty::ty_closure(ref c) => {
match c.store {
ty::UniqTraitStore => {
// proc: Equivalent to `Box<FnOnce>`
match bound {
ty::BoundCopy => {
Err(Unimplemented)
}
ty::BoundSized => {
Ok(If(Vec::new()))
}
ty::BoundSync |
ty::BoundSend => {
if c.bounds.builtin_bounds.contains(&bound) {
Ok(If(Vec::new()))
} else {
Err(Unimplemented)
}
}
}
}
ty::RegionTraitStore(_, mutbl) => {
// ||: Equivalent to `&FnMut` or `&mut FnMut` or something like that.
match bound {
ty::BoundCopy => {
match mutbl {
ast::MutMutable => {
// &mut T is affine
Err(Unimplemented)
}
ast::MutImmutable => {
// &T is copyable, no matter what T is
Ok(If(Vec::new()))
}
}
}
ty::BoundSized => {
Ok(If(Vec::new()))
}
ty::BoundSync |
ty::BoundSend => {
if c.bounds.builtin_bounds.contains(&bound) {
Ok(If(Vec::new()))
} else {
Err(Unimplemented)
}
}
}
}
}
}
ty::ty_trait(ref data) => {
match bound {
ty::BoundSized => {

View File

@ -916,7 +916,7 @@ impl<'tcx> ctxt<'tcx> {
pub fn print_debug_stats(&self) {
sty_debug_print!(
self,
ty_enum, ty_uniq, ty_vec, ty_ptr, ty_rptr, ty_bare_fn, ty_closure, ty_trait,
ty_enum, ty_uniq, ty_vec, ty_ptr, ty_rptr, ty_bare_fn, ty_trait,
ty_struct, ty_unboxed_closure, ty_tup, ty_param, ty_open, ty_infer, ty_projection);
println!("Substs interner: #{}", self.substs_interner.borrow().len());
@ -1353,7 +1353,6 @@ pub enum sty<'tcx> {
// fn item. Otherwise, if None(_), it a fn pointer type.
ty_bare_fn(Option<DefId>, &'tcx BareFnTy<'tcx>),
ty_closure(Box<ClosureTy<'tcx>>),
ty_trait(Box<TyTrait<'tcx>>),
ty_struct(DefId, &'tcx Substs<'tcx>),
@ -2594,14 +2593,6 @@ fn add_sty(&mut self, st: &sty) {
&ty_bare_fn(_, ref f) => {
self.add_fn_sig(&f.sig);
}
&ty_closure(ref f) => {
if let RegionTraitStore(r, _) = f.store {
self.add_region(r);
}
self.add_fn_sig(&f.sig);
self.add_bounds(&f.bounds);
}
}
}
@ -2749,7 +2740,7 @@ pub fn mk_nil<'tcx>(cx: &ctxt<'tcx>) -> Ty<'tcx> {
}
pub fn mk_closure<'tcx>(cx: &ctxt<'tcx>, fty: ClosureTy<'tcx>) -> Ty<'tcx> {
mk_t(cx, ty_closure(box fty))
panic!("stub");
}
pub fn mk_bare_fn<'tcx>(cx: &ctxt<'tcx>,
@ -3028,7 +3019,7 @@ pub fn type_is_vec(ty: Ty) -> bool {
pub fn type_is_structural(ty: Ty) -> bool {
match ty.sty {
ty_struct(..) | ty_tup(_) | ty_enum(..) | ty_closure(_) |
ty_struct(..) | ty_tup(_) | ty_enum(..) |
ty_vec(_, Some(_)) | ty_unboxed_closure(..) => true,
_ => type_is_slice(ty) | type_is_trait(ty)
}
@ -3345,10 +3336,6 @@ fn tc_ty<'tcx>(cx: &ctxt<'tcx>,
TC::None
}
ty_closure(ref c) => {
closure_contents(&**c) | TC::ReachesFfiUnsafe
}
ty_uniq(typ) => {
TC::ReachesFfiUnsafe | match typ.sty {
ty_str => TC::OwnsOwned,
@ -3649,7 +3636,6 @@ fn subtypes_require<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<DefId>,
ty_float(_) |
ty_str |
ty_bare_fn(..) |
ty_closure(_) |
ty_param(_) |
ty_projection(_) |
ty_vec(_, None) => {
@ -4153,7 +4139,6 @@ pub fn node_id_item_substs<'tcx>(cx: &ctxt<'tcx>, id: ast::NodeId) -> ItemSubsts
pub fn fn_is_variadic(fty: Ty) -> bool {
match fty.sty {
ty_bare_fn(_, ref f) => f.sig.0.variadic,
ty_closure(ref f) => f.sig.0.variadic,
ref s => {
panic!("fn_is_variadic() called on non-fn type: {}", s)
}
@ -4163,7 +4148,6 @@ pub fn fn_is_variadic(fty: Ty) -> bool {
pub fn ty_fn_sig<'tcx>(fty: Ty<'tcx>) -> &'tcx PolyFnSig<'tcx> {
match fty.sty {
ty_bare_fn(_, ref f) => &f.sig,
ty_closure(ref f) => &f.sig,
ref s => {
panic!("ty_fn_sig() called on non-fn type: {}", s)
}
@ -4174,7 +4158,6 @@ pub fn ty_fn_sig<'tcx>(fty: Ty<'tcx>) -> &'tcx PolyFnSig<'tcx> {
pub fn ty_fn_abi(fty: Ty) -> abi::Abi {
match fty.sty {
ty_bare_fn(_, ref f) => f.abi,
ty_closure(ref f) => f.abi,
_ => panic!("ty_fn_abi() called on non-fn type"),
}
}
@ -4186,7 +4169,6 @@ pub fn ty_fn_args<'tcx>(fty: Ty<'tcx>) -> &'tcx [Ty<'tcx>] {
pub fn ty_closure_store(fty: Ty) -> TraitStore {
match fty.sty {
ty_closure(ref f) => f.store,
ty_unboxed_closure(..) => {
// Close enough for the purposes of all the callers of this
// function (which is soon to be deprecated anyhow).
@ -4201,7 +4183,6 @@ pub fn ty_closure_store(fty: Ty) -> TraitStore {
pub fn ty_fn_ret<'tcx>(fty: Ty<'tcx>) -> FnOutput<'tcx> {
match fty.sty {
ty_bare_fn(_, ref f) => f.sig.0.output,
ty_closure(ref f) => f.sig.0.output,
ref s => {
panic!("ty_fn_ret() called on non-fn type: {}", s)
}
@ -4211,7 +4192,6 @@ pub fn ty_fn_ret<'tcx>(fty: Ty<'tcx>) -> FnOutput<'tcx> {
pub fn is_fn_ty(fty: Ty) -> bool {
match fty.sty {
ty_bare_fn(..) => true,
ty_closure(_) => true,
_ => false
}
}
@ -4731,7 +4711,6 @@ pub fn ty_sort_string<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> String {
ty_rptr(_, _) => "&-ptr".to_string(),
ty_bare_fn(Some(_), _) => format!("fn item"),
ty_bare_fn(None, _) => "fn pointer".to_string(),
ty_closure(_) => "fn".to_string(),
ty_trait(ref inner) => {
format!("trait {}", item_path_str(cx, inner.principal_def_id()))
}
@ -6326,24 +6305,6 @@ fn helper<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh, state: &mut sip::SipS
fn_sig(state, &b.sig);
return false;
}
ty_closure(ref c) => {
byte!(15);
hash!(c.unsafety);
hash!(c.onceness);
hash!(c.bounds);
match c.store {
UniqTraitStore => byte!(0),
RegionTraitStore(r, m) => {
byte!(1);
region(state, r);
assert_eq!(m, ast::MutMutable);
}
}
fn_sig(state, &c.sig);
return false;
}
ty_trait(ref data) => {
byte!(17);
did(state, data.principal_def_id());
@ -6666,12 +6627,6 @@ pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec<ty::Region>,
ty_struct(_, substs) => {
accum_substs(accumulator, substs);
}
ty_closure(ref closure_ty) => {
match closure_ty.store {
RegionTraitStore(region, _) => accumulator.push(region),
UniqTraitStore => {}
}
}
ty_unboxed_closure(_, region, substs) => {
accumulator.push(*region);
accum_substs(accumulator, substs);

View File

@ -604,9 +604,6 @@ pub fn super_fold_ty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
let bfn = f.fold_with(this);
ty::ty_bare_fn(opt_def_id, this.tcx().mk_bare_fn(bfn))
}
ty::ty_closure(ref f) => {
ty::ty_closure(f.fold_with(this))
}
ty::ty_rptr(r, ref tm) => {
let r = r.fold_with(this);
ty::ty_rptr(this.tcx().mk_region(r), tm.fold_with(this))

View File

@ -51,9 +51,6 @@ fn push_subtypes(&mut self, parent_ty: Ty<'tcx>) {
ty::ty_bare_fn(_, ref ft) => {
self.push_sig_subtypes(&ft.sig);
}
ty::ty_closure(ref ft) => {
self.push_sig_subtypes(&ft.sig);
}
}
}

View File

@ -18,7 +18,7 @@
use middle::ty::{ReSkolemized, ReVar, BrEnv};
use middle::ty::{mt, Ty, ParamTy};
use middle::ty::{ty_bool, ty_char, ty_struct, ty_enum};
use middle::ty::{ty_err, ty_str, ty_vec, ty_float, ty_bare_fn, ty_closure};
use middle::ty::{ty_err, ty_str, ty_vec, ty_float, ty_bare_fn};
use middle::ty::{ty_param, ty_ptr, ty_rptr, ty_tup, ty_open};
use middle::ty::{ty_unboxed_closure};
use middle::ty::{ty_uniq, ty_trait, ty_int, ty_uint, ty_infer};
@ -417,9 +417,6 @@ fn infer_ty_to_string(cx: &ctxt, ty: ty::InferTy) -> String {
strs => format!("({})", strs.connect(", "))
}
}
ty_closure(ref f) => {
closure_to_string(cx, &**f)
}
ty_bare_fn(opt_def_id, ref f) => {
bare_fn_to_string(cx, opt_def_id, f.unsafety, f.abi, None, &f.sig)
}

View File

@ -662,13 +662,6 @@ fn move_suggestion<'a,'tcx>(param_env: &ty::ParameterEnvironment<'a,'tcx>,
default_msgs: (&'static str, &'static str))
-> (&'static str, &'static str) {
match ty.sty {
ty::ty_closure(box ty::ClosureTy {
store: ty::RegionTraitStore(..),
..
}) => {
("a non-copyable stack closure",
"capture it in a new closure, e.g. `|x| f(x)`, to override")
}
_ => {
if ty::type_moves_by_default(param_env, span, ty) {
("non-copyable",

View File

@ -355,12 +355,6 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
// Functions are just pointers
ty::ty_bare_fn(..) => Some(path),
// Closures are a pair of pointers: the code and environment
ty::ty_closure(..) => {
path.push(FAT_PTR_ADDR);
Some(path)
},
// Is this the NonZero lang item wrapping a pointer or integer type?
ty::ty_struct(did, substs) if Some(did) == tcx.lang_items.non_zero() => {
let nonzero_fields = ty::lookup_struct_fields(tcx, did);

View File

@ -287,9 +287,6 @@ pub fn decl_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
ty::ty_bare_fn(_, ref f) => {
(f.sig.0.inputs.clone(), f.sig.0.output, f.abi, None)
}
ty::ty_closure(ref f) => {
(f.sig.0.inputs.clone(), f.sig.0.output, f.abi, Some(Type::i8p(ccx)))
}
ty::ty_unboxed_closure(closure_did, _, substs) => {
let typer = common::NormalizingUnboxedClosureTyper::new(ccx.tcx());
let function_type = typer.unboxed_closure_type(closure_did, substs);
@ -952,9 +949,6 @@ pub fn trans_external_path<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}
}
ty::ty_closure(_) => {
get_extern_rust_fn(ccx, t, name[], did)
}
_ => {
get_extern_const(ccx, did, t)
}
@ -2438,7 +2432,6 @@ pub fn get_fn_llvm_attributes<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<
use middle::ty::{BrAnon, ReLateBound};
let (fn_sig, abi, has_env) = match fn_ty.sty {
ty::ty_closure(ref f) => (f.sig.clone(), f.abi, true),
ty::ty_bare_fn(_, ref f) => (f.sig.clone(), f.abi, false),
ty::ty_unboxed_closure(closure_did, _, substs) => {
let typer = common::NormalizingUnboxedClosureTyper::new(ccx.tcx());

View File

@ -111,14 +111,6 @@ fn datum_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
data: Fn(llval),
};
}
ty::ty_closure(..) => {
let datum = unpack_datum!(
bcx, datum.to_lvalue_datum(bcx, "callee", expr.id));
return Callee {
bcx: bcx,
data: Closure(datum),
};
}
_ => {
bcx.tcx().sess.span_bug(
expr.span,
@ -679,7 +671,6 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
let (abi, ret_ty) = match callee_ty.sty {
ty::ty_bare_fn(_, ref f) => (f.abi, f.sig.0.output),
ty::ty_closure(ref f) => (f.abi, f.sig.0.output),
_ => panic!("expected bare rust fn or closure in trans_call_inner")
};

View File

@ -599,7 +599,6 @@ pub fn get_wrapper_for_bare_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
debug!("get_wrapper_for_bare_fn(closure_ty={})", closure_ty.repr(tcx));
let f = match closure_ty.sty {
ty::ty_closure(ref f) => f,
_ => {
ccx.sess().bug(format!("get_wrapper_for_bare_fn: \
expected a closure ty, got {}",

View File

@ -465,11 +465,6 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
}
}
},
ty::ty_closure(box ref closure_ty) => {
self.get_unique_type_id_of_closure_type(cx,
closure_ty.clone(),
&mut unique_type_id);
},
ty::ty_unboxed_closure(def_id, _, substs) => {
let typer = NormalizingUnboxedClosureTyper::new(cx.tcx());
let closure_ty = typer.unboxed_closure_type(def_id, substs);
@ -3017,9 +3012,6 @@ fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
ty::ty_bare_fn(_, ref barefnty) => {
subroutine_type_metadata(cx, unique_type_id, &barefnty.sig, usage_site_span)
}
ty::ty_closure(ref closurety) => {
subroutine_type_metadata(cx, unique_type_id, &closurety.sig, usage_site_span)
}
ty::ty_unboxed_closure(def_id, _, substs) => {
let typer = NormalizingUnboxedClosureTyper::new(cx.tcx());
let sig = typer.unboxed_closure_type(def_id, substs).sig;
@ -3870,66 +3862,6 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}
}
},
ty::ty_closure(box ty::ClosureTy { unsafety,
onceness,
store,
ref sig,
.. // omitting bounds ...
}) => {
if unsafety == ast::Unsafety::Unsafe {
output.push_str("unsafe ");
}
if onceness == ast::Once {
output.push_str("once ");
}
let param_list_closing_char;
match store {
ty::UniqTraitStore => {
output.push_str("proc(");
param_list_closing_char = ')';
}
ty::RegionTraitStore(_, ast::MutMutable) => {
output.push_str("&mut|");
param_list_closing_char = '|';
}
ty::RegionTraitStore(_, ast::MutImmutable) => {
output.push_str("&|");
param_list_closing_char = '|';
}
};
if sig.0.inputs.len() > 0 {
for &parameter_type in sig.0.inputs.iter() {
push_debuginfo_type_name(cx, parameter_type, true, output);
output.push_str(", ");
}
output.pop();
output.pop();
}
if sig.0.variadic {
if sig.0.inputs.len() > 0 {
output.push_str(", ...");
} else {
output.push_str("...");
}
}
output.push(param_list_closing_char);
match sig.0.output {
ty::FnConverging(result_type) if ty::type_is_nil(result_type) => {}
ty::FnConverging(result_type) => {
output.push_str(" -> ");
push_debuginfo_type_name(cx, result_type, true, output);
}
ty::FnDiverging => {
output.push_str(" -> !");
}
}
},
ty::ty_unboxed_closure(..) => {
output.push_str("closure");
}

View File

@ -441,18 +441,6 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: Ty<'tcx>)
v0,
t,
|bb, vv, tt| drop_ty(bb, vv, tt, None)),
ty::ty_closure(ref f) if f.store == ty::UniqTraitStore => {
let box_cell_v = GEPi(bcx, v0, &[0u, abi::FAT_PTR_EXTRA]);
let env = Load(bcx, box_cell_v);
let env_ptr_ty = Type::at_box(bcx.ccx(), Type::i8(bcx.ccx())).ptr_to();
let env = PointerCast(bcx, env, env_ptr_ty);
with_cond(bcx, IsNotNull(bcx, env), |bcx| {
let dtor_ptr = GEPi(bcx, env, &[0u, abi::BOX_FIELD_DROP_GLUE]);
let dtor = Load(bcx, dtor_ptr);
Call(bcx, dtor, &[PointerCast(bcx, box_cell_v, Type::i8p(bcx.ccx()))], None);
bcx
})
}
ty::ty_trait(..) => {
// No need to do a null check here (as opposed to the Box<trait case
// above), because this happens for a trait field in an unsized

View File

@ -143,13 +143,6 @@ pub fn type_of_rust_fn<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// Given a function type and a count of ty params, construct an llvm type
pub fn type_of_fn_from_ty<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, fty: Ty<'tcx>) -> Type {
match fty.sty {
ty::ty_closure(ref f) => {
type_of_rust_fn(cx,
Some(Type::i8p(cx)),
f.sig.0.inputs.as_slice(),
f.sig.0.output,
f.abi)
}
ty::ty_bare_fn(_, ref f) => {
// FIXME(#19925) once fn item types are
// zero-sized, we'll need to do something here
@ -207,7 +200,6 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
}
ty::ty_bare_fn(..) => Type::i8p(cx),
ty::ty_closure(..) => Type::struct_(cx, &[Type::i8p(cx), Type::i8p(cx)], false),
ty::ty_vec(ty, Some(size)) => {
let llty = sizing_type_of(cx, ty);
@ -369,10 +361,6 @@ fn type_of_unsize_info<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Ty
ty::ty_bare_fn(..) => {
type_of_fn_from_ty(cx, t).ptr_to()
}
ty::ty_closure(_) => {
let fn_ty = type_of_fn_from_ty(cx, t).ptr_to();
Type::struct_(cx, &[fn_ty, Type::i8p(cx)], false)
}
ty::ty_tup(ref tys) if tys.is_empty() => Type::nil(cx),
ty::ty_tup(..) => {
let repr = adt::represent_type(cx, t);

View File

@ -111,7 +111,7 @@ fn try_overloaded_call_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
{
// If the callee is a bare function or a closure, then we're all set.
match structurally_resolved_type(fcx, callee_expr.span, adjusted_ty).sty {
ty::ty_bare_fn(..) | ty::ty_closure(_) => {
ty::ty_bare_fn(..) => {
fcx.write_adjustment(callee_expr.id,
callee_expr.span,
ty::AdjustDerefRef(autoderefref));
@ -158,8 +158,7 @@ fn confirm_builtin_call<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
let error_fn_sig;
let fn_sig = match callee_ty.sty {
ty::ty_bare_fn(_, &ty::BareFnTy {ref sig, ..}) |
ty::ty_closure(box ty::ClosureTy {ref sig, ..}) => {
ty::ty_bare_fn(_, &ty::BareFnTy {ref sig, ..}) => {
sig
}
_ => {

View File

@ -268,7 +268,6 @@ fn check_boxed_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
// fresh bound regions for any bound regions we find in the
// expected types so as to avoid capture.
let expected_cenv = expected.map_to_option(fcx, |ty| match ty.sty {
ty::ty_closure(ref cenv) => Some(cenv),
_ => None
});
let (expected_sig, expected_onceness, expected_bounds) = match expected_cenv {

View File

@ -462,7 +462,6 @@ fn fixup_derefs_on_method_receiver_if_necessary(&self,
method_callee: &MethodCallee) {
let sig = match method_callee.ty.sty {
ty::ty_bare_fn(_, ref f) => f.sig.clone(),
ty::ty_closure(ref f) => f.sig.clone(),
_ => return,
};

View File

@ -735,29 +735,6 @@ fn check_expr_fn_block(rcx: &mut Rcx,
let function_type = rcx.resolve_node_type(expr.id);
match function_type.sty {
ty::ty_closure(box ty::ClosureTy{store: ty::RegionTraitStore(..),
ref bounds,
..}) => {
// For closure, ensure that the variables outlive region
// bound, since they are captured by reference.
ty::with_freevars(tcx, expr.id, |freevars| {
if freevars.is_empty() {
// No free variables means that the environment
// will be NULL at runtime and hence the closure
// has static lifetime.
} else {
// Variables being referenced must outlive closure.
constrain_free_variables_in_by_ref_closure(
rcx, bounds.region_bound, expr, freevars);
// Closure is stack allocated and hence cannot
// outlive the appropriate temporary scope.
let s = rcx.repeating_scope;
rcx.fcx.mk_subr(infer::InfStackClosure(expr.span),
bounds.region_bound, ty::ReScope(CodeExtent::from_node_id(s)));
}
});
}
ty::ty_unboxed_closure(_, region, _) => {
if tcx.capture_modes.borrow()[expr.id].clone() == ast::CaptureByRef {
ty::with_freevars(tcx, expr.id, |freevars| {
@ -778,11 +755,6 @@ fn check_expr_fn_block(rcx: &mut Rcx,
rcx.set_repeating_scope(repeating_scope);
match function_type.sty {
ty::ty_closure(box ty::ClosureTy {ref bounds, ..}) => {
ty::with_freevars(tcx, expr.id, |freevars| {
ensure_free_variable_types_outlive_closure_bound(rcx, bounds, expr, freevars);
})
}
ty::ty_unboxed_closure(_, region, _) => {
ty::with_freevars(tcx, expr.id, |freevars| {
let bounds = ty::region_existential_bound(*region);
@ -891,26 +863,6 @@ fn constrain_callee(rcx: &mut Rcx,
let callee_ty = rcx.resolve_node_type(callee_id);
match callee_ty.sty {
ty::ty_bare_fn(..) => { }
ty::ty_closure(ref closure_ty) => {
let region = match closure_ty.store {
ty::RegionTraitStore(r, _) => {
// While we're here, link the closure's region with a unique
// immutable borrow (gathered later in borrowck)
let mc = mc::MemCategorizationContext::new(rcx.fcx);
let expr_cmt = ignore_err!(mc.cat_expr(callee_expr));
link_region(rcx, callee_expr.span, call_region,
ty::UniqueImmBorrow, expr_cmt);
r
}
ty::UniqTraitStore => ty::ReStatic
};
rcx.fcx.mk_subr(infer::InvokeClosure(callee_expr.span),
call_region, region);
let region = closure_ty.bounds.region_bound;
rcx.fcx.mk_subr(infer::InvokeClosure(callee_expr.span),
call_region, region);
}
_ => {
// this should not happen, but it does if the program is
// erroneous

View File

@ -67,10 +67,6 @@ fn accumulate_from_ty(&mut self, ty: Ty<'tcx>) {
// No borrowed content reachable here.
}
ty::ty_closure(box ref c) => {
self.accumulate_from_closure_ty(ty, c);
}
ty::ty_unboxed_closure(_, region, _) => {
// An "unboxed closure type" is basically
// modeled here as equivalent to a struct like

View File

@ -122,7 +122,6 @@ fn check_closure(&mut self,
_body: &ast::Block)
{
let is_old_skool_closure = match self.fcx.expr_ty(expr).sty {
ty::ty_closure(..) => true,
_ => false,
};

View File

@ -22,7 +22,7 @@
use middle::ty::RegionEscape;
use middle::ty::{ImplContainer, ImplOrTraitItemId, MethodTraitItemId};
use middle::ty::{ParameterEnvironment, TypeTraitItemId, lookup_item_type};
use middle::ty::{Ty, ty_bool, ty_char, ty_closure, ty_enum, ty_err};
use middle::ty::{Ty, ty_bool, ty_char, ty_enum, ty_err};
use middle::ty::{ty_param, TypeScheme, ty_ptr};
use middle::ty::{ty_rptr, ty_struct, ty_trait, ty_tup};
use middle::ty::{ty_str, ty_vec, ty_float, ty_infer, ty_int, ty_open};
@ -69,7 +69,7 @@ fn get_base_type_def_id<'a, 'tcx>(inference_context: &InferCtxt<'a, 'tcx>,
}
ty_bool | ty_char | ty_int(..) | ty_uint(..) | ty_float(..) |
ty_str(..) | ty_vec(..) | ty_bare_fn(..) | ty_closure(..) | ty_tup(..) |
ty_str(..) | ty_vec(..) | ty_bare_fn(..) | ty_tup(..) |
ty_param(..) | ty_err | ty_open(..) | ty_uniq(_) |
ty_ptr(_) | ty_rptr(_, _) | ty_projection(..) => {
None

View File

@ -831,20 +831,7 @@ fn add_constraints_from_ty(&mut self,
}
}
ty::ty_bare_fn(_, &ty::BareFnTy { ref sig, .. }) |
ty::ty_closure(box ty::ClosureTy {
ref sig,
store: ty::UniqTraitStore,
..
}) =>
{
self.add_constraints_from_sig(generics, sig, variance);
}
ty::ty_closure(box ty::ClosureTy { ref sig,
store: ty::RegionTraitStore(region, _), .. }) => {
let contra = self.contravariant(variance);
self.add_constraints_from_region(generics, region, contra);
ty::ty_bare_fn(_, &ty::BareFnTy { ref sig, .. }) => {
self.add_constraints_from_sig(generics, sig, variance);
}

View File

@ -1426,19 +1426,6 @@ fn clean(&self, cx: &DocContext) -> Type {
decl: (ast_util::local_def(0), &fty.sig).clean(cx),
abi: fty.abi.to_string(),
}),
ty::ty_closure(ref fty) => {
let decl = box ClosureDecl {
lifetimes: Vec::new(), // FIXME: this looks wrong...
decl: (ast_util::local_def(0), &fty.sig).clean(cx),
onceness: fty.onceness,
unsafety: fty.unsafety,
bounds: fty.bounds.clean(cx),
};
match fty.store {
ty::UniqTraitStore => Proc(decl),
ty::RegionTraitStore(..) => Closure(decl),
}
}
ty::ty_struct(did, substs) |
ty::ty_enum(did, substs) => {
let fqn = csearch::get_item_path(cx.tcx(), did);