From 9753da6ab79f863e2e8a54874dd45a077e1ffb96 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 20 Jul 2022 10:51:35 +0800 Subject: [PATCH] Fix locals tracking in Rust closures (#3027) The fix comes from the rewriting of the `closure_parameters` stanza: it was capturing the entire `closure_parameters` node including paretheses, whitespace, and commas. Capturing the identifiers within fixes the tracking. In order to make sure locals definitions from closure parameters don't leak out of the body of the closure, though, we should also mark the closure itself as a locals scope. --- runtime/queries/rust/locals.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/queries/rust/locals.scm b/runtime/queries/rust/locals.scm index 6428f9b4..9c85b84a 100644 --- a/runtime/queries/rust/locals.scm +++ b/runtime/queries/rust/locals.scm @@ -1,6 +1,7 @@ ; Scopes (block) @local.scope +(closure_expression) @local.scope ; Definitions @@ -10,7 +11,7 @@ (let_declaration pattern: (identifier) @local.definition) -(closure_parameters (identifier)) @local.definition +(closure_parameters (identifier) @local.definition) ; References (identifier) @local.reference