2021-09-06 17:13:52 +08:00
|
|
|
; Scopes
|
|
|
|
|
2022-08-06 18:58:06 +08:00
|
|
|
[
|
|
|
|
(function_item)
|
2023-11-04 05:21:01 +08:00
|
|
|
(struct_item)
|
|
|
|
(enum_item)
|
|
|
|
(union_item)
|
|
|
|
(type_item)
|
|
|
|
(trait_item)
|
|
|
|
(impl_item)
|
2022-08-06 18:58:06 +08:00
|
|
|
(closure_expression)
|
|
|
|
(block)
|
|
|
|
] @local.scope
|
2021-09-06 17:13:52 +08:00
|
|
|
|
2025-07-14 09:28:50 +08:00
|
|
|
; Parameters
|
2021-09-06 17:13:52 +08:00
|
|
|
|
|
|
|
(parameter
|
2025-07-12 22:09:41 +08:00
|
|
|
pattern: [
|
|
|
|
; `foo` in `fn x(foo: !) {}`
|
|
|
|
(identifier) @local.definition.variable.parameter @variable.parameter
|
|
|
|
; `foo` and `bar` in `fn x((foo, bar): !) {}`
|
|
|
|
(tuple_pattern (identifier)* (identifier) @local.definition.variable.parameter @variable.parameter)
|
|
|
|
; `foo` and `bar` in `fn x(Struct { foo, bar }: !) {}`
|
|
|
|
(struct_pattern
|
|
|
|
(field_pattern)*
|
|
|
|
(field_pattern
|
|
|
|
name: (shorthand_field_identifier) @local.definition.variable.parameter @variable.parameter)
|
|
|
|
)
|
|
|
|
; `foo` and `bar` in `fn x(TupleStruct(foo, bar): !) {}`
|
|
|
|
(tuple_struct_pattern
|
|
|
|
type: _
|
|
|
|
(identifier)*
|
|
|
|
(identifier) @local.definition.variable.parameter @variable.parameter
|
|
|
|
)
|
|
|
|
; `foo` and `bar` in `fn x([foo, bar]: !) {}`
|
|
|
|
(slice_pattern
|
|
|
|
(identifier)*
|
|
|
|
(identifier) @local.definition.variable.parameter @variable.parameter
|
|
|
|
)
|
|
|
|
])
|
2021-09-06 17:13:52 +08:00
|
|
|
|
2025-07-14 09:28:50 +08:00
|
|
|
; Mutable variables
|
|
|
|
|
|
|
|
[
|
|
|
|
(let_declaration
|
|
|
|
(mutable_specifier)
|
|
|
|
pattern: (identifier) @local.definition.variable.mutable @variable.mutable)
|
|
|
|
(parameter
|
|
|
|
(mutable_specifier)
|
|
|
|
pattern: (identifier) @local.definition.variable.mutable @variable.mutable)
|
|
|
|
(mut_pattern
|
|
|
|
(mutable_specifier)
|
|
|
|
(identifier) @local.definition.variable.mutable @variable.mutable)
|
|
|
|
]
|
|
|
|
|
2021-09-06 17:13:52 +08:00
|
|
|
; References
|
|
|
|
(identifier) @local.reference
|