]> git.lizzy.rs Git - rust.git/commitdiff
remove ty_closure
authorJorge Aparicio <japaricious@gmail.com>
Sun, 4 Jan 2015 14:50:17 +0000 (09:50 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Mon, 5 Jan 2015 22:22:15 +0000 (17:22 -0500)
32 files changed:
src/librustc/lint/builtin.rs
src/librustc/metadata/tyencode.rs
src/librustc/middle/effect.rs
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/fast_reject.rs
src/librustc/middle/infer/coercion.rs
src/librustc/middle/infer/combine.rs
src/librustc/middle/infer/freshen.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/traits/coherence.rs
src/librustc/middle/traits/select.rs
src/librustc/middle/ty.rs
src/librustc/middle/ty_fold.rs
src/librustc/middle/ty_walk.rs
src/librustc/util/ppaux.rs
src/librustc_borrowck/borrowck/mod.rs
src/librustc_trans/trans/adt.rs
src/librustc_trans/trans/base.rs
src/librustc_trans/trans/callee.rs
src/librustc_trans/trans/closure.rs
src/librustc_trans/trans/debuginfo.rs
src/librustc_trans/trans/glue.rs
src/librustc_trans/trans/type_of.rs
src/librustc_typeck/check/callee.rs
src/librustc_typeck/check/closure.rs
src/librustc_typeck/check/method/confirm.rs
src/librustc_typeck/check/regionck.rs
src/librustc_typeck/check/regionmanip.rs
src/librustc_typeck/check/upvar.rs
src/librustc_typeck/coherence/mod.rs
src/librustc_typeck/variance.rs
src/librustdoc/clean/mod.rs

index 269aa8fda13266f58badd0e2ab2f7d8c4d418791..6666a21c31feebb5e874e4ec3d5d84651ce97aa5 100644 (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;
                 }
 
index 5f0f51ce9033d3b4f9a5ecfda313839e0dfa9423..0042209aced6ad4e17d1392c72e374e9d35f8f34 100644 (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));
index 1075263e7512de7b34eb77aa71a339f01a24f5ef..f7eea6e5cb7c9cc45da7be1b13ae6c291afd87a2 100644 (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,
     }
 }
index 5b786ec99224723bb254790390f25dd904ee096b..ed5e8e31b7bb59ec6c3e934c3ee2e665bb2f4ca2 100644 (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 =
index d42817bce9302a911584a95118aaf5905862bc69..42bc70b5b561fd12b57db8ffd50ea559f078fd16 100644 (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()))
         }
index f6f62e035900e0ea9ae06a4a3fbbfa962e539a10..12f34a9ae54e658d90f5f3e7e1ab7e53e2fe185c 100644 (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));
index 29507058761154952096e908b058d2d19de6a4e2..dd711fcbf022eed6d76a7d49e45db83b026d6795 100644 (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))
index 7488a72b4e4609382b3c9cb262d6090d7928b883..608ae31475327e4b3430336fef69183f1e1b1583 100644 (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(..) |
index 31c3ca4199febfa27dea50422c9caa64d6a00405..f5ab4e80945ad9b65743268ecb77033a4d47248c 100644 (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);
index e6805cddae05aab1c9a26432c422ada8424a194d..55abe895183f1ba69b195846fca35bea20f51850 100644 (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(..) |
index f499cf61301aa9be5d96fc5570e7434aff99b44e..2393b7d733d0000ae9c1e001a801eaf0fc67f1fb 100644 (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 => {
index 5834844382207bbce35f7f99d397b23fdf350e17..31916848f5dc8b0a631e87631972e2d161d6b6a1 100644 (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);
index 6fc5919669402adf23b69eb406c28f398514d508..1bc0d70945899eacea45d77c05ff91fc5103546c 100644 (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))
index 6070a4208f663709a3d0d3ae03eafea13cd1edea..4953e9a2ce1d16eee8b4003fdd388945c84078fa 100644 (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);
-            }
         }
     }
 
index 9639af5ca1cd53ec49789ac81ed9f31d5fd64d6e..e6ee16d1789c00fbd401f20ab5fd472b52e34e5c 100644 (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)
         }
index 75545634b40cf689a72597e9d339ba37e6bdadf0..e1f0c9ec26677abef3eb817672c78b396bfc8686 100644 (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",
index 223df5d3a57855dc6e366e875515e4b442b452a7..01b47b728b6ba7410f71e9723ae463c3024579d6 100644 (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);
index 9814a4ed183a81b20affe508c22b4ca191fb74d1..56c1e2ddba0b58f2b9350c411ac15aabab22ae40 100644 (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());
index b0fc9fef2fd1175d6bdee986d910aa6d88d92f65..8048d0218df2d5d375328464514a556b85034b5f 100644 (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")
     };
 
index 7b394cef192eb99479ac7944a0bb52496cb3abef..cb0d2f3edd4d69f6afa49028b984894739335d02 100644 (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 {}",
index 916fcbfe13ef77df022583d3acf82788b4ee20ee..84ae088f5beae449280971476cf4ec4225dd2ab2 100644 (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");
         }
index 116ce2bf51dbeb19ddebf290c7b216524b2bfd93..491c6a83ca9bf39fb4296f907fdb4838fac8ead0 100644 (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
index fbbf2ac80d51e278fca7df3504fe0d16417188f6..3e499ea8498fbad9355e18cf6204370fb9db8573 100644 (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);
index 153c6463fbebb84c0601638e672c3c08f0dbb01d..98a826355a73ac8e78719c637f9853b7e9674703 100644 (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
         }
         _ => {
index db84f1dce975110459fe775e623f1f7c19b17c71..1368b3325a57f50b38909f7f8839d184706dd3c6 100644 (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 {
index 54d2378256d3a7fef70a78cdcc7456fe4e0f6eec..adea5084aab2b54383b13b08b62248110f3e46ab 100644 (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,
         };
 
index b5ddb528c2f2f405589c33c16207c3a9ead7c722..2adbd1f0a3f7f5dd92e17c489c7b789ac5dbd692 100644 (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
index 66cf077d4c21fbc9925cbc33b1b4d3233775d3f1..e73fa195b04484b6c49ba4ce4ba89e8e9a3115a2 100644 (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
index 1fdb68854c01fd4a7b76ba3284e61ff6f8d277b6..92fda96595c7bab805f73eee53d20fe823e70cad 100644 (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,
         };
 
index bb2c6221e2162b179294db022c207a96ca537d4c..09ab98745bd6a59a1d1573ca603a6a1508badabd 100644 (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
index 6bef7e713af28b2bd0df4bad7ea94143580c8954..e58c2275fcd96448c9836330cfe2bad49df4120f 100644 (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);
             }
 
index 5f6c62f1d7a68fc4321a5b6212012f2cb7f7ae37..e2ca4b1ecdbc7e9215447cc6bfbe2508fb2494c1 100644 (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);