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.
commit9753da6ab79f863e2e8a54874dd45a077e1ffb96
authorMichael Davis <mcarsondavis@gmail.com>
dateWed 20 Jul 2022, 10:51 (4 years ago)
parent791bf7e
runtime/queries/rust/locals.scm+2−1
@@ -1,6 +1,7 @@
11; Scopes
22
33(block) @local.scope
4+(closure_expression) @local.scope
45
56; Definitions
67
@@ -10,7 +11,7 @@
1011(let_declaration
1112 pattern: (identifier) @local.definition)
1213
13−(closure_parameters (identifier)) @local.definition
14+(closure_parameters (identifier) @local.definition)
1415
1516; References
1617(identifier) @local.reference