From 5f7f2c9a0592bc1627781767ec8228aaad3e5364 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 4 Jan 2015 09:50:17 -0500 Subject: [PATCH] remove ty_closure --- src/librustc/lint/builtin.rs | 6 +- src/librustc/metadata/tyencode.rs | 4 -- src/librustc/middle/effect.rs | 1 - src/librustc/middle/expr_use_visitor.rs | 13 ---- src/librustc/middle/fast_reject.rs | 3 - src/librustc/middle/infer/coercion.rs | 24 -------- src/librustc/middle/infer/combine.rs | 6 -- src/librustc/middle/infer/freshen.rs | 1 - src/librustc/middle/mem_categorization.rs | 29 +-------- src/librustc/middle/traits/coherence.rs | 1 - src/librustc/middle/traits/select.rs | 56 ----------------- src/librustc/middle/ty.rs | 51 +--------------- src/librustc/middle/ty_fold.rs | 3 - src/librustc/middle/ty_walk.rs | 3 - src/librustc/util/ppaux.rs | 5 +- src/librustc_borrowck/borrowck/mod.rs | 7 --- src/librustc_trans/trans/adt.rs | 6 -- src/librustc_trans/trans/base.rs | 7 --- src/librustc_trans/trans/callee.rs | 9 --- src/librustc_trans/trans/closure.rs | 1 - src/librustc_trans/trans/debuginfo.rs | 68 --------------------- src/librustc_trans/trans/glue.rs | 12 ---- src/librustc_trans/trans/type_of.rs | 12 ---- src/librustc_typeck/check/callee.rs | 5 +- src/librustc_typeck/check/closure.rs | 1 - src/librustc_typeck/check/method/confirm.rs | 1 - src/librustc_typeck/check/regionck.rs | 48 --------------- src/librustc_typeck/check/regionmanip.rs | 4 -- src/librustc_typeck/check/upvar.rs | 1 - src/librustc_typeck/coherence/mod.rs | 4 +- src/librustc_typeck/variance.rs | 15 +---- src/librustdoc/clean/mod.rs | 13 ---- 32 files changed, 11 insertions(+), 409 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 269aa8fda13..6666a21c31f 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -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; } diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index 5f0f51ce903..0042209aced 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -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)); diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index 1075263e751..f7eea6e5cb7 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -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, } } diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 5b786ec9922..ed5e8e31b7b 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -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 = diff --git a/src/librustc/middle/fast_reject.rs b/src/librustc/middle/fast_reject.rs index d42817bce93..42bc70b5b56 100644 --- a/src/librustc/middle/fast_reject.rs +++ b/src/librustc/middle/fast_reject.rs @@ -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())) } diff --git a/src/librustc/middle/infer/coercion.rs b/src/librustc/middle/infer/coercion.rs index f6f62e03590..12f34a9ae54 100644 --- a/src/librustc/middle/infer/coercion.rs +++ b/src/librustc/middle/infer/coercion.rs @@ -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)); diff --git a/src/librustc/middle/infer/combine.rs b/src/librustc/middle/infer/combine.rs index 29507058761..dd711fcbf02 100644 --- a/src/librustc/middle/infer/combine.rs +++ b/src/librustc/middle/infer/combine.rs @@ -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)) diff --git a/src/librustc/middle/infer/freshen.rs b/src/librustc/middle/infer/freshen.rs index 7488a72b4e4..608ae314753 100644 --- a/src/librustc/middle/infer/freshen.rs +++ b/src/librustc/middle/infer/freshen.rs @@ -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(..) | diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 31c3ca4199f..f5ab4e80945 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -197,8 +197,7 @@ pub enum deref_kind { // pointer adjustment). pub fn deref_kind(t: Ty) -> McResult { 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 { 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); diff --git a/src/librustc/middle/traits/coherence.rs b/src/librustc/middle/traits/coherence.rs index e6805cddae0..55abe895183 100644 --- a/src/librustc/middle/traits/coherence.rs +++ b/src/librustc/middle/traits/coherence.rs @@ -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(..) | diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index f499cf61301..2393b7d733d 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -1273,62 +1273,6 @@ fn builtin_bound(&mut self, } } - ty::ty_closure(ref c) => { - match c.store { - ty::UniqTraitStore => { - // proc: Equivalent to `Box` - 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 => { diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 58348443822..31916848f5d 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -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, &'tcx BareFnTy<'tcx>), - ty_closure(Box>), ty_trait(Box>), 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, 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_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); diff --git a/src/librustc/middle/ty_fold.rs b/src/librustc/middle/ty_fold.rs index 6fc59196694..1bc0d709458 100644 --- a/src/librustc/middle/ty_fold.rs +++ b/src/librustc/middle/ty_fold.rs @@ -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)) diff --git a/src/librustc/middle/ty_walk.rs b/src/librustc/middle/ty_walk.rs index 6070a4208f6..4953e9a2ce1 100644 --- a/src/librustc/middle/ty_walk.rs +++ b/src/librustc/middle/ty_walk.rs @@ -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); - } } } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 9639af5ca1c..e6ee16d1789 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -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) } diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 75545634b40..e1f0c9ec266 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -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", diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/trans/adt.rs index 223df5d3a57..01b47b728b6 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -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); diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 9814a4ed183..56c1e2ddba0 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -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()); diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/trans/callee.rs index b0fc9fef2fd..8048d0218df 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/trans/callee.rs @@ -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") }; diff --git a/src/librustc_trans/trans/closure.rs b/src/librustc_trans/trans/closure.rs index 7b394cef192..cb0d2f3edd4 100644 --- a/src/librustc_trans/trans/closure.rs +++ b/src/librustc_trans/trans/closure.rs @@ -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 {}", diff --git a/src/librustc_trans/trans/debuginfo.rs b/src/librustc_trans/trans/debuginfo.rs index 916fcbfe13e..84ae088f5be 100644 --- a/src/librustc_trans/trans/debuginfo.rs +++ b/src/librustc_trans/trans/debuginfo.rs @@ -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 ¶meter_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"); } diff --git a/src/librustc_trans/trans/glue.rs b/src/librustc_trans/trans/glue.rs index 116ce2bf51d..491c6a83ca9 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/trans/glue.rs @@ -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(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); diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 153c6463fbe..98a826355a7 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -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 } _ => { diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index db84f1dce97..1368b3325a5 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -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 { diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 54d2378256d..adea5084aab 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -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, }; diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index b5ddb528c2f..2adbd1f0a3f 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -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 diff --git a/src/librustc_typeck/check/regionmanip.rs b/src/librustc_typeck/check/regionmanip.rs index 66cf077d4c2..e73fa195b04 100644 --- a/src/librustc_typeck/check/regionmanip.rs +++ b/src/librustc_typeck/check/regionmanip.rs @@ -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 diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index 1fdb68854c0..92fda96595c 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -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, }; diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index bb2c6221e21..09ab98745bd 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -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 diff --git a/src/librustc_typeck/variance.rs b/src/librustc_typeck/variance.rs index 6bef7e713af..e58c2275fcd 100644 --- a/src/librustc_typeck/variance.rs +++ b/src/librustc_typeck/variance.rs @@ -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); } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 5f6c62f1d7a..e2ca4b1ecdb 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -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);