Skip to content

Commit a6867e2

Browse files
committed
Removing support for the do syntax from libsyntax and librustc.
Fixes #10815.
1 parent 221670b commit a6867e2

File tree

17 files changed

+48
-212
lines changed

17 files changed

+48
-212
lines changed

src/librustc/middle/cfg/construct.rs

-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ impl CFGBuilder {
398398
}
399399

400400
ast::ExprAddrOf(_, e) |
401-
ast::ExprDoBody(e) |
402401
ast::ExprCast(e, _) |
403402
ast::ExprUnary(_, _, e) |
404403
ast::ExprParen(e) |

src/librustc/middle/dataflow.rs

-1
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,6 @@ impl<'a, O:DataFlowOperator> PropagationContext<'a, O> {
706706
ast::ExprPath(..) => {}
707707

708708
ast::ExprAddrOf(_, e) |
709-
ast::ExprDoBody(e) |
710709
ast::ExprCast(e, _) |
711710
ast::ExprUnary(_, _, e) |
712711
ast::ExprParen(e) |

src/librustc/middle/liveness.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ fn visit_expr(v: &mut LivenessVisitor, expr: &Expr, this: @IrMaps) {
538538
ExprIndex(..) | ExprField(..) | ExprVstore(..) | ExprVec(..) |
539539
ExprCall(..) | ExprMethodCall(..) | ExprTup(..) | ExprLogLevel |
540540
ExprBinary(..) | ExprAddrOf(..) |
541-
ExprDoBody(..) | ExprCast(..) | ExprUnary(..) | ExprBreak(_) |
541+
ExprCast(..) | ExprUnary(..) | ExprBreak(_) |
542542
ExprAgain(_) | ExprLit(_) | ExprRet(..) | ExprBlock(..) |
543543
ExprAssign(..) | ExprAssignOp(..) | ExprMac(..) |
544544
ExprStruct(..) | ExprRepeat(..) | ExprParen(..) |
@@ -1245,7 +1245,6 @@ impl Liveness {
12451245
}
12461246

12471247
ExprAddrOf(_, e) |
1248-
ExprDoBody(e) |
12491248
ExprCast(e, _) |
12501249
ExprUnary(_, _, e) |
12511250
ExprParen(e) => {
@@ -1529,7 +1528,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
15291528
ExprCall(..) | ExprMethodCall(..) | ExprIf(..) | ExprMatch(..) |
15301529
ExprWhile(..) | ExprLoop(..) | ExprIndex(..) | ExprField(..) |
15311530
ExprVstore(..) | ExprVec(..) | ExprTup(..) | ExprLogLevel |
1532-
ExprBinary(..) | ExprDoBody(..) |
1531+
ExprBinary(..) |
15331532
ExprCast(..) | ExprUnary(..) | ExprRet(..) | ExprBreak(..) |
15341533
ExprAgain(..) | ExprLit(_) | ExprBlock(..) |
15351534
ExprMac(..) | ExprAddrOf(..) | ExprStruct(..) | ExprRepeat(..) |

src/librustc/middle/mem_categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ impl mem_categorization_ctxt {
436436
ast::ExprAddrOf(..) | ast::ExprCall(..) |
437437
ast::ExprAssign(..) | ast::ExprAssignOp(..) |
438438
ast::ExprFnBlock(..) | ast::ExprProc(..) | ast::ExprRet(..) |
439-
ast::ExprDoBody(..) | ast::ExprUnary(..) |
439+
ast::ExprUnary(..) |
440440
ast::ExprMethodCall(..) | ast::ExprCast(..) | ast::ExprVstore(..) |
441441
ast::ExprVec(..) | ast::ExprTup(..) | ast::ExprIf(..) |
442442
ast::ExprLogLevel | ast::ExprBinary(..) | ast::ExprWhile(..) |

src/librustc/middle/moves.rs

-4
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,6 @@ impl VisitContext {
570570
self.consume_expr(count);
571571
}
572572

573-
ExprDoBody(base) => {
574-
self.use_expr(base, comp_mode);
575-
}
576-
577573
ExprFnBlock(ref decl, body) |
578574
ExprProc(ref decl, body) => {
579575
for a in decl.inputs.iter() {

src/librustc/middle/trans/debuginfo.rs

-14
Original file line numberDiff line numberDiff line change
@@ -2655,20 +2655,6 @@ fn populate_scope_map(cx: &CrateContext,
26552655
})
26562656
}
26572657

2658-
ast::ExprDoBody(inner_exp) => {
2659-
let inner_expr_is_expr_fn_block = match *inner_exp {
2660-
ast::Expr { node: ast::ExprFnBlock(..), .. } => true,
2661-
_ => false
2662-
};
2663-
2664-
if !inner_expr_is_expr_fn_block {
2665-
cx.sess.span_bug(inner_exp.span, "debuginfo: Inner expression was expected \
2666-
to be an ast::expr_fn_block.");
2667-
}
2668-
2669-
walk_expr(cx, inner_exp, scope_stack, scope_map);
2670-
}
2671-
26722658
ast::ExprCall(fn_exp, ref args, _) => {
26732659
walk_expr(cx, fn_exp, scope_stack, scope_map);
26742660

src/librustc/middle/trans/expr.rs

-3
Original file line numberDiff line numberDiff line change
@@ -867,9 +867,6 @@ fn trans_rvalue_dps_unadjusted<'a>(bcx: &'a Block<'a>,
867867
closure::trans_expr_fn(bcx, sigil, decl, body,
868868
expr.id, expr.id, dest)
869869
}
870-
ast::ExprDoBody(blk) => {
871-
trans_into(bcx, blk, dest)
872-
}
873870
ast::ExprCall(f, ref args, _) => {
874871
callee::trans_call(bcx, expr, f,
875872
callee::ArgExprs(*args), expr.id, dest)

src/librustc/middle/ty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3166,7 +3166,6 @@ pub fn expr_kind(tcx: ctxt,
31663166
ast::ExprMatch(..) |
31673167
ast::ExprFnBlock(..) |
31683168
ast::ExprProc(..) |
3169-
ast::ExprDoBody(..) |
31703169
ast::ExprBlock(..) |
31713170
ast::ExprRepeat(..) |
31723171
ast::ExprVstore(_, ast::ExprVstoreSlice) |

src/librustc/middle/typeck/check/mod.rs

+1-42
Original file line numberDiff line numberDiff line change
@@ -1640,8 +1640,6 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
16401640
} else {
16411641
let suffix = match sugar {
16421642
ast::NoSugar => "",
1643-
ast::DoSugar => " (including the closure passed by \
1644-
the `do` keyword)",
16451643
ast::ForSugar => " (including the closure passed by \
16461644
the `for` keyword)"
16471645
};
@@ -1690,8 +1688,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
16901688
for (i, arg) in args.iter().take(t).enumerate() {
16911689
let is_block = match arg.node {
16921690
ast::ExprFnBlock(..) |
1693-
ast::ExprProc(..) |
1694-
ast::ExprDoBody(..) => true,
1691+
ast::ExprProc(..) => true,
16951692
_ => false
16961693
};
16971694

@@ -2928,44 +2925,6 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
29282925
Vanilla,
29292926
expected);
29302927
}
2931-
ast::ExprDoBody(b) => {
2932-
let expected_sty = unpack_expected(fcx,
2933-
expected,
2934-
|x| Some((*x).clone()));
2935-
let inner_ty = match expected_sty {
2936-
Some(ty::ty_closure(ref closure_ty))
2937-
if closure_ty.sigil == ast::OwnedSigil => {
2938-
expected.unwrap()
2939-
}
2940-
_ => match expected {
2941-
Some(expected_t) => {
2942-
fcx.type_error_message(expr.span, |actual| {
2943-
format!("last argument in `do` call \
2944-
has non-procedure type: {}",
2945-
actual)
2946-
}, expected_t, None);
2947-
let err_ty = ty::mk_err();
2948-
fcx.write_ty(id, err_ty);
2949-
err_ty
2950-
}
2951-
None => {
2952-
fcx.tcx().sess.impossible_case(
2953-
expr.span,
2954-
"do body must have expected type")
2955-
}
2956-
}
2957-
};
2958-
match b.node {
2959-
ast::ExprFnBlock(decl, body) => {
2960-
check_expr_fn(fcx, b, None,
2961-
decl, body, DoBlock, Some(inner_ty));
2962-
demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b));
2963-
}
2964-
// argh
2965-
_ => fail!("expected fn ty")
2966-
}
2967-
fcx.write_ty(expr.id, fcx.node_ty(b.id));
2968-
}
29692928
ast::ExprBlock(b) => {
29702929
check_block_with_expected(fcx, b, expected);
29712930
fcx.write_ty(id, fcx.node_ty(b.id));

src/librustc/middle/typeck/check/regionck.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,6 @@ pub mod guarantor {
10451045
ast::ExprMatch(..) |
10461046
ast::ExprFnBlock(..) |
10471047
ast::ExprProc(..) |
1048-
ast::ExprDoBody(..) |
10491048
ast::ExprBlock(..) |
10501049
ast::ExprRepeat(..) |
10511050
ast::ExprVec(..) => {

src/libsyntax/ast.rs

-2
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,6 @@ impl Expr {
539539
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
540540
pub enum CallSugar {
541541
NoSugar,
542-
DoSugar,
543542
ForSugar
544543
}
545544

@@ -566,7 +565,6 @@ pub enum Expr_ {
566565
ExprMatch(@Expr, ~[Arm]),
567566
ExprFnBlock(P<FnDecl>, P<Block>),
568567
ExprProc(P<FnDecl>, P<Block>),
569-
ExprDoBody(@Expr),
570568
ExprBlock(P<Block>),
571569

572570
ExprAssign(@Expr, @Expr),

src/libsyntax/fold.rs

-1
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,6 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr {
752752
ExprUnary(callee_id, binop, ohs) => {
753753
ExprUnary(folder.new_id(callee_id), binop, folder.fold_expr(ohs))
754754
}
755-
ExprDoBody(f) => ExprDoBody(folder.fold_expr(f)),
756755
ExprLit(_) => e.node.clone(),
757756
ExprCast(expr, ty) => {
758757
ExprCast(folder.fold_expr(expr), folder.fold_ty(ty))

src/libsyntax/parse/classify.rs

-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ pub fn expr_requires_semi_to_be_stmt(e: @ast::Expr) -> bool {
2929
| ast::ExprWhile(..)
3030
| ast::ExprLoop(..)
3131
| ast::ExprForLoop(..)
32-
| ast::ExprCall(_, _, ast::DoSugar)
3332
| ast::ExprCall(_, _, ast::ForSugar)
34-
| ast::ExprMethodCall(_, _, _, _, ast::DoSugar)
3533
| ast::ExprMethodCall(_, _, _, _, ast::ForSugar) => false,
3634
_ => true
3735
}

src/libsyntax/parse/parser.rs

+2-74
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use abi;
1414
use abi::AbiSet;
1515
use ast::{Sigil, BorrowedSigil, ManagedSigil, OwnedSigil};
16-
use ast::{CallSugar, NoSugar, DoSugar};
16+
use ast::{CallSugar, NoSugar};
1717
use ast::{BareFnTy, ClosureTy};
1818
use ast::{RegionTyParamBound, TraitTyParamBound};
1919
use ast::{Provided, Public, Purity};
@@ -24,7 +24,7 @@ use ast::{Crate, CrateConfig, Decl, DeclItem};
2424
use ast::{DeclLocal, DefaultBlock, UnDeref, BiDiv, EMPTY_CTXT, EnumDef, ExplicitSelf};
2525
use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain};
2626
use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox};
27-
use ast::{ExprBreak, ExprCall, ExprCast, ExprDoBody};
27+
use ast::{ExprBreak, ExprCall, ExprCast};
2828
use ast::{ExprField, ExprFnBlock, ExprIf, ExprIndex};
2929
use ast::{ExprLit, ExprLogLevel, ExprLoop, ExprMac};
3030
use ast::{ExprMethodCall, ExprParen, ExprPath, ExprProc};
@@ -1796,9 +1796,6 @@ impl Parser {
17961796
return self.parse_if_expr();
17971797
} else if self.eat_keyword(keywords::For) {
17981798
return self.parse_for_expr(None);
1799-
} else if self.eat_keyword(keywords::Do) {
1800-
return self.parse_sugary_call_expr(lo, ~"do", DoSugar,
1801-
ExprDoBody);
18021799
} else if self.eat_keyword(keywords::While) {
18031800
return self.parse_while_expr();
18041801
} else if Parser::token_is_lifetime(&self.token) {
@@ -2541,75 +2538,6 @@ impl Parser {
25412538
self.mk_expr(lo, hi, ExprForLoop(pat, expr, loop_block, opt_ident))
25422539
}
25432540

2544-
2545-
// parse a 'do'.
2546-
// the 'do' expression parses as a call, but looks like
2547-
// a function call followed by a closure expression.
2548-
pub fn parse_sugary_call_expr(&mut self,
2549-
lo: BytePos,
2550-
keyword: ~str,
2551-
sugar: CallSugar,
2552-
ctor: |v: @Expr| -> Expr_)
2553-
-> @Expr {
2554-
// Parse the callee `foo` in
2555-
// do foo || {
2556-
// do foo.bar || {
2557-
// etc, or the portion of the call expression before the lambda in
2558-
// do foo() || {
2559-
// or
2560-
// do foo.bar(a) || {
2561-
// Turn on the restriction to stop at | or || so we can parse
2562-
// them as the lambda arguments
2563-
let e = self.parse_expr_res(RESTRICT_NO_BAR_OR_DOUBLEBAR_OP);
2564-
match e.node {
2565-
ExprCall(f, ref args, NoSugar) => {
2566-
let block = self.parse_lambda_block_expr();
2567-
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
2568-
ctor(block));
2569-
let args = vec::append_one((*args).clone(), last_arg);
2570-
self.mk_expr(lo, block.span.hi, ExprCall(f, args, sugar))
2571-
}
2572-
ExprMethodCall(_, i, ref tps, ref args, NoSugar) => {
2573-
let block = self.parse_lambda_block_expr();
2574-
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
2575-
ctor(block));
2576-
let args = vec::append_one((*args).clone(), last_arg);
2577-
let method_call = self.mk_method_call(i,
2578-
(*tps).clone(),
2579-
args,
2580-
sugar);
2581-
self.mk_expr(lo, block.span.hi, method_call)
2582-
}
2583-
ExprField(f, i, ref tps) => {
2584-
let block = self.parse_lambda_block_expr();
2585-
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
2586-
ctor(block));
2587-
let method_call = self.mk_method_call(i,
2588-
(*tps).clone(),
2589-
~[f, last_arg],
2590-
sugar);
2591-
self.mk_expr(lo, block.span.hi, method_call)
2592-
}
2593-
ExprPath(..) | ExprCall(..) | ExprMethodCall(..) |
2594-
ExprParen(..) => {
2595-
let block = self.parse_lambda_block_expr();
2596-
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
2597-
ctor(block));
2598-
let call = self.mk_call(e, ~[last_arg], sugar);
2599-
self.mk_expr(lo, last_arg.span.hi, call)
2600-
}
2601-
_ => {
2602-
// There may be other types of expressions that can
2603-
// represent the callee in `do` expressions
2604-
// but they aren't represented by tests
2605-
debug!("sugary call on {:?}", e.node);
2606-
self.span_fatal(
2607-
e.span,
2608-
format!("`{}` must be followed by a block call", keyword));
2609-
}
2610-
}
2611-
}
2612-
26132541
pub fn parse_while_expr(&mut self) -> @Expr {
26142542
let lo = self.last_span.lo;
26152543
let cond = self.parse_expr();

0 commit comments

Comments
 (0)