Skip to content

Don't discard non-special tokens in macro invocations #119

@Wilfred

Description

@Wilfred
vec![Foo::bar()];
baz![?];

The :: and ? are not included in the syntax tree. I think this is because _non_special_token is matching these with a regular expression, unlike e.g. as.

tree-sitter-rust/grammar.js

Lines 193 to 198 in cc7bdd3

_non_special_token: $ => choice(
$._literal, $.identifier, $.metavariable, $.mutable_specifier, $.self, $.super, $.crate,
alias(choice(...primitive_types), $.primitive_type),
/[/_\-=->,;:::!=?.@*&#%^+<>|~]+/,
'\'',
'as', 'async', 'await', 'break', 'const', 'continue', 'default', 'enum', 'fn', 'for', 'if', 'impl',

This is causing issues for difftastic, where Foo::bar() preserves the :: but vec![Foo::bar()] does not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions