(struct_item
  name: (type_identifier) @name) @definition.class

(enum_item
  name: (type_identifier) @name) @definition.class

(union_item
  name: (type_identifier) @name) @definition.class

(type_item
  name: (type_identifier) @name) @definition.class

(type_parameters
  (type_parameter
    name: (type_identifier) @name)) @definition.type

(declaration_list
  (function_item
    name: (identifier) @name)) @definition.method

(function_item
  name: (identifier) @name) @definition.function

(trait_item
  name: (type_identifier) @name) @definition.interface

(mod_item
  name: (identifier) @name) @definition.module

(macro_definition
  name: (identifier) @name) @definition.macro

(use_declaration
  argument: (identifier) @name) @reference.import

(use_declaration
  argument: (scoped_identifier
    name: (identifier) @name)) @reference.import

(call_expression
  function: (identifier) @name) @reference.call

(macro_invocation
  macro: (identifier) @name) @reference.call

(impl_item
  trait: (type_identifier) @name) @reference.implementation

(impl_item
  type: (type_identifier) @name
  !trait) @reference.implementation

(type_arguments
  (type_identifier) @name) @reference.type

(generic_type
  type: (type_identifier) @name) @reference.type

[
  (binary_expression left: (identifier) @name)
  (binary_expression right: (identifier) @name)
  (unary_expression (identifier) @name)
  (return_expression (identifier) @name)
  (arguments (identifier) @name)
  (assignment_expression left: (identifier) @name)
  (let_declaration pattern: (identifier) @name)
] @reference.variable

(parameters
  (parameter
    pattern: (identifier) @name)) @definition.parameter
