Make save-analysis work for `if let` etc.

This commit is contained in:
Nick Cameron 2015-09-30 14:56:19 +13:00
parent 08f3752270
commit ce80094632
2 changed files with 28 additions and 1 deletions

View File

@ -1132,12 +1132,20 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
// walk the body
self.nest(ex.id, |v| v.visit_block(&**body));
}
ast::ExprForLoop(ref pattern, ref subexpression, ref block, _) => {
ast::ExprForLoop(ref pattern, ref subexpression, ref block, _) |
ast::ExprWhileLet(ref pattern, ref subexpression, ref block, _) => {
let value = self.span.snippet(mk_sp(ex.span.lo, subexpression.span.hi));
self.process_var_decl(pattern, value);
visit::walk_expr(self, subexpression);
visit::walk_block(self, block);
}
ast::ExprIfLet(ref pattern, ref subexpression, ref block, ref opt_else) => {
let value = self.span.snippet(mk_sp(ex.span.lo, subexpression.span.hi));
self.process_var_decl(pattern, value);
visit::walk_expr(self, subexpression);
visit::walk_block(self, block);
opt_else.as_ref().map(|el| visit::walk_expr(self, el));
}
_ => {
visit::walk_expr(self, ex)
}

View File

@ -339,8 +339,27 @@ fn main() { // foo
if let SomeEnum::Strings(..) = s7 {
println!("hello!");
}
for i in 0..5 {
foo_foo(i);
}
if let Some(x) = None {
foo_foo(x);
}
if false {
} else if let Some(y) = None {
foo_foo(y);
}
while let Some(z) = None {
foo_foo(z);
}
}
fn foo_foo(_: i32) {}
impl Iterator for nofields {
type Item = (usize, usize);