Skip to content

Commit e7bb33a

Browse files
committed
rm obsolete for support from the compiler
1 parent 1008945 commit e7bb33a

20 files changed

+15
-323
lines changed

src/librustc/middle/cfg/construct.rs

-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,6 @@ impl CFGBuilder {
396396
}
397397

398398
ast::expr_addr_of(_, e) |
399-
ast::expr_loop_body(e) |
400399
ast::expr_do_body(e) |
401400
ast::expr_cast(e, _) |
402401
ast::expr_unary(_, _, e) |

src/librustc/middle/check_loop.rs

-8
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ pub fn check_crate(tcx: ty::ctxt, crate: &Crate) {
4545
can_ret: false
4646
}, v));
4747
}
48-
expr_loop_body(@expr {node: expr_fn_block(_, ref b), _}) => {
49-
let sigil = ty::ty_closure_sigil(ty::expr_ty(tcx, e));
50-
let blk = (sigil == BorrowedSigil);
51-
(v.visit_block)(b, (Context {
52-
in_loop: true,
53-
can_ret: blk
54-
}, v));
55-
}
5648
expr_break(_) => {
5749
if !cx.in_loop {
5850
tcx.sess.span_err(e.span, "`break` outside of loop");

src/librustc/middle/dataflow.rs

+2-45
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,8 @@ struct PropagationContext<'self, O> {
8282
changed: bool
8383
}
8484

85-
#[deriving(Eq)]
86-
enum LoopKind {
87-
/// A `while` or `loop` loop
88-
TrueLoop,
89-
90-
/// A `for` "loop" (i.e., really a func call where `break`, `return`,
91-
/// and `loop` all essentially perform an early return from the closure)
92-
ForLoop
93-
}
94-
9585
struct LoopScope<'self> {
9686
loop_id: ast::NodeId,
97-
loop_kind: LoopKind,
9887
break_bits: ~[uint]
9988
}
10089

@@ -509,7 +498,6 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
509498

510499
loop_scopes.push(LoopScope {
511500
loop_id: expr.id,
512-
loop_kind: ForLoop,
513501
break_bits: reslice(in_out).to_owned()
514502
});
515503
for input in decl.inputs.iter() {
@@ -574,7 +562,6 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
574562
let mut body_bits = reslice(in_out).to_owned();
575563
loop_scopes.push(LoopScope {
576564
loop_id: expr.id,
577-
loop_kind: TrueLoop,
578565
break_bits: reslice(in_out).to_owned()
579566
});
580567
self.walk_block(blk, body_bits, loop_scopes);
@@ -599,7 +586,6 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
599586
self.reset(in_out);
600587
loop_scopes.push(LoopScope {
601588
loop_id: expr.id,
602-
loop_kind: TrueLoop,
603589
break_bits: reslice(in_out).to_owned()
604590
});
605591
self.walk_block(blk, body_bits, loop_scopes);
@@ -646,20 +632,6 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
646632

647633
ast::expr_ret(o_e) => {
648634
self.walk_opt_expr(o_e, in_out, loop_scopes);
649-
650-
// is this a return from a `for`-loop closure?
651-
match loop_scopes.iter().position(|s| s.loop_kind == ForLoop) {
652-
Some(i) => {
653-
// if so, add the in_out bits to the state
654-
// upon exit. Remember that we cannot count
655-
// upon the `for` loop function not to invoke
656-
// the closure again etc.
657-
self.break_from_to(expr, &mut loop_scopes[i], in_out);
658-
}
659-
660-
None => {}
661-
}
662-
663635
self.reset(in_out);
664636
}
665637

@@ -671,22 +643,8 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
671643

672644
ast::expr_again(label) => {
673645
let scope = self.find_scope(expr, label, loop_scopes);
674-
675-
match scope.loop_kind {
676-
TrueLoop => {
677-
self.pop_scopes(expr, scope, in_out);
678-
self.add_to_entry_set(scope.loop_id, reslice(in_out));
679-
}
680-
681-
ForLoop => {
682-
// If this `loop` construct is looping back to a `for`
683-
// loop, then `loop` is really just a return from the
684-
// closure. Therefore, we treat it the same as `break`.
685-
// See case for `expr_fn_block` for more details.
686-
self.break_from_to(expr, scope, in_out);
687-
}
688-
}
689-
646+
self.pop_scopes(expr, scope, in_out);
647+
self.add_to_entry_set(scope.loop_id, reslice(in_out));
690648
self.reset(in_out);
691649
}
692650

@@ -756,7 +714,6 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
756714
}
757715

758716
ast::expr_addr_of(_, e) |
759-
ast::expr_loop_body(e) |
760717
ast::expr_do_body(e) |
761718
ast::expr_cast(e, _) |
762719
ast::expr_unary(_, _, e) |

src/librustc/middle/liveness.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ fn visit_expr(expr: @expr, (this, vt): (@mut IrMaps, vt<@mut IrMaps>)) {
512512
// otherwise, live nodes are not required:
513513
expr_index(*) | expr_field(*) | expr_vstore(*) | expr_vec(*) |
514514
expr_call(*) | expr_method_call(*) | expr_tup(*) | expr_log(*) |
515-
expr_binary(*) | expr_addr_of(*) | expr_loop_body(*) |
515+
expr_binary(*) | expr_addr_of(*) |
516516
expr_do_body(*) | expr_cast(*) | expr_unary(*) | expr_break(_) |
517517
expr_again(_) | expr_lit(_) | expr_ret(*) | expr_block(*) |
518518
expr_assign(*) | expr_assign_op(*) | expr_mac(*) |
@@ -1209,7 +1209,6 @@ impl Liveness {
12091209
}
12101210

12111211
expr_addr_of(_, e) |
1212-
expr_loop_body(e) |
12131212
expr_do_body(e) |
12141213
expr_cast(e, _) |
12151214
expr_unary(_, _, e) |
@@ -1483,7 +1482,7 @@ fn check_expr(expr: @expr, (this, vt): (@Liveness, vt<@Liveness>)) {
14831482
expr_call(*) | expr_method_call(*) | expr_if(*) | expr_match(*) |
14841483
expr_while(*) | expr_loop(*) | expr_index(*) | expr_field(*) |
14851484
expr_vstore(*) | expr_vec(*) | expr_tup(*) | expr_log(*) |
1486-
expr_binary(*) | expr_loop_body(*) | expr_do_body(*) |
1485+
expr_binary(*) | expr_do_body(*) |
14871486
expr_cast(*) | expr_unary(*) | expr_ret(*) | expr_break(*) |
14881487
expr_again(*) | expr_lit(_) | expr_block(*) |
14891488
expr_mac(*) | expr_addr_of(*) | expr_struct(*) | expr_repeat(*) |

src/librustc/middle/mem_categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ impl mem_categorization_ctxt {
423423

424424
ast::expr_addr_of(*) | ast::expr_call(*) |
425425
ast::expr_assign(*) | ast::expr_assign_op(*) |
426-
ast::expr_fn_block(*) | ast::expr_ret(*) | ast::expr_loop_body(*) |
426+
ast::expr_fn_block(*) | ast::expr_ret(*) |
427427
ast::expr_do_body(*) | ast::expr_unary(*) |
428428
ast::expr_method_call(*) | ast::expr_cast(*) | ast::expr_vstore(*) |
429429
ast::expr_vec(*) | ast::expr_tup(*) | ast::expr_if(*) |

src/librustc/middle/moves.rs

-1
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ impl VisitContext {
541541
self.consume_expr(count, visitor);
542542
}
543543

544-
expr_loop_body(base) |
545544
expr_do_body(base) => {
546545
self.use_expr(base, comp_mode, visitor);
547546
}

src/librustc/middle/trans/asm.rs

-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ pub fn trans_inline_asm(bcx: @mut Block, ia: &ast::inline_asm) -> @mut Block {
4141
ty::ByCopy,
4242
out,
4343
&mut cleanups,
44-
None,
4544
callee::DontAutorefArg)
4645
}));
4746

@@ -56,7 +55,6 @@ pub fn trans_inline_asm(bcx: @mut Block, ia: &ast::inline_asm) -> @mut Block {
5655
ty::ByCopy,
5756
e,
5857
&mut cleanups,
59-
None,
6058
callee::DontAutorefArg)
6159
})
6260

@@ -77,7 +75,6 @@ pub fn trans_inline_asm(bcx: @mut Block, ia: &ast::inline_asm) -> @mut Block {
7775
ty::ByCopy,
7876
input,
7977
&mut cleanups,
80-
None,
8178
callee::DontAutorefArg)
8279
})
8380

src/librustc/middle/trans/callee.rs

+4-76
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use middle::trans::base;
2727
use middle::trans::base::*;
2828
use middle::trans::build::*;
2929
use middle::trans::callee;
30-
use middle::trans::closure;
3130
use middle::trans::common;
3231
use middle::trans::common::*;
3332
use middle::trans::datum::*;
@@ -556,29 +555,9 @@ pub fn trans_call_inner(in_cx: @mut Block,
556555
autoref_arg: AutorefArg)
557556
-> Result {
558557
do base::with_scope_result(in_cx, call_info, "call") |cx| {
559-
let ret_in_loop = match args {
560-
ArgExprs(args) => {
561-
args.len() > 0u && match args.last().node {
562-
ast::expr_loop_body(@ast::expr {
563-
node: ast::expr_fn_block(_, ref body),
564-
_
565-
}) => body_contains_ret(body),
566-
_ => false
567-
}
568-
}
569-
_ => false
570-
};
571-
572558
let callee = get_callee(cx);
573559
let mut bcx = callee.bcx;
574560
let ccx = cx.ccx();
575-
let ret_flag = if ret_in_loop {
576-
let flag = alloca(bcx, Type::bool(), "__ret_flag");
577-
Store(bcx, C_bool(false), flag);
578-
Some(flag)
579-
} else {
580-
None
581-
};
582561

583562
let (llfn, llenv) = unsafe {
584563
match callee.data {
@@ -611,9 +590,7 @@ pub fn trans_call_inner(in_cx: @mut Block,
611590
}
612591

613592
llargs.push(llenv);
614-
bcx = trans_args(bcx, args, fn_expr_ty,
615-
ret_flag, autoref_arg, &mut llargs);
616-
593+
bcx = trans_args(bcx, args, fn_expr_ty, autoref_arg, &mut llargs);
617594

618595
// Now that the arguments have finished evaluating, we need to revoke
619596
// the cleanup for the self argument
@@ -667,20 +644,6 @@ pub fn trans_call_inner(in_cx: @mut Block,
667644

668645
if ty::type_is_bot(ret_ty) {
669646
Unreachable(bcx);
670-
} else if ret_in_loop {
671-
let ret_flag_result = bool_to_i1(bcx, Load(bcx, ret_flag.get()));
672-
bcx = do with_cond(bcx, ret_flag_result) |bcx| {
673-
{
674-
let r = bcx.fcx.loop_ret;
675-
for &(flagptr, _) in r.iter() {
676-
Store(bcx, C_bool(true), flagptr);
677-
Store(bcx, C_bool(false), bcx.fcx.llretptr.get());
678-
}
679-
}
680-
base::cleanup_and_leave(bcx, None, Some(bcx.fcx.get_llreturn()));
681-
Unreachable(bcx);
682-
bcx
683-
}
684647
}
685648
rslt(bcx, llresult)
686649
}
@@ -713,7 +676,6 @@ pub fn trans_ret_slot(bcx: @mut Block, fn_ty: ty::t, dest: Option<expr::Dest>)
713676
pub fn trans_args(cx: @mut Block,
714677
args: CallArgs,
715678
fn_ty: ty::t,
716-
ret_flag: Option<ValueRef>,
717679
autoref_arg: AutorefArg,
718680
llargs: &mut ~[ValueRef]) -> @mut Block
719681
{
@@ -728,15 +690,13 @@ pub fn trans_args(cx: @mut Block,
728690
// to cast her view of the arguments to the caller's view.
729691
match args {
730692
ArgExprs(arg_exprs) => {
731-
let last = arg_exprs.len() - 1u;
732693
for (i, arg_expr) in arg_exprs.iter().enumerate() {
733694
let arg_val = unpack_result!(bcx, {
734695
trans_arg_expr(bcx,
735696
arg_tys[i],
736697
ty::ByCopy,
737698
*arg_expr,
738699
&mut temp_cleanups,
739-
if i == last { ret_flag } else { None },
740700
autoref_arg)
741701
});
742702
llargs.push(arg_val);
@@ -769,49 +729,17 @@ pub fn trans_arg_expr(bcx: @mut Block,
769729
self_mode: ty::SelfMode,
770730
arg_expr: @ast::expr,
771731
temp_cleanups: &mut ~[ValueRef],
772-
ret_flag: Option<ValueRef>,
773732
autoref_arg: AutorefArg) -> Result {
774733
let _icx = push_ctxt("trans_arg_expr");
775734
let ccx = bcx.ccx();
776735

777-
debug!("trans_arg_expr(formal_arg_ty=(%s), self_mode=%?, arg_expr=%s, \
778-
ret_flag=%?)",
736+
debug!("trans_arg_expr(formal_arg_ty=(%s), self_mode=%?, arg_expr=%s)",
779737
formal_arg_ty.repr(bcx.tcx()),
780738
self_mode,
781-
arg_expr.repr(bcx.tcx()),
782-
ret_flag.map(|v| bcx.val_to_str(*v)));
739+
arg_expr.repr(bcx.tcx()));
783740

784741
// translate the arg expr to a datum
785-
let arg_datumblock = match ret_flag {
786-
None => expr::trans_to_datum(bcx, arg_expr),
787-
788-
// If there is a ret_flag, this *must* be a loop body
789-
Some(_) => {
790-
match arg_expr.node {
791-
ast::expr_loop_body(
792-
blk @ @ast::expr {
793-
node: ast::expr_fn_block(ref decl, ref body),
794-
_
795-
}) => {
796-
let scratch_ty = expr_ty(bcx, arg_expr);
797-
let scratch = alloc_ty(bcx, scratch_ty, "__ret_flag");
798-
let arg_ty = expr_ty(bcx, arg_expr);
799-
let sigil = ty::ty_closure_sigil(arg_ty);
800-
let bcx = closure::trans_expr_fn(
801-
bcx, sigil, decl, body, arg_expr.id,
802-
blk.id, Some(ret_flag), expr::SaveIn(scratch));
803-
DatumBlock {bcx: bcx,
804-
datum: Datum {val: scratch,
805-
ty: scratch_ty,
806-
mode: ByRef(RevokeClean)}}
807-
}
808-
_ => {
809-
bcx.sess().impossible_case(
810-
arg_expr.span, "ret_flag with non-loop-body expr");
811-
}
812-
}
813-
}
814-
};
742+
let arg_datumblock = expr::trans_to_datum(bcx, arg_expr);
815743
let arg_datum = arg_datumblock.datum;
816744
let bcx = arg_datumblock.bcx;
817745

src/librustc/middle/trans/expr.rs

-21
Original file line numberDiff line numberDiff line change
@@ -605,27 +605,6 @@ fn trans_rvalue_dps_unadjusted(bcx: @mut Block, expr: @ast::expr,
605605
expr.id, expr.id,
606606
None, dest);
607607
}
608-
ast::expr_loop_body(blk) => {
609-
let expr_ty = expr_ty(bcx, expr);
610-
let sigil = ty::ty_closure_sigil(expr_ty);
611-
match blk.node {
612-
ast::expr_fn_block(ref decl, ref body) => {
613-
return closure::trans_expr_fn(bcx,
614-
sigil,
615-
decl,
616-
body,
617-
expr.id,
618-
blk.id,
619-
Some(None),
620-
dest);
621-
}
622-
_ => {
623-
bcx.sess().impossible_case(
624-
expr.span,
625-
"loop_body has the wrong kind of contents")
626-
}
627-
}
628-
}
629608
ast::expr_do_body(blk) => {
630609
return trans_into(bcx, blk, dest);
631610
}

src/librustc/middle/trans/meth.rs

-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ pub fn trans_self_arg(bcx: @mut Block,
137137
mentry.self_mode,
138138
base,
139139
temp_cleanups,
140-
None,
141140
DontAutorefArg)
142141
}
143142

src/librustc/middle/trans/type_use.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ pub fn mark_for_expr(cx: &Context, e: &expr) {
400400
expr_match(*) | expr_block(_) | expr_if(*) | expr_while(*) |
401401
expr_break(_) | expr_again(_) | expr_unary(*) | expr_lit(_) |
402402
expr_mac(_) | expr_addr_of(*) | expr_ret(_) | expr_loop(*) |
403-
expr_loop_body(_) | expr_do_body(_) => (),
403+
expr_do_body(_) => (),
404404

405405
expr_for_loop(*) => fail!("non-desugared expr_for_loop")
406406
}

src/librustc/middle/ty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3192,7 +3192,6 @@ pub fn expr_kind(tcx: ctxt,
31923192
ast::expr_if(*) |
31933193
ast::expr_match(*) |
31943194
ast::expr_fn_block(*) |
3195-
ast::expr_loop_body(*) |
31963195
ast::expr_do_body(*) |
31973196
ast::expr_block(*) |
31983197
ast::expr_repeat(*) |

0 commit comments

Comments
 (0)