Skip to content

Commit acb8c1a

Browse files
author
Jorge Aparicio
committed
remove more ExprForLoops
1 parent 76362f0 commit acb8c1a

File tree

8 files changed

+1
-93
lines changed

8 files changed

+1
-93
lines changed

src/librustc/middle/check_loop.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ impl<'a, 'v> Visitor<'v> for CheckLoopVisitor<'a> {
4545
ast::ExprLoop(ref b, _) => {
4646
self.with_context(Loop, |v| v.visit_block(&**b));
4747
}
48-
ast::ExprForLoop(_, ref e, ref b, _) => {
49-
self.visit_expr(&**e);
50-
self.with_context(Loop, |v| v.visit_block(&**b));
51-
}
5248
ast::ExprClosure(_, _, _, ref b) => {
5349
self.with_context(Closure, |v| v.visit_block(&**b));
5450
}

src/librustc/middle/check_match.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -223,19 +223,6 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
223223
.collect();
224224
check_exhaustive(cx, ex.span, &matrix, source);
225225
},
226-
ast::ExprForLoop(ref pat, _, _, _) => {
227-
let mut static_inliner = StaticInliner::new(cx.tcx);
228-
is_refutable(cx, &*static_inliner.fold_pat((*pat).clone()), |uncovered_pat| {
229-
span_err!(cx.tcx.sess, pat.span, E0297,
230-
"refutable pattern in `for` loop binding: \
231-
`{}` not covered",
232-
pat_to_string(uncovered_pat));
233-
});
234-
235-
// Check legality of move bindings.
236-
check_legality_of_move_bindings(cx, false, slice::ref_slice(pat));
237-
check_legality_of_bindings_in_at_patterns(cx, &**pat);
238-
}
239226
_ => ()
240227
}
241228
}

src/librustc/middle/region.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -701,14 +701,6 @@ fn resolve_expr(visitor: &mut RegionResolutionVisitor, expr: &ast::Expr) {
701701
terminating(body.id);
702702
}
703703

704-
ast::ExprForLoop(ref _pat, ref _head, ref body, _) => {
705-
terminating(body.id);
706-
707-
// The variable parent of everything inside (most importantly, the
708-
// pattern) is the body.
709-
visitor.cx.var_parent = InnermostDeclaringBlock::Block(body.id);
710-
}
711-
712704
ast::ExprMatch(..) => {
713705
visitor.cx.var_parent = InnermostDeclaringBlock::Match(expr.id);
714706
}

src/librustc/middle/ty.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4493,9 +4493,6 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
44934493
// the index method invoked for `a[i]` always yields an `&T`
44944494
ast::ExprIndex(..) => LvalueExpr,
44954495

4496-
// `for` loops are statements
4497-
ast::ExprForLoop(..) => RvalueStmtExpr,
4498-
44994496
// in the general case, result could be any type, use DPS
45004497
_ => RvalueDpsExpr
45014498
};

src/librustc/util/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl<'v, P> Visitor<'v> for LoopQueryVisitor<P> where P: FnMut(&ast::Expr_) -> b
9696
match e.node {
9797
// Skip inner loops, since a break in the inner loop isn't a
9898
// break inside the outer loop
99-
ast::ExprLoop(..) | ast::ExprWhile(..) | ast::ExprForLoop(..) => {}
99+
ast::ExprLoop(..) | ast::ExprWhile(..) => {}
100100
_ => visit::walk_expr(self, e)
101101
}
102102
}

src/librustc_resolve/lib.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4562,39 +4562,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
45624562
})
45634563
}
45644564

4565-
ExprForLoop(ref pattern, ref head, ref body, optional_label) => {
4566-
self.resolve_expr(&**head);
4567-
4568-
self.value_ribs.push(Rib::new(NormalRibKind));
4569-
4570-
self.resolve_pattern(&**pattern,
4571-
LocalIrrefutableMode,
4572-
&mut HashMap::new());
4573-
4574-
match optional_label {
4575-
None => {}
4576-
Some(label) => {
4577-
self.label_ribs
4578-
.push(Rib::new(NormalRibKind));
4579-
let def_like = DlDef(DefLabel(expr.id));
4580-
4581-
{
4582-
let rib = self.label_ribs.last_mut().unwrap();
4583-
let renamed = mtwt::resolve(label);
4584-
rib.bindings.insert(renamed, def_like);
4585-
}
4586-
}
4587-
}
4588-
4589-
self.resolve_block(&**body);
4590-
4591-
if optional_label.is_some() {
4592-
drop(self.label_ribs.pop())
4593-
}
4594-
4595-
self.value_ribs.pop();
4596-
}
4597-
45984565
ExprBreak(Some(label)) | ExprAgain(Some(label)) => {
45994566
let renamed = mtwt::resolve(label);
46004567
match self.search_label(renamed) {

src/librustc_trans/trans/expr.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -927,13 +927,6 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
927927
ast::ExprWhile(ref cond, ref body, _) => {
928928
controlflow::trans_while(bcx, expr, &**cond, &**body)
929929
}
930-
ast::ExprForLoop(ref pat, ref head, ref body, _) => {
931-
controlflow::trans_for(bcx,
932-
expr_info(expr),
933-
&**pat,
934-
&**head,
935-
&**body)
936-
}
937930
ast::ExprLoop(ref body, _) => {
938931
controlflow::trans_loop(bcx, expr, &**body)
939932
}

src/librustc_typeck/check/regionck.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -658,30 +658,6 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
658658
rcx.set_repeating_scope(repeating_scope);
659659
}
660660

661-
ast::ExprForLoop(ref pat, ref head, ref body, _) => {
662-
constrain_bindings_in_pat(&**pat, rcx);
663-
664-
{
665-
let mc = mc::MemCategorizationContext::new(rcx.fcx);
666-
let pat_ty = rcx.resolve_node_type(pat.id);
667-
let pat_cmt = mc.cat_rvalue(pat.id,
668-
pat.span,
669-
ty::ReScope(CodeExtent::from_node_id(body.id)),
670-
pat_ty);
671-
link_pattern(rcx, mc, pat_cmt, &**pat);
672-
}
673-
674-
rcx.visit_expr(&**head);
675-
type_of_node_must_outlive(rcx,
676-
infer::AddrOf(expr.span),
677-
head.id,
678-
ty::ReScope(CodeExtent::from_node_id(expr.id)));
679-
680-
let repeating_scope = rcx.set_repeating_scope(body.id);
681-
rcx.visit_block(&**body);
682-
rcx.set_repeating_scope(repeating_scope);
683-
}
684-
685661
_ => {
686662
visit::walk_expr(rcx, expr);
687663
}

0 commit comments

Comments
 (0)