tree-sitter / tree-sitter-rust

Rust grammar for tree-sitter
MIT License
340 stars 97 forks source link

Some code is not highlighted correctly #149

Closed jorendorff closed 2 years ago

jorendorff commented 2 years ago

Some folks noticed that GitHub's code highlighting for Rust recently regressed. Some examples are

The cause of the regression is that GitHub recently switched from Linguist to tree-sitter-rust for Rust code highlighting.

The first bug is a one-liner in queries/highlights.scm. The second bug is more complicated. Part of it is due to handling (identifier) and (scoped_identifier) but not (type_identifier) and (scoped_type_identifier), but after that, it's probably impossible to distinguish names of struct-like enum variants from names of structs in (struct_pattern) using this pattern language. So whether we highlight them as enum variants (which would be correct in this example) or as type names, we'll be wrong sometimes.

aDotInTheVoid commented 2 years ago

For future reference, here's what these look like now:

The first example from the above text, with async not hilighed The second exaple, with both match arms hilighed differently

maxbrunsfeld commented 2 years ago

/cc @patrickt @dcreager