mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
remove more ExprForLoop
s
This commit is contained in:
parent
76362f0a0e
commit
acb8c1aaa6
@ -45,10 +45,6 @@ impl<'a, 'v> Visitor<'v> for CheckLoopVisitor<'a> {
|
||||
ast::ExprLoop(ref 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) => {
|
||||
self.with_context(Closure, |v| v.visit_block(&**b));
|
||||
}
|
||||
|
@ -223,19 +223,6 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
|
||||
.collect();
|
||||
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);
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
@ -701,14 +701,6 @@ fn resolve_expr(visitor: &mut RegionResolutionVisitor, expr: &ast::Expr) {
|
||||
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(..) => {
|
||||
visitor.cx.var_parent = InnermostDeclaringBlock::Match(expr.id);
|
||||
}
|
||||
|
@ -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`
|
||||
ast::ExprIndex(..) => LvalueExpr,
|
||||
|
||||
// `for` loops are statements
|
||||
ast::ExprForLoop(..) => RvalueStmtExpr,
|
||||
|
||||
// in the general case, result could be any type, use DPS
|
||||
_ => RvalueDpsExpr
|
||||
};
|
||||
|
@ -96,7 +96,7 @@ impl<'v, P> Visitor<'v> for LoopQueryVisitor<P> where P: FnMut(&ast::Expr_) -> b
|
||||
match e.node {
|
||||
// Skip inner loops, since a break in the inner loop isn't a
|
||||
// break inside the outer loop
|
||||
ast::ExprLoop(..) | ast::ExprWhile(..) | ast::ExprForLoop(..) => {}
|
||||
ast::ExprLoop(..) | ast::ExprWhile(..) => {}
|
||||
_ => visit::walk_expr(self, e)
|
||||
}
|
||||
}
|
||||
|
@ -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)) => {
|
||||
let renamed = mtwt::resolve(label);
|
||||
match self.search_label(renamed) {
|
||||
|
@ -927,13 +927,6 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
ast::ExprWhile(ref cond, ref 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, _) => {
|
||||
controlflow::trans_loop(bcx, expr, &**body)
|
||||
}
|
||||
|
@ -658,30 +658,6 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user