aboutsummaryrefslogtreecommitdiff
path: root/crates/libeditor/src/scope/fn_scope.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-09-02 23:51:46 +0100
committerAleksey Kladov <[email protected]>2018-09-02 23:51:46 +0100
commit23303cd0f8298c2d7b082fcb04919454c1c306ab (patch)
tree12c22fd573fb86f7718a68ec1d74eb62e401b2f6 /crates/libeditor/src/scope/fn_scope.rs
parent83e2ab434cf20313c9248fbbe7e90f65f27d31ce (diff)
match scope
Diffstat (limited to 'crates/libeditor/src/scope/fn_scope.rs')
-rw-r--r--crates/libeditor/src/scope/fn_scope.rs41
1 files changed, 27 insertions, 14 deletions
diff --git a/crates/libeditor/src/scope/fn_scope.rs b/crates/libeditor/src/scope/fn_scope.rs
index 78e9c061c..42cd71eb5 100644
--- a/crates/libeditor/src/scope/fn_scope.rs
+++ b/crates/libeditor/src/scope/fn_scope.rs
@@ -189,7 +189,20 @@ fn compute_expr_scopes(expr: ast::Expr, scopes: &mut FnScopes, scope: ScopeId) {
189 .chain(e.expr()) 189 .chain(e.expr())
190 .for_each(|expr| compute_expr_scopes(expr, scopes, scope)); 190 .for_each(|expr| compute_expr_scopes(expr, scopes, scope));
191 } 191 }
192 192 ast::Expr::MatchExpr(e) => {
193 if let Some(expr) = e.expr() {
194 compute_expr_scopes(expr, scopes, scope);
195 }
196 for arm in e.match_arm_list().into_iter().flat_map(|it| it.arms()) {
197 let scope = scopes.new_scope(scope);
198 for pat in arm.pats() {
199 scopes.add_bindings(scope, pat);
200 }
201 if let Some(expr) = arm.expr() {
202 compute_expr_scopes(expr, scopes, scope);
203 }
204 }
205 }
193 _ => { 206 _ => {
194 expr.syntax().children() 207 expr.syntax().children()
195 .filter_map(ast::Expr::cast) 208 .filter_map(ast::Expr::cast)
@@ -279,17 +292,17 @@ mod tests {
279 ); 292 );
280 } 293 }
281 294
282 // #[test] 295 #[test]
283 // fn test_match() { 296 fn test_match() {
284 // do_check(r" 297 do_check(r"
285 // fn quux() { 298 fn quux() {
286 // match () { 299 match () {
287 // Some(x) => { 300 Some(x) => {
288 // <|> 301 <|>
289 // } 302 }
290 // }; 303 };
291 // }", 304 }",
292 // &["x"], 305 &["x"],
293 // ); 306 );
294 // } 307 }
295} 308}