]> git.lizzy.rs Git - rust.git/commitdiff
Remove `proc` types/expressions from the parser, compiler, and
authorNiko Matsakis <niko@alum.mit.edu>
Wed, 26 Nov 2014 15:07:22 +0000 (10:07 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Sun, 14 Dec 2014 09:21:56 +0000 (04:21 -0500)
language. Recommend `move||` instead.

33 files changed:
src/libcore/raw.rs
src/librustc/middle/cfg/construct.rs
src/librustc/middle/check_loop.rs
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/infer/error_reporting.rs
src/librustc/middle/infer/mod.rs
src/librustc/middle/liveness.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/resolve.rs
src/librustc/middle/resolve_lifetime.rs
src/librustc/middle/traits/select.rs
src/librustc/middle/ty.rs
src/librustc/util/ppaux.rs
src/librustc_back/svh.rs
src/librustc_borrowck/borrowck/mod.rs
src/librustc_trans/trans/base.rs
src/librustc_trans/trans/debuginfo.rs
src/librustc_trans/trans/expr.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/closure.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/regionck.rs
src/librustc_typeck/check/writeback.rs
src/libsyntax/ast.rs
src/libsyntax/ast_map/blocks.rs
src/libsyntax/ast_map/mod.rs
src/libsyntax/ext/expand.rs
src/libsyntax/feature_gate.rs
src/libsyntax/fold.rs
src/libsyntax/parse/obsolete.rs
src/libsyntax/parse/parser.rs
src/libsyntax/print/pprust.rs
src/libsyntax/visit.rs

index db1be94b2b83feb53c684e4c367d9347a359af37..be2f4e590a3590d61b81905c2db64352ab6ec089 100644 (file)
@@ -40,15 +40,6 @@ pub struct Closure {
 
 impl Copy for Closure {}
 
-/// The representation of a Rust procedure (`proc()`)
-#[repr(C)]
-pub struct Procedure {
-    pub code: *mut (),
-    pub env: *mut (),
-}
-
-impl Copy for Procedure {}
-
 /// The representation of a Rust trait object.
 ///
 /// This struct does not have a `Repr` implementation
index 0dcb78f6bb04c3e7100deb322a1993f403a67a99..b6347278bffda63db464be532e936ee8bd1e2ffd 100644 (file)
@@ -498,7 +498,6 @@ fn expr(&mut self, expr: &ast::Expr, pred: CFGIndex) -> CFGIndex {
 
             ast::ExprMac(..) |
             ast::ExprClosure(..) |
-            ast::ExprProc(..) |
             ast::ExprLit(..) |
             ast::ExprPath(..) => {
                 self.straightline(expr, pred, None::<ast::Expr>.iter())
index fee2d810fcb3dace18ad10917f3ddee04d83809d..c4ad089d76e6e84384c7ed1b96e62ff627d98bfc 100644 (file)
@@ -52,8 +52,7 @@ fn visit_expr(&mut self, e: &ast::Expr) {
                 self.visit_expr(&**e);
                 self.with_context(Loop, |v| v.visit_block(&**b));
             }
-            ast::ExprClosure(_, _, _, ref b) |
-            ast::ExprProc(_, ref b) => {
+            ast::ExprClosure(_, _, _, ref b) => {
                 self.with_context(Closure, |v| v.visit_block(&**b));
             }
             ast::ExprBreak(_) => self.require_loop("break", e.span),
index 8e00c96535b1e2c79a54db5491c85753f4ddcde0..6501d8d6eb4306db79a4049a22e9c2a73966a49c 100644 (file)
@@ -613,8 +613,7 @@ pub fn walk_expr(&mut self, expr: &ast::Expr) {
                 self.consume_expr(&**count);
             }
 
-            ast::ExprClosure(..) |
-            ast::ExprProc(..) => {
+            ast::ExprClosure(..) => {
                 self.walk_captures(expr)
             }
 
index e2a57629d7eb9c39befcc1ef2f1cadf776958066..0c346519672d84d3e2017e4468d14fc31ef40171 100644 (file)
@@ -587,19 +587,6 @@ fn report_concrete_failure(&self,
                     sub,
                     "");
             }
-            infer::ProcCapture(span, id) => {
-                self.tcx.sess.span_err(
-                    span,
-                    format!("captured variable `{}` must be 'static \
-                             to be captured in a proc",
-                            ty::local_var_name_str(self.tcx, id).get())
-                        .as_slice());
-                note_and_explain_region(
-                    self.tcx,
-                    "captured variable is only valid for ",
-                    sup,
-                    "");
-            }
             infer::IndexSlice(span) => {
                 self.tcx.sess.span_err(span,
                                        "index of slice outside its lifetime");
@@ -625,28 +612,6 @@ fn report_concrete_failure(&self,
                     sup,
                     "");
             }
-            infer::RelateProcBound(span, var_node_id, ty) => {
-                self.tcx.sess.span_err(
-                    span,
-                    format!(
-                        "the type `{}` of captured variable `{}` \
-                         outlives the `proc()` it \
-                         is captured in",
-                        self.ty_to_string(ty),
-                        ty::local_var_name_str(self.tcx,
-                                               var_node_id)).as_slice());
-                note_and_explain_region(
-                    self.tcx,
-                    "`proc()` is valid for ",
-                    sub,
-                    "");
-                note_and_explain_region(
-                    self.tcx,
-                    format!("the type `{}` is only valid for ",
-                            self.ty_to_string(ty)).as_slice(),
-                    sup,
-                    "");
-            }
             infer::RelateParamBound(span, ty) => {
                 self.tcx.sess.span_err(
                     span,
@@ -1587,15 +1552,6 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
                                 self.tcx,
                                 id).get().to_string()).as_slice());
             }
-            infer::ProcCapture(span, id) => {
-                self.tcx.sess.span_note(
-                    span,
-                    format!("...so that captured variable `{}` \
-                            is 'static",
-                            ty::local_var_name_str(
-                                self.tcx,
-                                id).get()).as_slice());
-            }
             infer::IndexSlice(span) => {
                 self.tcx.sess.span_note(
                     span,
@@ -1606,15 +1562,6 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
                     span,
                     "...so that it can be closed over into an object");
             }
-            infer::RelateProcBound(span, var_node_id, _ty) => {
-                self.tcx.sess.span_note(
-                    span,
-                    format!(
-                        "...so that the variable `{}` can be captured \
-                         into a proc",
-                        ty::local_var_name_str(self.tcx,
-                                               var_node_id)).as_slice());
-            }
             infer::CallRcvr(span) => {
                 self.tcx.sess.span_note(
                     span,
index 4c3b7589d76cbb59cc4c65e1005ea6954458f419..2b1d8776365ecfb9ae4a0a43055a20db66a1a19b 100644 (file)
@@ -175,9 +175,6 @@ pub enum SubregionOrigin<'tcx> {
     // Closure bound must not outlive captured free variables
     FreeVariable(Span, ast::NodeId),
 
-    // Proc upvars must be 'static
-    ProcCapture(Span, ast::NodeId),
-
     // Index into slice must be within its lifetime
     IndexSlice(Span),
 
@@ -185,10 +182,6 @@ pub enum SubregionOrigin<'tcx> {
     // relating `'a` to `'b`
     RelateObjectBound(Span),
 
-    // When closing over a variable in a closure/proc, ensure that the
-    // type of the variable outlives the lifetime bound.
-    RelateProcBound(Span, ast::NodeId, Ty<'tcx>),
-
     // Some type parameter was instantiated with the given type,
     // and that type must outlive some region.
     RelateParamBound(Span, Ty<'tcx>),
@@ -1089,10 +1082,8 @@ pub fn span(&self) -> Span {
             InvokeClosure(a) => a,
             DerefPointer(a) => a,
             FreeVariable(a, _) => a,
-            ProcCapture(a, _) => a,
             IndexSlice(a) => a,
             RelateObjectBound(a) => a,
-            RelateProcBound(a, _, _) => a,
             RelateParamBound(a, _) => a,
             RelateRegionParamBound(a) => a,
             RelateDefaultParamBound(a, _) => a,
@@ -1128,21 +1119,12 @@ fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
             FreeVariable(a, b) => {
                 format!("FreeVariable({}, {})", a.repr(tcx), b)
             }
-            ProcCapture(a, b) => {
-                format!("ProcCapture({}, {})", a.repr(tcx), b)
-            }
             IndexSlice(a) => {
                 format!("IndexSlice({})", a.repr(tcx))
             }
             RelateObjectBound(a) => {
                 format!("RelateObjectBound({})", a.repr(tcx))
             }
-            RelateProcBound(a, b, c) => {
-                format!("RelateProcBound({},{},{})",
-                        a.repr(tcx),
-                        b,
-                        c.repr(tcx))
-            }
             RelateParamBound(a, b) => {
                 format!("RelateParamBound({},{})",
                         a.repr(tcx),
index 271e903bbdf1761feff735b8715788f8e106faa5..31bcdff9cd59370705567f8a4bc8ddd994439654 100644 (file)
@@ -461,7 +461,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
         }
         visit::walk_expr(ir, expr);
       }
-      ast::ExprClosure(..) | ast::ExprProc(..) => {
+      ast::ExprClosure(..) => {
         // Interesting control flow (for loops can contain labeled
         // breaks or continues)
         ir.add_live_node_for_node(expr.id, ExprNode(expr.span));
@@ -981,9 +981,8 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
               self.propagate_through_expr(&**e, succ)
           }
 
-          ast::ExprClosure(_, _, _, ref blk) |
-          ast::ExprProc(_, ref blk) => {
-              debug!("{} is an ExprClosure or ExprProc",
+          ast::ExprClosure(_, _, _, ref blk) => {
+              debug!("{} is an ExprClosure",
                      expr_to_string(expr));
 
               /*
@@ -1502,8 +1501,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
       ast::ExprBreak(..) | ast::ExprAgain(..) | ast::ExprLit(_) |
       ast::ExprBlock(..) | ast::ExprMac(..) | ast::ExprAddrOf(..) |
       ast::ExprStruct(..) | ast::ExprRepeat(..) | ast::ExprParen(..) |
-      ast::ExprClosure(..) | ast::ExprProc(..) |
-      ast::ExprPath(..) | ast::ExprBox(..) | ast::ExprSlice(..) => {
+      ast::ExprClosure(..) | ast::ExprPath(..) | ast::ExprBox(..) | ast::ExprSlice(..) => {
         visit::walk_expr(this, expr);
       }
       ast::ExprIfLet(..) => {
index d96cf4495bdde95b0ab624606776aef7f0832531..652847a63436defe3525fd2401d39d214a645857 100644 (file)
@@ -555,8 +555,7 @@ pub fn cat_expr_unadjusted(&self, expr: &ast::Expr) -> McResult<cmt<'tcx>> {
 
           ast::ExprAddrOf(..) | ast::ExprCall(..) |
           ast::ExprAssign(..) | ast::ExprAssignOp(..) |
-          ast::ExprClosure(..) | ast::ExprProc(..) |
-          ast::ExprRet(..) |
+          ast::ExprClosure(..) | ast::ExprRet(..) |
           ast::ExprUnary(..) | ast::ExprSlice(..) |
           ast::ExprMethodCall(..) | ast::ExprCast(..) |
           ast::ExprVec(..) | ast::ExprTup(..) | ast::ExprIf(..) |
@@ -728,7 +727,6 @@ fn cat_upvar(&self,
                 };
 
                 match fn_expr.node {
-                    ast::ExprProc(_, ref body) |
                     ast::ExprClosure(_, _, _, ref body) => body.id,
                     _ => unreachable!()
                 }
index 85e0c9294a6baeb87294dc5f26a3252945dad165..9912db69a053fc92e0ae493ab3be58e1aa5ee84b 100644 (file)
@@ -51,7 +51,7 @@
 use syntax::ast::{Arm, BindByRef, BindByValue, BindingMode, Block, Crate, CrateNum};
 use syntax::ast::{DeclItem, DefId, Expr, ExprAgain, ExprBreak, ExprField};
 use syntax::ast::{ExprClosure, ExprForLoop, ExprLoop, ExprWhile, ExprMethodCall};
-use syntax::ast::{ExprPath, ExprProc, ExprStruct, FnDecl};
+use syntax::ast::{ExprPath, ExprStruct, FnDecl};
 use syntax::ast::{ForeignItem, ForeignItemFn, ForeignItemStatic, Generics};
 use syntax::ast::{Ident, ImplItem, Item, ItemEnum, ItemFn, ItemForeignMod};
 use syntax::ast::{ItemImpl, ItemMac, ItemMod, ItemStatic, ItemStruct};
@@ -64,7 +64,7 @@
 use syntax::ast::{StructVariantKind, TraitRef, TraitTyParamBound};
 use syntax::ast::{TupleVariantKind, Ty, TyBool, TyChar, TyClosure, TyF32};
 use syntax::ast::{TyF64, TyFloat, TyI, TyI8, TyI16, TyI32, TyI64, TyInt, TyObjectSum};
-use syntax::ast::{TyParam, TyParamBound, TyPath, TyPtr, TyPolyTraitRef, TyProc, TyQPath};
+use syntax::ast::{TyParam, TyParamBound, TyPath, TyPtr, TyPolyTraitRef, TyQPath};
 use syntax::ast::{TyRptr, TyStr, TyU, TyU8, TyU16, TyU32, TyU64, TyUint};
 use syntax::ast::{TypeImplItem, UnnamedField};
 use syntax::ast::{Variant, ViewItem, ViewItemExternCrate};
@@ -5027,7 +5027,7 @@ fn resolve_type(&mut self, ty: &Ty) {
                 self.resolve_trait_reference(ty.id, &*qpath.trait_ref, TraitQPath);
             }
 
-            TyClosure(ref c) | TyProc(ref c) => {
+            TyClosure(ref c) => {
                 self.resolve_type_parameter_bounds(
                     ty.id,
                     &c.bounds,
@@ -5902,13 +5902,6 @@ fn resolve_expr(&mut self, expr: &Expr) {
                                       &**block);
             }
 
-            ExprProc(ref fn_decl, ref block) => {
-                self.capture_mode_map.insert(expr.id, ast::CaptureByValue);
-                self.resolve_function(ClosureRibKind(expr.id, block.id),
-                                      Some(&**fn_decl), NoTypeParameters,
-                                      &**block);
-            }
-
             ExprStruct(ref path, _, _) => {
                 // Resolve the path to the structure it goes to. We don't
                 // check to ensure that the path is actually a structure; that
index 83332d275ce99ab19a1e27cea656c268dbbce739..ee0fc32702064c4d2df83de82b1be65043900886 100644 (file)
@@ -141,7 +141,7 @@ fn visit_fn(&mut self, fk: visit::FnKind<'v>, fd: &'v ast::FnDecl,
 
     fn visit_ty(&mut self, ty: &ast::Ty) {
         match ty.node {
-            ast::TyClosure(ref c) | ast::TyProc(ref c) => {
+            ast::TyClosure(ref c)  => {
                 // Careful, the bounds on a closure/proc are *not* within its binder.
                 visit::walk_ty_param_bounds_helper(self, &c.bounds);
                 visit::walk_lifetime_decls_helper(self, &c.lifetimes);
index 88c70f5557c14af47c3d9cd3c933958e3c512752..c3c4acd8191c08756545adc32b653f80857f27ad 100644 (file)
@@ -746,8 +746,9 @@ fn assemble_unboxed_closure_candidates(&mut self,
             _ => { return Ok(()); }
         };
 
-        debug!("assemble_unboxed_candidates: self_ty={} obligation={}",
+        debug!("assemble_unboxed_candidates: self_ty={} kind={} obligation={}",
                self_ty.repr(self.tcx()),
+               kind,
                obligation.repr(self.tcx()));
 
         let closure_kind = match self.typer.unboxed_closures().borrow().get(&closure_def_id) {
@@ -760,6 +761,8 @@ fn assemble_unboxed_closure_candidates(&mut self,
             }
         };
 
+        debug!("closure_kind = {}", closure_kind);
+
         if closure_kind == kind {
             candidates.vec.push(UnboxedClosureCandidate(closure_def_id, substs.clone()));
         }
@@ -842,14 +845,24 @@ fn winnow_candidate<'o>(&mut self,
                             candidate: &Candidate<'tcx>)
                             -> EvaluationResult<'tcx>
     {
-        debug!("winnow_candidate: candidate={}", candidate.repr(self.tcx()));
-        self.infcx.probe(|| {
+        /*!
+         * Further evaluate `candidate` to decide whether all type parameters match
+         * and whether nested obligations are met. Returns true if `candidate` remains
+         * viable after this further scrutiny.
+         */
+
+        debug!("winnow_candidate: depth={} candidate={}",
+               stack.obligation.recursion_depth, candidate.repr(self.tcx()));
+        let result = self.infcx.probe(|| {
             let candidate = (*candidate).clone();
             match self.confirm_candidate(stack.obligation, candidate) {
                 Ok(selection) => self.winnow_selection(Some(stack), selection),
                 Err(error) => EvaluatedToErr(error),
             }
-        })
+        });
+        debug!("winnow_candidate depth={} result={}",
+               stack.obligation.recursion_depth, result);
+        result
     }
 
     fn winnow_selection<'o>(&mut self,
@@ -1562,6 +1575,10 @@ fn confirm_unboxed_closure_candidate(&mut self,
             substs: substs,
         });
 
+        debug!("confirm_unboxed_closure_candidate(closure_def_id={}, trait_ref={})",
+               closure_def_id.repr(self.tcx()),
+               trait_ref.repr(self.tcx()));
+
         self.confirm(obligation.cause,
                      obligation.trait_ref.clone(),
                      trait_ref)
index 8e99045cffb5831f57978fa9123054ece46ec870..98d4761508a284ab825b67f847430dfb2f8dc06b 100644 (file)
@@ -4236,7 +4236,6 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
         ast::ExprIf(..) |
         ast::ExprMatch(..) |
         ast::ExprClosure(..) |
-        ast::ExprProc(..) |
         ast::ExprBlock(..) |
         ast::ExprRepeat(..) |
         ast::ExprVec(..) => {
index 5dbf3208595ed9434f64a625918b29165c58cc75..f8276fa8f84d4e9ecb694fd75dda055ba3b366e7 100644 (file)
@@ -449,7 +449,14 @@ fn infer_ty_to_string(cx: &ctxt, ty: ty::InferTy) -> String {
             let unboxed_closures = cx.unboxed_closures.borrow();
             unboxed_closures.get(did).map(|cl| {
                 closure_to_string(cx, &cl.closure_type.subst(cx, substs))
-            }).unwrap_or_else(|| "closure".to_string())
+            }).unwrap_or_else(|| {
+                if did.krate == ast::LOCAL_CRATE {
+                    let span = cx.map.span(did.node);
+                    format!("closure[{}]", span.repr(cx))
+                } else {
+                    format!("closure")
+                }
+            })
         }
         ty_vec(t, sz) => {
             let inner_str = ty_to_string(cx, t);
index 549d636e8cb564ac0ee977841f368e38faf2e7b9..116cff49153beecdad9be2d5c9117d5a0c77fd20 100644 (file)
@@ -242,7 +242,6 @@ pub enum SawExprComponent<'a> {
         SawExprWhile,
         SawExprMatch,
         SawExprClosure,
-        SawExprProc,
         SawExprBlock,
         SawExprAssign,
         SawExprAssignOp(ast::BinOp),
@@ -274,7 +273,6 @@ fn saw_expr<'a>(node: &'a Expr_) -> SawExprComponent<'a> {
             ExprLoop(_, id)          => SawExprLoop(id.map(content)),
             ExprMatch(..)            => SawExprMatch,
             ExprClosure(..)          => SawExprClosure,
-            ExprProc(..)             => SawExprProc,
             ExprBlock(..)            => SawExprBlock,
             ExprAssign(..)           => SawExprAssign,
             ExprAssignOp(op, _, _)   => SawExprAssignOp(op),
index 1722f9a1f75f24800c880e382e5c73a732d0de24..a3fb91aced007fc432e505b867a7c1b79664442e 100644 (file)
@@ -337,7 +337,6 @@ pub fn closure_to_block(closure_id: ast::NodeId,
                         tcx: &ty::ctxt) -> ast::NodeId {
     match tcx.map.get(closure_id) {
         ast_map::NodeExpr(expr) => match expr.node {
-            ast::ExprProc(_, ref block) |
             ast::ExprClosure(_, _, _, ref block) => {
                 block.id
             }
index 5170746404e01d0a440c57aa6258e5bc53031f7a..b2578fdbc054bb0c26241588a892ca734d423e18 100644 (file)
@@ -1396,8 +1396,7 @@ fn has_nested_returns(tcx: &ty::ctxt, id: ast::NodeId) -> bool {
         }
         Some(ast_map::NodeExpr(e)) => {
             match e.node {
-                ast::ExprClosure(_, _, _, ref blk) |
-                ast::ExprProc(_, ref blk) => {
+                ast::ExprClosure(_, _, _, ref blk) => {
                     let mut explicit = CheckForNestedReturnsVisitor::explicit();
                     let mut implicit = CheckForNestedReturnsVisitor::implicit();
                     visit::walk_expr(&mut explicit, e);
index de169fc9d62a6f2f67e92beac98b4e73b94e137c..66258f228cd7b8f2d35ef4bb46ecab1bd728ecae 100644 (file)
@@ -1239,7 +1239,6 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         }
         ast_map::NodeExpr(ref expr) => {
             match expr.node {
-                ast::ExprProc(ref fn_decl, ref top_level_block) |
                 ast::ExprClosure(_, _, ref fn_decl, ref top_level_block) => {
                     let name = format!("fn{}", token::gensym("fn"));
                     let name = token::str_to_ident(name.as_slice());
@@ -3588,7 +3587,6 @@ fn walk_expr(cx: &CrateContext,
                 })
             }
 
-            ast::ExprProc(ref decl, ref block) |
             ast::ExprClosure(_, _, ref decl, ref block) => {
                 with_new_scope(cx,
                                block.span,
index e1769001942d586950358355618d518603289fed..5b9a1d499910e62f299c170819ff507f7e544a9e 100644 (file)
@@ -1052,8 +1052,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         ast::ExprVec(..) | ast::ExprRepeat(..) => {
             tvec::trans_fixed_vstore(bcx, expr, dest)
         }
-        ast::ExprClosure(_, _, ref decl, ref body) |
-        ast::ExprProc(ref decl, ref body) => {
+        ast::ExprClosure(_, _, ref decl, ref body) => {
             // Check the side-table to see whether this is an unboxed
             // closure or an older, legacy style closure. Store this
             // into a variable to ensure the the RefCell-lock is
index 7ee627dbe14551a5883269fe709885696b65c496..4ea2a2287019db090be67526142bf7ee3fcd6ff3 100644 (file)
@@ -945,26 +945,6 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
                                             None);
                 ty::mk_closure(tcx, fn_decl)
             }
-            ast::TyProc(ref f) => {
-                // Use corresponding trait store to figure out default bounds
-                // if none were specified.
-                let bounds = conv_existential_bounds(this,
-                                                     rscope,
-                                                     ast_ty.span,
-                                                     None,
-                                                     f.bounds.as_slice());
-
-                let fn_decl = ty_of_closure(this,
-                                            f.fn_style,
-                                            f.onceness,
-                                            bounds,
-                                            ty::UniqTraitStore,
-                                            &*f.decl,
-                                            abi::Rust,
-                                            None);
-
-                ty::mk_closure(tcx, fn_decl)
-            }
             ast::TyPolyTraitRef(ref bounds) => {
                 conv_ty_poly_trait_ref(this, rscope, ast_ty.span, bounds.as_slice())
             }
@@ -1071,7 +1051,7 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
             }
             ast::TyInfer => {
                 // TyInfer also appears as the type of arguments or return
-                // values in a ExprClosure or ExprProc, or as
+                // values in a ExprClosure, or as
                 // the type of local variables. Both of these cases are
                 // handled specially and will not descend into this routine.
                 this.ty_infer(ast_ty.span)
index 4e027005931a9f089e0bc5d7d86a3c2cd22f5ae7..692bd31638e347a81f7743a9afd18a1de400a608 100644 (file)
@@ -250,12 +250,12 @@ fn deduce_unboxed_closure_expectations_from_obligations<'a,'tcx>(
 }
 
 
-pub fn check_boxed_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
-                                    expr: &ast::Expr,
-                                    store: ty::TraitStore,
-                                    decl: &ast::FnDecl,
-                                    body: &ast::Block,
-                                    expected: Expectation<'tcx>) {
+fn check_boxed_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
+                                expr: &ast::Expr,
+                                store: ty::TraitStore,
+                                decl: &ast::FnDecl,
+                                body: &ast::Block,
+                                expected: Expectation<'tcx>) {
     let tcx = fcx.ccx.tcx;
 
     // Find the expected input/output types (if any). Substitute
@@ -293,18 +293,10 @@ pub fn check_boxed_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
             }
             _ => {
                 // Not an error! Means we're inferring the closure type
-                let (bounds, onceness) = match expr.node {
-                    ast::ExprProc(..) => {
-                        let mut bounds = ty::region_existential_bound(ty::ReStatic);
-                        bounds.builtin_bounds.insert(ty::BoundSend); // FIXME
-                        (bounds, ast::Once)
-                    }
-                    _ => {
-                        let region = fcx.infcx().next_region_var(
-                            infer::AddrOfRegion(expr.span));
-                        (ty::region_existential_bound(region), ast::Many)
-                    }
-                };
+                let region = fcx.infcx().next_region_var(
+                    infer::AddrOfRegion(expr.span));
+                let bounds = ty::region_existential_bound(region);
+                let onceness = ast::Many;
                 (None, onceness, bounds)
             }
         }
index 77460bb6b269a39167aeb9dbdc37724c0697c6f2..fccd6605df713457965035e57924bde02f0c031f 100644 (file)
@@ -2122,14 +2122,6 @@ fn try_overloaded_call<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
         fcx.inh.method_map.borrow_mut().insert(method_call, method_callee);
         write_call(fcx, call_expression, output_type);
 
-        if !fcx.tcx().sess.features.borrow().unboxed_closures {
-            span_err!(fcx.tcx().sess, call_expression.span, E0056,
-                "overloaded calls are experimental");
-            span_help!(fcx.tcx().sess, call_expression.span,
-                "add `#![feature(unboxed_closures)]` to \
-                the crate attributes to enable");
-        }
-
         return true
     }
 
@@ -2666,7 +2658,7 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
         };
         for (i, arg) in args.iter().take(t).enumerate() {
             let is_block = match arg.node {
-                ast::ExprClosure(..) | ast::ExprProc(..) => true,
+                ast::ExprClosure(..) => true,
                 _ => false
             };
 
@@ -3997,14 +3989,6 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
       ast::ExprClosure(_, opt_kind, ref decl, ref body) => {
           closure::check_expr_closure(fcx, expr, opt_kind, &**decl, &**body, expected);
       }
-      ast::ExprProc(ref decl, ref body) => {
-          closure::check_boxed_closure(fcx,
-                                       expr,
-                                       ty::UniqTraitStore,
-                                       &**decl,
-                                       &**body,
-                                       expected);
-      }
       ast::ExprBlock(ref b) => {
         check_block_with_expected(fcx, &**b, expected);
         fcx.write_ty(id, fcx.node_ty(b.id));
index cadcee43b4402b845f9d85ba3c7700b379534167..9f75b9764ebd8581df6f83dc1d8da3d640eac2e7 100644 (file)
@@ -714,7 +714,6 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
             visit::walk_expr(rcx, expr);
         }
 
-        ast::ExprProc(_, ref body) |
         ast::ExprClosure(_, _, _, ref body) => {
             check_expr_fn_block(rcx, expr, &**body);
         }
@@ -936,8 +935,9 @@ fn ensure_free_variable_types_outlive_closure_bound(
                 let cause = traits::ObligationCause::new(freevar.span, rcx.fcx.body_id, code);
                 rcx.fcx.register_builtin_bound(var_ty, builtin_bound, cause);
             }
+
             type_must_outlive(
-                rcx, infer::RelateProcBound(expr.span, var_node_id, var_ty),
+                rcx, infer::FreeVariable(expr.span, var_node_id),
                 var_ty, bounds.region_bound);
         }
     }
index 48f1ef8da1d54672cc6fb4b1264f6d1aab3cbc82..8d94cf5dd5e96f1fb3e03b3d2590e81bfbf23414 100644 (file)
@@ -121,8 +121,7 @@ fn visit_expr(&mut self, e: &ast::Expr) {
                                     MethodCall::expr(e.id));
 
         match e.node {
-            ast::ExprClosure(_, _, ref decl, _) |
-            ast::ExprProc(ref decl, _) => {
+            ast::ExprClosure(_, _, ref decl, _) => {
                 for input in decl.inputs.iter() {
                     let _ = self.visit_node_id(ResolvingExpr(e.span),
                                                input.id);
index ea8de458ce2255dd059906af3fe442fb1ec6a539..ae7a2127e9f605349fd7a68c608ab1fc024c720e 100644 (file)
@@ -719,7 +719,6 @@ pub enum Expr_ {
     ExprLoop(P<Block>, Option<Ident>),
     ExprMatch(P<Expr>, Vec<Arm>, MatchSource),
     ExprClosure(CaptureClause, Option<UnboxedClosureKind>, P<FnDecl>, P<Block>),
-    ExprProc(P<FnDecl>, P<Block>),
     ExprBlock(P<Block>),
 
     ExprAssign(P<Expr>, P<Expr>),
@@ -1225,8 +1224,6 @@ pub enum Ty_ {
     TyRptr(Option<Lifetime>, MutTy),
     /// A closure (e.g. `|uint| -> bool`)
     TyClosure(P<ClosureTy>),
-    /// A procedure (e.g `proc(uint) -> bool`)
-    TyProc(P<ClosureTy>),
     /// A bare function (e.g. `fn(uint) -> bool`)
     TyBareFn(P<BareFnTy>),
     /// A tuple (`(A, B, C, D,...)`)
index 75f69f2f6d062a093134fbee3322749bc781bfc3..5462918b662831f3dd60b93b4cb83b7bd3f25a6a 100644 (file)
@@ -37,7 +37,7 @@
 ///
 /// More specifically, it is one of either:
 ///   - A function item,
-///   - A closure expr (i.e. an ExprClosure or ExprProc), or
+///   - A closure expr (i.e. an ExprClosure), or
 ///   - The default implementation for a trait method.
 ///
 /// To construct one, use the `Code::from_node` function.
@@ -73,7 +73,7 @@ fn is_fn_like(&self) -> bool {
 impl MaybeFnLike for ast::Expr {
     fn is_fn_like(&self) -> bool {
         match self.node {
-            ast::ExprClosure(..) | ast::ExprProc(..) => true,
+            ast::ExprClosure(..) => true,
             _ => false,
         }
     }
@@ -222,8 +222,6 @@ fn handle<A, I, M, C>(self, item_fn: I, method: M, closure: C) -> A where
             ast_map::NodeExpr(e) => match e.node {
                 ast::ExprClosure(_, _, ref decl, ref block) =>
                     closure(ClosureParts::new(&**decl, &**block, e.id, e.span)),
-                ast::ExprProc(ref decl, ref block) =>
-                    closure(ClosureParts::new(&**decl, &**block, e.id, e.span)),
                 _ => panic!("expr FnLikeNode that is not fn-like"),
             },
             _ => panic!("other FnLikeNode that is not fn-like"),
index 907ac6b19fc0dced1053f4383fdda45b7d0c4f3c..6f1d2d39b30493df204cf7ea185292f60586c3fc 100644 (file)
@@ -859,7 +859,7 @@ fn visit_fn(&mut self, fk: visit::FnKind<'ast>, fd: &'ast FnDecl,
 
     fn visit_ty(&mut self, ty: &'ast Ty) {
         match ty.node {
-            TyClosure(ref fd) | TyProc(ref fd) => {
+            TyClosure(ref fd) => {
                 self.visit_fn_decl(&*fd.decl);
             }
             TyBareFn(ref fd) => {
index 9c4e85f16ff8570c42527480c3610507dab21ac6..1a004ca7c44cc6c2d352e6dcdce1d048e38597b3 100644 (file)
@@ -217,13 +217,6 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
             P(ast::Expr{id:id, node: new_node, span: fld.new_span(span)})
         }
 
-        ast::ExprProc(fn_decl, block) => {
-            let (rewritten_fn_decl, rewritten_block)
-                = expand_and_rename_fn_decl_and_block(fn_decl, block, fld);
-            let new_node = ast::ExprProc(rewritten_fn_decl, rewritten_block);
-            P(ast::Expr{id:id, node: new_node, span: fld.new_span(span)})
-        }
-
         _ => {
             P(noop_fold_expr(ast::Expr {
                 id: id,
@@ -1576,17 +1569,6 @@ macro_rules! add_method (($T:ty) =>
             0)
     }
 
-    // closure arg hygiene (ExprProc)
-    // expands to fn f(){(proc(x_1 : int) {(x_2 + x_1)})(3);}
-    #[test] fn closure_arg_hygiene_2(){
-        run_renaming_test(
-            &("macro_rules! inject_x (()=>(x))
-              fn f(){ (proc(x : int){(inject_x!() + x)})(3); }",
-              vec!(vec!(1)),
-              true),
-            0)
-    }
-
     // macro_rules in method position. Sadly, unimplemented.
     #[test] fn macro_in_method_posn(){
         expand_crate_str(
index 2ee4957ec0fa08af83575114ea47b49cdf96af63..66fe672c3e5e82e7b97e0d6ad636ca346513fa91 100644 (file)
@@ -306,12 +306,6 @@ fn visit_ty(&mut self, t: &ast::Ty) {
 
     fn visit_expr(&mut self, e: &ast::Expr) {
         match e.node {
-            ast::ExprClosure(_, Some(_), _, _) => {
-                self.gate_feature("unboxed_closures",
-                                  e.span,
-                                  "unboxed closures are a work-in-progress \
-                                   feature with known bugs");
-            }
             ast::ExprSlice(..) => {
                 self.gate_feature("slicing_syntax",
                                   e.span,
index 0318dd5b0cd2d218e3091233cc6cc55384a57496..611faa2c2c9091da6bb4d0ecb9643867a4a7f3da 100644 (file)
@@ -425,17 +425,6 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
                     }
                 }))
             }
-            TyProc(f) => {
-                TyProc(f.map(|ClosureTy {fn_style, onceness, bounds, decl, lifetimes}| {
-                    ClosureTy {
-                        fn_style: fn_style,
-                        onceness: onceness,
-                        bounds: fld.fold_bounds(bounds),
-                        decl: fld.fold_fn_decl(decl),
-                        lifetimes: fld.fold_lifetime_defs(lifetimes)
-                    }
-                }))
-            }
             TyBareFn(f) => {
                 TyBareFn(f.map(|BareFnTy {lifetimes, fn_style, abi, decl}| BareFnTy {
                     lifetimes: fld.fold_lifetime_defs(lifetimes),
@@ -1360,10 +1349,6 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
                         arms.move_map(|x| folder.fold_arm(x)),
                         source)
             }
-            ExprProc(decl, body) => {
-                ExprProc(folder.fold_fn_decl(decl),
-                         folder.fold_block(body))
-            }
             ExprClosure(capture_clause, opt_kind, decl, body) => {
                 ExprClosure(capture_clause,
                             opt_kind,
index 2a2bb42cef012de88234cdcc487b8f74b44f45f1..3a7cc77515dbefc8d86394de73a3cfbf8c2aa8c7 100644 (file)
@@ -32,6 +32,8 @@ pub enum ObsoleteSyntax {
     ObsoleteImportRenaming,
     ObsoleteSubsliceMatch,
     ObsoleteExternCrateRenaming,
+    ObsoleteProcType,
+    ObsoleteProcExpr,
 }
 
 impl Copy for ObsoleteSyntax {}
@@ -55,6 +57,14 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
     /// Reports an obsolete syntax non-fatal error.
     fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
         let (kind_str, desc) = match kind {
+            ObsoleteProcType => (
+                "the `proc` type",
+                "use unboxed closures instead",
+            ),
+            ObsoleteProcExpr => (
+                "`proc` expression",
+                "use a `move ||` expression instead",
+            ),
             ObsoleteOwnedType => (
                 "`~` notation for owned pointers",
                 "use `Box<T>` in `std::owned` instead"
index e9cc91d94151a2f231a252ea3c856dbdba1b1b02..381942a3e622f6eb2ec2329f4d2391cc28743620 100644 (file)
 use ast::{ExprBreak, ExprCall, ExprCast};
 use ast::{ExprField, ExprTupField, ExprClosure, ExprIf, ExprIfLet, ExprIndex, ExprSlice};
 use ast::{ExprLit, ExprLoop, ExprMac};
-use ast::{ExprMethodCall, ExprParen, ExprPath, ExprProc};
+use ast::{ExprMethodCall, ExprParen, ExprPath};
 use ast::{ExprRepeat, ExprRet, ExprStruct, ExprTup, ExprUnary};
 use ast::{ExprVec, ExprWhile, ExprWhileLet, ExprForLoop, Field, FnDecl};
-use ast::{Once, Many};
+use ast::{Many};
 use ast::{FnUnboxedClosureKind, FnMutUnboxedClosureKind};
 use ast::{FnOnceUnboxedClosureKind};
 use ast::{ForeignItem, ForeignItemStatic, ForeignItemFn, ForeignMod, FunctionRetTy};
@@ -54,7 +54,7 @@
 use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef};
 use ast::{TtDelimited, TtSequence, TtToken};
 use ast::{TupleVariantKind, Ty, Ty_, TypeBinding};
-use ast::{TypeField, TyFixedLengthVec, TyClosure, TyProc, TyBareFn};
+use ast::{TypeField, TyFixedLengthVec, TyClosure, TyBareFn};
 use ast::{TyTypeof, TyInfer, TypeMethod};
 use ast::{TyParam, TyParamBound, TyParen, TyPath, TyPolyTraitRef, TyPtr, TyQPath};
 use ast::{TyRptr, TyTup, TyU32, TyVec, UnUniq};
@@ -1064,7 +1064,6 @@ pub fn parse_for_in_type(&mut self) -> Ty_ {
         Deprecated:
 
         - for <'lt> |S| -> T
-        - for <'lt> proc(S) -> T
 
         Eventually:
 
@@ -1158,26 +1157,21 @@ pub fn parse_proc_type(&mut self, lifetime_defs: Vec<ast::LifetimeDef>) -> Ty_ {
          |     |    |    Bounds
          |     |  Argument types
          |   Legacy lifetimes
-        the `proc` keyword
+        the `proc` keyword (already consumed)
 
         */
 
-        let lifetime_defs = self.parse_legacy_lifetime_defs(lifetime_defs);
-        let (inputs, variadic) = self.parse_fn_args(false, false);
-        let bounds = self.parse_colon_then_ty_param_bounds();
-        let ret_ty = self.parse_ret_ty();
-        let decl = P(FnDecl {
-            inputs: inputs,
-            output: ret_ty,
-            variadic: variadic
-        });
-        TyProc(P(ClosureTy {
-            fn_style: NormalFn,
-            onceness: Once,
-            bounds: bounds,
-            decl: decl,
-            lifetimes: lifetime_defs,
-        }))
+        let proc_span = self.last_span;
+
+        // To be helpful, parse the proc as ever
+        let _ = self.parse_legacy_lifetime_defs(lifetime_defs);
+        let _ = self.parse_fn_args(false, false);
+        let _ = self.parse_colon_then_ty_param_bounds();
+        let _ = self.parse_ret_ty();
+
+        self.obsolete(proc_span, ObsoleteProcType);
+
+        TyInfer
     }
 
     /// Parses an optional unboxed closure kind (`&:`, `&mut:`, or `:`).
@@ -2294,17 +2288,10 @@ pub fn parse_bottom_expr(&mut self) -> P<Expr> {
                     return self.parse_lambda_expr(CaptureByValue);
                 }
                 if self.eat_keyword(keywords::Proc) {
-                    let decl = self.parse_proc_decl();
-                    let body = self.parse_expr();
-                    let fakeblock = P(ast::Block {
-                            id: ast::DUMMY_NODE_ID,
-                            view_items: Vec::new(),
-                            stmts: Vec::new(),
-                            rules: DefaultBlock,
-                            span: body.span,
-                            expr: Some(body),
-                        });
-                    return self.mk_expr(lo, fakeblock.span.hi, ExprProc(decl, fakeblock));
+                    let span = self.last_span;
+                    let _ = self.parse_proc_decl();
+                    let _ = self.parse_expr();
+                    return self.obsolete_expr(span, ObsoleteProcExpr);
                 }
                 if self.eat_keyword(keywords::If) {
                     return self.parse_if_expr();
index 6d8b8dcb8ba5d0e442f07233e50af5e07a9f5b12..87905db22f349b857ded5af646c21d70cf2d0187 100644 (file)
@@ -450,7 +450,7 @@ pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> String {
 fn needs_parentheses(expr: &ast::Expr) -> bool {
     match expr.node {
         ast::ExprAssign(..) | ast::ExprBinary(..) |
-        ast::ExprClosure(..) | ast::ExprProc(..) |
+        ast::ExprClosure(..) |
         ast::ExprAssignOp(..) | ast::ExprCast(..) => true,
         _ => false,
     }
@@ -734,25 +734,6 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> IoResult<()> {
                                       Some(&generics),
                                       None));
             }
-            ast::TyProc(ref f) => {
-                let generics = ast::Generics {
-                    lifetimes: f.lifetimes.clone(),
-                    ty_params: OwnedSlice::empty(),
-                    where_clause: ast::WhereClause {
-                        id: ast::DUMMY_NODE_ID,
-                        predicates: Vec::new(),
-                    },
-                };
-                try!(self.print_ty_fn(None,
-                                      Some('~'),
-                                      f.fn_style,
-                                      f.onceness,
-                                      &*f.decl,
-                                      None,
-                                      &f.bounds,
-                                      Some(&generics),
-                                      None));
-            }
             ast::TyPath(ref path, _) => {
                 try!(self.print_path(path, false));
             }
@@ -1696,33 +1677,6 @@ pub fn print_expr(&mut self, expr: &ast::Expr) -> IoResult<()> {
                 // empty box to satisfy the close.
                 try!(self.ibox(0));
             }
-            ast::ExprProc(ref decl, ref body) => {
-                // in do/for blocks we don't want to show an empty
-                // argument list, but at this point we don't know which
-                // we are inside.
-                //
-                // if !decl.inputs.is_empty() {
-                try!(self.print_proc_args(&**decl));
-                try!(space(&mut self.s));
-                // }
-                assert!(body.stmts.is_empty());
-                assert!(body.expr.is_some());
-                // we extract the block, so as not to create another set of boxes
-                match body.expr.as_ref().unwrap().node {
-                    ast::ExprBlock(ref blk) => {
-                        try!(self.print_block_unclosed(&**blk));
-                    }
-                    _ => {
-                        // this is a bare expression
-                        try!(self.print_expr(body.expr.as_ref().map(|e| &**e).unwrap()));
-                        try!(self.end()); // need to close a box
-                    }
-                }
-                // a box will be closed by print_expr, but we didn't want an overall
-                // wrapper so we closed the corresponding opening. so create an
-                // empty box to satisfy the close.
-                try!(self.ibox(0));
-            }
             ast::ExprBlock(ref blk) => {
                 // containing cbox, will be closed by print-block at }
                 try!(self.cbox(indent_unit));
@@ -2010,6 +1964,7 @@ fn print_path_parameters(&mut self,
                 match data.output {
                     None => { }
                     Some(ref ty) => {
+                        try!(self.space_if_not_bol());
                         try!(self.word_space("->"));
                         try!(self.print_type(&**ty));
                     }
index a36f8b23ca3226d1bdb536a83b52980628a1896c..eca99df8e5561c2985015a75bcdb47d0dcefc4c0 100644 (file)
@@ -389,14 +389,6 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
             walk_ty_param_bounds_helper(visitor, &function_declaration.bounds);
             walk_lifetime_decls_helper(visitor, &function_declaration.lifetimes);
         }
-        TyProc(ref function_declaration) => {
-            for argument in function_declaration.decl.inputs.iter() {
-                visitor.visit_ty(&*argument.ty)
-            }
-            walk_fn_ret_ty(visitor, &function_declaration.decl.output);
-            walk_ty_param_bounds_helper(visitor, &function_declaration.bounds);
-            walk_lifetime_decls_helper(visitor, &function_declaration.lifetimes);
-        }
         TyBareFn(ref function_declaration) => {
             for argument in function_declaration.decl.inputs.iter() {
                 visitor.visit_ty(&*argument.ty)
@@ -831,13 +823,6 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
                              expression.span,
                              expression.id)
         }
-        ExprProc(ref function_declaration, ref body) => {
-            visitor.visit_fn(FkFnBlock,
-                             &**function_declaration,
-                             &**body,
-                             expression.span,
-                             expression.id)
-        }
         ExprBlock(ref block) => visitor.visit_block(&**block),
         ExprAssign(ref left_hand_expression, ref right_hand_expression) => {
             visitor.visit_expr(&**right_hand_expression);