add clearing return vars

This commit is contained in:
Jaeyong Sung 2022-03-14 00:13:57 +09:00
parent 1ad7e7097a
commit 800f66de2b
No known key found for this signature in database
GPG Key ID: 2B86898CCB2A5486

View File

@ -268,18 +268,22 @@ fn visit_stmt(&mut self, s: &'tcx Stmt<'tcx>) {
pat, init: Some(init), ..
}) => {
self.visit_pat_expr(pat, init, false);
self.ret_vars.clear();
},
StmtKind::Item(i) => {
let item = self.ty_ctx.hir().item(i);
self.visit_item(item);
self.ret_vars.clear();
},
StmtKind::Expr(e) | StmtKind::Semi(e) => {
self.visit_expr(e);
self.ret_vars.clear();
},
StmtKind::Expr(e) | StmtKind::Semi(e) => self.visit_expr(e),
StmtKind::Local(_) => {},
}
}
fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) {
debug_assert!(self.ret_vars.is_empty());
match ex.kind {
ExprKind::Array(exprs) | ExprKind::Tup(exprs) => {
self.ret_vars = exprs