Skip to content

Commit ce80094

Browse files
committed
Make save-analysis work for if let etc.
1 parent 08f3752 commit ce80094

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/librustc_trans/save/dump_csv.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,12 +1132,20 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
11321132
// walk the body
11331133
self.nest(ex.id, |v| v.visit_block(&**body));
11341134
}
1135-
ast::ExprForLoop(ref pattern, ref subexpression, ref block, _) => {
1135+
ast::ExprForLoop(ref pattern, ref subexpression, ref block, _) |
1136+
ast::ExprWhileLet(ref pattern, ref subexpression, ref block, _) => {
11361137
let value = self.span.snippet(mk_sp(ex.span.lo, subexpression.span.hi));
11371138
self.process_var_decl(pattern, value);
11381139
visit::walk_expr(self, subexpression);
11391140
visit::walk_block(self, block);
11401141
}
1142+
ast::ExprIfLet(ref pattern, ref subexpression, ref block, ref opt_else) => {
1143+
let value = self.span.snippet(mk_sp(ex.span.lo, subexpression.span.hi));
1144+
self.process_var_decl(pattern, value);
1145+
visit::walk_expr(self, subexpression);
1146+
visit::walk_block(self, block);
1147+
opt_else.as_ref().map(|el| visit::walk_expr(self, el));
1148+
}
11411149
_ => {
11421150
visit::walk_expr(self, ex)
11431151
}

src/test/run-make/save-analysis/foo.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,27 @@ fn main() { // foo
339339
if let SomeEnum::Strings(..) = s7 {
340340
println!("hello!");
341341
}
342+
343+
for i in 0..5 {
344+
foo_foo(i);
345+
}
346+
347+
if let Some(x) = None {
348+
foo_foo(x);
349+
}
350+
351+
if false {
352+
} else if let Some(y) = None {
353+
foo_foo(y);
354+
}
355+
356+
while let Some(z) = None {
357+
foo_foo(z);
358+
}
342359
}
343360

361+
fn foo_foo(_: i32) {}
362+
344363
impl Iterator for nofields {
345364
type Item = (usize, usize);
346365

0 commit comments

Comments
 (0)