aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-30 14:05:49 +0100
committerAleksey Kladov <[email protected]>2018-08-30 14:05:49 +0100
commit7570d85869da7e2d35958047f8d1a90e3b6e2212 (patch)
tree636a6a6a42bb361aee0e46aa9a1f6f6344c69f7c
parentc2c64145cb0487b20b79d4bf470cda7e39fcb236 (diff)
loop scope
-rw-r--r--crates/libeditor/src/scope/fn_scope.rs18
1 files changed, 18 insertions, 0 deletions
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) {
180 .chain(e.expr()) 180 .chain(e.expr())
181 .for_each(|expr| compute_expr_scopes(expr, scopes, scope)); 181 .for_each(|expr| compute_expr_scopes(expr, scopes, scope));
182 } 182 }
183 ast::Expr::LoopExpr(e) => {
184 if let Some(block) = e.body() {
185 compute_block_scopes(block, scopes, scope);
186 }
187 }
183 _ => { 188 _ => {
184 expr.syntax().children() 189 expr.syntax().children()
185 .filter_map(ast::Expr::cast) 190 .filter_map(ast::Expr::cast)
@@ -255,4 +260,17 @@ mod tests {
255 &["x"], 260 &["x"],
256 ); 261 );
257 } 262 }
263
264 #[test]
265 fn test_loop_scope() {
266 do_check(r"
267 fn quux() {
268 loop {
269 let x = ();
270 <|>
271 };
272 }",
273 &["x"],
274 );
275 }
258} 276}