Skip to content

Commit d258d68

Browse files
committed
Remove proc types/expressions from the parser, compiler, and
language. Recommend `move||` instead.
1 parent 9cc8453 commit d258d68

33 files changed

+91
-321
lines changed

src/libcore/raw.rs

-9
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@ pub struct Closure {
4040

4141
impl Copy for Closure {}
4242

43-
/// The representation of a Rust procedure (`proc()`)
44-
#[repr(C)]
45-
pub struct Procedure {
46-
pub code: *mut (),
47-
pub env: *mut (),
48-
}
49-
50-
impl Copy for Procedure {}
51-
5243
/// The representation of a Rust trait object.
5344
///
5445
/// This struct does not have a `Repr` implementation

src/librustc/middle/cfg/construct.rs

-1
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,6 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
498498

499499
ast::ExprMac(..) |
500500
ast::ExprClosure(..) |
501-
ast::ExprProc(..) |
502501
ast::ExprLit(..) |
503502
ast::ExprPath(..) => {
504503
self.straightline(expr, pred, None::<ast::Expr>.iter())

src/librustc/middle/check_loop.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ impl<'a, 'v> Visitor<'v> for CheckLoopVisitor<'a> {
5252
self.visit_expr(&**e);
5353
self.with_context(Loop, |v| v.visit_block(&**b));
5454
}
55-
ast::ExprClosure(_, _, _, ref b) |
56-
ast::ExprProc(_, ref b) => {
55+
ast::ExprClosure(_, _, _, ref b) => {
5756
self.with_context(Closure, |v| v.visit_block(&**b));
5857
}
5958
ast::ExprBreak(_) => self.require_loop("break", e.span),

src/librustc/middle/expr_use_visitor.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
613613
self.consume_expr(&**count);
614614
}
615615

616-
ast::ExprClosure(..) |
617-
ast::ExprProc(..) => {
616+
ast::ExprClosure(..) => {
618617
self.walk_captures(expr)
619618
}
620619

src/librustc/middle/infer/error_reporting.rs

-53
Original file line numberDiff line numberDiff line change
@@ -587,19 +587,6 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
587587
sub,
588588
"");
589589
}
590-
infer::ProcCapture(span, id) => {
591-
self.tcx.sess.span_err(
592-
span,
593-
format!("captured variable `{}` must be 'static \
594-
to be captured in a proc",
595-
ty::local_var_name_str(self.tcx, id).get())
596-
.as_slice());
597-
note_and_explain_region(
598-
self.tcx,
599-
"captured variable is only valid for ",
600-
sup,
601-
"");
602-
}
603590
infer::IndexSlice(span) => {
604591
self.tcx.sess.span_err(span,
605592
"index of slice outside its lifetime");
@@ -625,28 +612,6 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
625612
sup,
626613
"");
627614
}
628-
infer::RelateProcBound(span, var_node_id, ty) => {
629-
self.tcx.sess.span_err(
630-
span,
631-
format!(
632-
"the type `{}` of captured variable `{}` \
633-
outlives the `proc()` it \
634-
is captured in",
635-
self.ty_to_string(ty),
636-
ty::local_var_name_str(self.tcx,
637-
var_node_id)).as_slice());
638-
note_and_explain_region(
639-
self.tcx,
640-
"`proc()` is valid for ",
641-
sub,
642-
"");
643-
note_and_explain_region(
644-
self.tcx,
645-
format!("the type `{}` is only valid for ",
646-
self.ty_to_string(ty)).as_slice(),
647-
sup,
648-
"");
649-
}
650615
infer::RelateParamBound(span, ty) => {
651616
self.tcx.sess.span_err(
652617
span,
@@ -1587,15 +1552,6 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
15871552
self.tcx,
15881553
id).get().to_string()).as_slice());
15891554
}
1590-
infer::ProcCapture(span, id) => {
1591-
self.tcx.sess.span_note(
1592-
span,
1593-
format!("...so that captured variable `{}` \
1594-
is 'static",
1595-
ty::local_var_name_str(
1596-
self.tcx,
1597-
id).get()).as_slice());
1598-
}
15991555
infer::IndexSlice(span) => {
16001556
self.tcx.sess.span_note(
16011557
span,
@@ -1606,15 +1562,6 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
16061562
span,
16071563
"...so that it can be closed over into an object");
16081564
}
1609-
infer::RelateProcBound(span, var_node_id, _ty) => {
1610-
self.tcx.sess.span_note(
1611-
span,
1612-
format!(
1613-
"...so that the variable `{}` can be captured \
1614-
into a proc",
1615-
ty::local_var_name_str(self.tcx,
1616-
var_node_id)).as_slice());
1617-
}
16181565
infer::CallRcvr(span) => {
16191566
self.tcx.sess.span_note(
16201567
span,

src/librustc/middle/infer/mod.rs

-18
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,13 @@ pub enum SubregionOrigin<'tcx> {
175175
// Closure bound must not outlive captured free variables
176176
FreeVariable(Span, ast::NodeId),
177177

178-
// Proc upvars must be 'static
179-
ProcCapture(Span, ast::NodeId),
180-
181178
// Index into slice must be within its lifetime
182179
IndexSlice(Span),
183180

184181
// When casting `&'a T` to an `&'b Trait` object,
185182
// relating `'a` to `'b`
186183
RelateObjectBound(Span),
187184

188-
// When closing over a variable in a closure/proc, ensure that the
189-
// type of the variable outlives the lifetime bound.
190-
RelateProcBound(Span, ast::NodeId, Ty<'tcx>),
191-
192185
// Some type parameter was instantiated with the given type,
193186
// and that type must outlive some region.
194187
RelateParamBound(Span, Ty<'tcx>),
@@ -1089,10 +1082,8 @@ impl<'tcx> SubregionOrigin<'tcx> {
10891082
InvokeClosure(a) => a,
10901083
DerefPointer(a) => a,
10911084
FreeVariable(a, _) => a,
1092-
ProcCapture(a, _) => a,
10931085
IndexSlice(a) => a,
10941086
RelateObjectBound(a) => a,
1095-
RelateProcBound(a, _, _) => a,
10961087
RelateParamBound(a, _) => a,
10971088
RelateRegionParamBound(a) => a,
10981089
RelateDefaultParamBound(a, _) => a,
@@ -1128,21 +1119,12 @@ impl<'tcx> Repr<'tcx> for SubregionOrigin<'tcx> {
11281119
FreeVariable(a, b) => {
11291120
format!("FreeVariable({}, {})", a.repr(tcx), b)
11301121
}
1131-
ProcCapture(a, b) => {
1132-
format!("ProcCapture({}, {})", a.repr(tcx), b)
1133-
}
11341122
IndexSlice(a) => {
11351123
format!("IndexSlice({})", a.repr(tcx))
11361124
}
11371125
RelateObjectBound(a) => {
11381126
format!("RelateObjectBound({})", a.repr(tcx))
11391127
}
1140-
RelateProcBound(a, b, c) => {
1141-
format!("RelateProcBound({},{},{})",
1142-
a.repr(tcx),
1143-
b,
1144-
c.repr(tcx))
1145-
}
11461128
RelateParamBound(a, b) => {
11471129
format!("RelateParamBound({},{})",
11481130
a.repr(tcx),

src/librustc/middle/liveness.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
461461
}
462462
visit::walk_expr(ir, expr);
463463
}
464-
ast::ExprClosure(..) | ast::ExprProc(..) => {
464+
ast::ExprClosure(..) => {
465465
// Interesting control flow (for loops can contain labeled
466466
// breaks or continues)
467467
ir.add_live_node_for_node(expr.id, ExprNode(expr.span));
@@ -981,9 +981,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
981981
self.propagate_through_expr(&**e, succ)
982982
}
983983

984-
ast::ExprClosure(_, _, _, ref blk) |
985-
ast::ExprProc(_, ref blk) => {
986-
debug!("{} is an ExprClosure or ExprProc",
984+
ast::ExprClosure(_, _, _, ref blk) => {
985+
debug!("{} is an ExprClosure",
987986
expr_to_string(expr));
988987

989988
/*
@@ -1502,8 +1501,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
15021501
ast::ExprBreak(..) | ast::ExprAgain(..) | ast::ExprLit(_) |
15031502
ast::ExprBlock(..) | ast::ExprMac(..) | ast::ExprAddrOf(..) |
15041503
ast::ExprStruct(..) | ast::ExprRepeat(..) | ast::ExprParen(..) |
1505-
ast::ExprClosure(..) | ast::ExprProc(..) |
1506-
ast::ExprPath(..) | ast::ExprBox(..) | ast::ExprSlice(..) => {
1504+
ast::ExprClosure(..) | ast::ExprPath(..) | ast::ExprBox(..) | ast::ExprSlice(..) => {
15071505
visit::walk_expr(this, expr);
15081506
}
15091507
ast::ExprIfLet(..) => {

src/librustc/middle/mem_categorization.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
555555

556556
ast::ExprAddrOf(..) | ast::ExprCall(..) |
557557
ast::ExprAssign(..) | ast::ExprAssignOp(..) |
558-
ast::ExprClosure(..) | ast::ExprProc(..) |
559-
ast::ExprRet(..) |
558+
ast::ExprClosure(..) | ast::ExprRet(..) |
560559
ast::ExprUnary(..) | ast::ExprSlice(..) |
561560
ast::ExprMethodCall(..) | ast::ExprCast(..) |
562561
ast::ExprVec(..) | ast::ExprTup(..) | ast::ExprIf(..) |
@@ -728,7 +727,6 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
728727
};
729728

730729
match fn_expr.node {
731-
ast::ExprProc(_, ref body) |
732730
ast::ExprClosure(_, _, _, ref body) => body.id,
733731
_ => unreachable!()
734732
}

src/librustc/middle/resolve.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use util::nodemap::{NodeMap, NodeSet, DefIdSet, FnvHashMap};
5151
use syntax::ast::{Arm, BindByRef, BindByValue, BindingMode, Block, Crate, CrateNum};
5252
use syntax::ast::{DeclItem, DefId, Expr, ExprAgain, ExprBreak, ExprField};
5353
use syntax::ast::{ExprClosure, ExprForLoop, ExprLoop, ExprWhile, ExprMethodCall};
54-
use syntax::ast::{ExprPath, ExprProc, ExprStruct, FnDecl};
54+
use syntax::ast::{ExprPath, ExprStruct, FnDecl};
5555
use syntax::ast::{ForeignItem, ForeignItemFn, ForeignItemStatic, Generics};
5656
use syntax::ast::{Ident, ImplItem, Item, ItemEnum, ItemFn, ItemForeignMod};
5757
use syntax::ast::{ItemImpl, ItemMac, ItemMod, ItemStatic, ItemStruct};
@@ -64,7 +64,7 @@ use syntax::ast::{RegionTyParamBound, StmtDecl, StructField};
6464
use syntax::ast::{StructVariantKind, TraitRef, TraitTyParamBound};
6565
use syntax::ast::{TupleVariantKind, Ty, TyBool, TyChar, TyClosure, TyF32};
6666
use syntax::ast::{TyF64, TyFloat, TyI, TyI8, TyI16, TyI32, TyI64, TyInt, TyObjectSum};
67-
use syntax::ast::{TyParam, TyParamBound, TyPath, TyPtr, TyPolyTraitRef, TyProc, TyQPath};
67+
use syntax::ast::{TyParam, TyParamBound, TyPath, TyPtr, TyPolyTraitRef, TyQPath};
6868
use syntax::ast::{TyRptr, TyStr, TyU, TyU8, TyU16, TyU32, TyU64, TyUint};
6969
use syntax::ast::{TypeImplItem, UnnamedField};
7070
use syntax::ast::{Variant, ViewItem, ViewItemExternCrate};
@@ -5027,7 +5027,7 @@ impl<'a> Resolver<'a> {
50275027
self.resolve_trait_reference(ty.id, &*qpath.trait_ref, TraitQPath);
50285028
}
50295029

5030-
TyClosure(ref c) | TyProc(ref c) => {
5030+
TyClosure(ref c) => {
50315031
self.resolve_type_parameter_bounds(
50325032
ty.id,
50335033
&c.bounds,
@@ -5902,13 +5902,6 @@ impl<'a> Resolver<'a> {
59025902
&**block);
59035903
}
59045904

5905-
ExprProc(ref fn_decl, ref block) => {
5906-
self.capture_mode_map.insert(expr.id, ast::CaptureByValue);
5907-
self.resolve_function(ClosureRibKind(expr.id, block.id),
5908-
Some(&**fn_decl), NoTypeParameters,
5909-
&**block);
5910-
}
5911-
59125905
ExprStruct(ref path, _, _) => {
59135906
// Resolve the path to the structure it goes to. We don't
59145907
// check to ensure that the path is actually a structure; that

src/librustc/middle/resolve_lifetime.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
141141

142142
fn visit_ty(&mut self, ty: &ast::Ty) {
143143
match ty.node {
144-
ast::TyClosure(ref c) | ast::TyProc(ref c) => {
144+
ast::TyClosure(ref c) => {
145145
// Careful, the bounds on a closure/proc are *not* within its binder.
146146
visit::walk_ty_param_bounds_helper(self, &c.bounds);
147147
visit::walk_lifetime_decls_helper(self, &c.lifetimes);

src/librustc/middle/traits/select.rs

+21-4
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
746746
_ => { return Ok(()); }
747747
};
748748

749-
debug!("assemble_unboxed_candidates: self_ty={} obligation={}",
749+
debug!("assemble_unboxed_candidates: self_ty={} kind={} obligation={}",
750750
self_ty.repr(self.tcx()),
751+
kind,
751752
obligation.repr(self.tcx()));
752753

753754
let closure_kind = match self.typer.unboxed_closures().borrow().get(&closure_def_id) {
@@ -760,6 +761,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
760761
}
761762
};
762763

764+
debug!("closure_kind = {}", closure_kind);
765+
763766
if closure_kind == kind {
764767
candidates.vec.push(UnboxedClosureCandidate(closure_def_id, substs.clone()));
765768
}
@@ -842,14 +845,24 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
842845
candidate: &Candidate<'tcx>)
843846
-> EvaluationResult<'tcx>
844847
{
845-
debug!("winnow_candidate: candidate={}", candidate.repr(self.tcx()));
846-
self.infcx.probe(|| {
848+
/*!
849+
* Further evaluate `candidate` to decide whether all type parameters match
850+
* and whether nested obligations are met. Returns true if `candidate` remains
851+
* viable after this further scrutiny.
852+
*/
853+
854+
debug!("winnow_candidate: depth={} candidate={}",
855+
stack.obligation.recursion_depth, candidate.repr(self.tcx()));
856+
let result = self.infcx.probe(|| {
847857
let candidate = (*candidate).clone();
848858
match self.confirm_candidate(stack.obligation, candidate) {
849859
Ok(selection) => self.winnow_selection(Some(stack), selection),
850860
Err(error) => EvaluatedToErr(error),
851861
}
852-
})
862+
});
863+
debug!("winnow_candidate depth={} result={}",
864+
stack.obligation.recursion_depth, result);
865+
result
853866
}
854867

855868
fn winnow_selection<'o>(&mut self,
@@ -1562,6 +1575,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15621575
substs: substs,
15631576
});
15641577

1578+
debug!("confirm_unboxed_closure_candidate(closure_def_id={}, trait_ref={})",
1579+
closure_def_id.repr(self.tcx()),
1580+
trait_ref.repr(self.tcx()));
1581+
15651582
self.confirm(obligation.cause,
15661583
obligation.trait_ref.clone(),
15671584
trait_ref)

src/librustc/middle/ty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4236,7 +4236,6 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
42364236
ast::ExprIf(..) |
42374237
ast::ExprMatch(..) |
42384238
ast::ExprClosure(..) |
4239-
ast::ExprProc(..) |
42404239
ast::ExprBlock(..) |
42414240
ast::ExprRepeat(..) |
42424241
ast::ExprVec(..) => {

src/librustc/util/ppaux.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,14 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
449449
let unboxed_closures = cx.unboxed_closures.borrow();
450450
unboxed_closures.get(did).map(|cl| {
451451
closure_to_string(cx, &cl.closure_type.subst(cx, substs))
452-
}).unwrap_or_else(|| "closure".to_string())
452+
}).unwrap_or_else(|| {
453+
if did.krate == ast::LOCAL_CRATE {
454+
let span = cx.map.span(did.node);
455+
format!("closure[{}]", span.repr(cx))
456+
} else {
457+
format!("closure")
458+
}
459+
})
453460
}
454461
ty_vec(t, sz) => {
455462
let inner_str = ty_to_string(cx, t);

src/librustc_back/svh.rs

-2
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ mod svh_visitor {
242242
SawExprWhile,
243243
SawExprMatch,
244244
SawExprClosure,
245-
SawExprProc,
246245
SawExprBlock,
247246
SawExprAssign,
248247
SawExprAssignOp(ast::BinOp),
@@ -274,7 +273,6 @@ mod svh_visitor {
274273
ExprLoop(_, id) => SawExprLoop(id.map(content)),
275274
ExprMatch(..) => SawExprMatch,
276275
ExprClosure(..) => SawExprClosure,
277-
ExprProc(..) => SawExprProc,
278276
ExprBlock(..) => SawExprBlock,
279277
ExprAssign(..) => SawExprAssign,
280278
ExprAssignOp(op, _, _) => SawExprAssignOp(op),

src/librustc_borrowck/borrowck/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ pub fn closure_to_block(closure_id: ast::NodeId,
337337
tcx: &ty::ctxt) -> ast::NodeId {
338338
match tcx.map.get(closure_id) {
339339
ast_map::NodeExpr(expr) => match expr.node {
340-
ast::ExprProc(_, ref block) |
341340
ast::ExprClosure(_, _, _, ref block) => {
342341
block.id
343342
}

src/librustc_trans/trans/base.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1396,8 +1396,7 @@ fn has_nested_returns(tcx: &ty::ctxt, id: ast::NodeId) -> bool {
13961396
}
13971397
Some(ast_map::NodeExpr(e)) => {
13981398
match e.node {
1399-
ast::ExprClosure(_, _, _, ref blk) |
1400-
ast::ExprProc(_, ref blk) => {
1399+
ast::ExprClosure(_, _, _, ref blk) => {
14011400
let mut explicit = CheckForNestedReturnsVisitor::explicit();
14021401
let mut implicit = CheckForNestedReturnsVisitor::implicit();
14031402
visit::walk_expr(&mut explicit, e);

0 commit comments

Comments
 (0)