From 7570d85869da7e2d35958047f8d1a90e3b6e2212 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Aug 2018 16:05:49 +0300 Subject: loop scope --- crates/libeditor/src/scope/fn_scope.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/libeditor/src/scope/fn_scope.rs b/crates/libeditor/src/scope/fn_scope.rs index a38647c43..de38b33f0 100644 --- a/crates/libeditor/src/scope/fn_scope.rs +++ b/crates/libeditor/src/scope/fn_scope.rs @@ -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"], + ); + } } -- cgit v1.2.3