loop scope

This commit is contained in:
Aleksey Kladov 2018-08-30 16:05:49 +03:00
parent c2c64145cb
commit 7570d85869

View file

@ -180,6 +180,11 @@ fn compute_expr_scopes(expr: ast::Expr, scopes: &mut FnScopes, scope: ScopeId) {
.chain(e.expr())
.for_each(|expr| compute_expr_scopes(expr, scopes, scope));
}
ast::Expr::LoopExpr(e) => {
if let Some(block) = e.body() {
compute_block_scopes(block, scopes, scope);
}
}
_ => {
expr.syntax().children()
.filter_map(ast::Expr::cast)
@ -255,4 +260,17 @@ mod tests {
&["x"],
);
}
#[test]
fn test_loop_scope() {
do_check(r"
fn quux() {
loop {
let x = ();
<|>
};
}",
&["x"],
);
}
}