remove more ExprForLoops

This commit is contained in:
Jorge Aparicio 2015-01-22 18:59:00 -05:00
parent 76362f0a0e
commit acb8c1aaa6
8 changed files with 1 additions and 93 deletions

View File

@ -45,10 +45,6 @@ impl<'a, 'v> Visitor<'v> for CheckLoopVisitor<'a> {
ast::ExprLoop(ref b, _) => { ast::ExprLoop(ref b, _) => {
self.with_context(Loop, |v| v.visit_block(&**b)); self.with_context(Loop, |v| v.visit_block(&**b));
} }
ast::ExprForLoop(_, ref e, ref b, _) => {
self.visit_expr(&**e);
self.with_context(Loop, |v| v.visit_block(&**b));
}
ast::ExprClosure(_, _, _, ref b) => { ast::ExprClosure(_, _, _, ref b) => {
self.with_context(Closure, |v| v.visit_block(&**b)); self.with_context(Closure, |v| v.visit_block(&**b));
} }

View File

@ -223,19 +223,6 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
.collect(); .collect();
check_exhaustive(cx, ex.span, &matrix, source); check_exhaustive(cx, ex.span, &matrix, source);
}, },
ast::ExprForLoop(ref pat, _, _, _) => {
let mut static_inliner = StaticInliner::new(cx.tcx);
is_refutable(cx, &*static_inliner.fold_pat((*pat).clone()), |uncovered_pat| {
span_err!(cx.tcx.sess, pat.span, E0297,
"refutable pattern in `for` loop binding: \
`{}` not covered",
pat_to_string(uncovered_pat));
});
// Check legality of move bindings.
check_legality_of_move_bindings(cx, false, slice::ref_slice(pat));
check_legality_of_bindings_in_at_patterns(cx, &**pat);
}
_ => () _ => ()
} }
} }

View File

@ -701,14 +701,6 @@ fn resolve_expr(visitor: &mut RegionResolutionVisitor, expr: &ast::Expr) {
terminating(body.id); terminating(body.id);
} }
ast::ExprForLoop(ref _pat, ref _head, ref body, _) => {
terminating(body.id);
// The variable parent of everything inside (most importantly, the
// pattern) is the body.
visitor.cx.var_parent = InnermostDeclaringBlock::Block(body.id);
}
ast::ExprMatch(..) => { ast::ExprMatch(..) => {
visitor.cx.var_parent = InnermostDeclaringBlock::Match(expr.id); visitor.cx.var_parent = InnermostDeclaringBlock::Match(expr.id);
} }

View File

@ -4493,9 +4493,6 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
// the index method invoked for `a[i]` always yields an `&T` // the index method invoked for `a[i]` always yields an `&T`
ast::ExprIndex(..) => LvalueExpr, ast::ExprIndex(..) => LvalueExpr,
// `for` loops are statements
ast::ExprForLoop(..) => RvalueStmtExpr,
// in the general case, result could be any type, use DPS // in the general case, result could be any type, use DPS
_ => RvalueDpsExpr _ => RvalueDpsExpr
}; };

View File

@ -96,7 +96,7 @@ impl<'v, P> Visitor<'v> for LoopQueryVisitor<P> where P: FnMut(&ast::Expr_) -> b
match e.node { match e.node {
// Skip inner loops, since a break in the inner loop isn't a // Skip inner loops, since a break in the inner loop isn't a
// break inside the outer loop // break inside the outer loop
ast::ExprLoop(..) | ast::ExprWhile(..) | ast::ExprForLoop(..) => {} ast::ExprLoop(..) | ast::ExprWhile(..) => {}
_ => visit::walk_expr(self, e) _ => visit::walk_expr(self, e)
} }
} }

View File

@ -4562,39 +4562,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}) })
} }
ExprForLoop(ref pattern, ref head, ref body, optional_label) => {
self.resolve_expr(&**head);
self.value_ribs.push(Rib::new(NormalRibKind));
self.resolve_pattern(&**pattern,
LocalIrrefutableMode,
&mut HashMap::new());
match optional_label {
None => {}
Some(label) => {
self.label_ribs
.push(Rib::new(NormalRibKind));
let def_like = DlDef(DefLabel(expr.id));
{
let rib = self.label_ribs.last_mut().unwrap();
let renamed = mtwt::resolve(label);
rib.bindings.insert(renamed, def_like);
}
}
}
self.resolve_block(&**body);
if optional_label.is_some() {
drop(self.label_ribs.pop())
}
self.value_ribs.pop();
}
ExprBreak(Some(label)) | ExprAgain(Some(label)) => { ExprBreak(Some(label)) | ExprAgain(Some(label)) => {
let renamed = mtwt::resolve(label); let renamed = mtwt::resolve(label);
match self.search_label(renamed) { match self.search_label(renamed) {

View File

@ -927,13 +927,6 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
ast::ExprWhile(ref cond, ref body, _) => { ast::ExprWhile(ref cond, ref body, _) => {
controlflow::trans_while(bcx, expr, &**cond, &**body) controlflow::trans_while(bcx, expr, &**cond, &**body)
} }
ast::ExprForLoop(ref pat, ref head, ref body, _) => {
controlflow::trans_for(bcx,
expr_info(expr),
&**pat,
&**head,
&**body)
}
ast::ExprLoop(ref body, _) => { ast::ExprLoop(ref body, _) => {
controlflow::trans_loop(bcx, expr, &**body) controlflow::trans_loop(bcx, expr, &**body)
} }

View File

@ -658,30 +658,6 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
rcx.set_repeating_scope(repeating_scope); rcx.set_repeating_scope(repeating_scope);
} }
ast::ExprForLoop(ref pat, ref head, ref body, _) => {
constrain_bindings_in_pat(&**pat, rcx);
{
let mc = mc::MemCategorizationContext::new(rcx.fcx);
let pat_ty = rcx.resolve_node_type(pat.id);
let pat_cmt = mc.cat_rvalue(pat.id,
pat.span,
ty::ReScope(CodeExtent::from_node_id(body.id)),
pat_ty);
link_pattern(rcx, mc, pat_cmt, &**pat);
}
rcx.visit_expr(&**head);
type_of_node_must_outlive(rcx,
infer::AddrOf(expr.span),
head.id,
ty::ReScope(CodeExtent::from_node_id(expr.id)));
let repeating_scope = rcx.set_repeating_scope(body.id);
rcx.visit_block(&**body);
rcx.set_repeating_scope(repeating_scope);
}
_ => { _ => {
visit::walk_expr(rcx, expr); visit::walk_expr(rcx, expr);
} }