Skip to content

Commit

Permalink
Fix locals tracking in Rust closures (#3027)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
the-mikedavis authored Jul 20, 2022
1 parent 791bf7e commit 9753da6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion runtime/queries/rust/locals.scm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
; Scopes

(block) @local.scope
(closure_expression) @local.scope

; Definitions

Expand All @@ -10,7 +11,7 @@
(let_declaration
pattern: (identifier) @local.definition)

(closure_parameters (identifier)) @local.definition
(closure_parameters (identifier) @local.definition)

; References
(identifier) @local.reference
Expand Down

0 comments on commit 9753da6

Please sign in to comment.