github-linguist / linguist

Language Savant. If your repository's language is being reported incorrectly, send us a pull request!
MIT License
12.23k stars 4.23k forks source link

Rust grammar repo is unmaintained #5965

Closed workingjubilee closed 2 years ago

workingjubilee commented 2 years ago

Describe the bug

Screenshot 2022-07-05, a comment on "Add triggers" by Hoverbear, Pull Request #51 for the plrust repo, consisting of Jubilee remarking "Why does GitHub highlight this so oddly?" on text within a function invocation inside a proc macro

Hello!

This screenshot features a string being highlighted using the same color as for function highlighting. These are normally highlighted very differently. I believe I understand the cause, however.

The Atom project is being sunsetted, and the associated Atom-derived syntax highlighting for Rust has had the repo archived and no longer maintained for some 3 years now, at least. Since it was last in regular maintenance, some subtle changes to Rust syntax have emerged in Edition 2021, and some interesting cases that it was not prepared for, like this macro syntactic embedding, have emerged in the language.

Expected behaviour

I expected this string to be highlighted like a string, not like a function.

Additional notes

There is a tree-sitter grammar for Rust, and I see tree-sitter is used elsewhere in this repo, so perhaps that can be used here? I am not aware of how annoying that would be. The rust-analyzer extension is generally the most up to date and can provide quite a lot of syntactic and semantic analysis power for Rust, but it is meant to be used as a full-blown language server. Seems slightly overkill.

TheWitheredStriker commented 2 years ago

There exist some other grammar files for Rust on GitHub, like these two (both have a compatible MIT license and are actively maintained). Though, I'm not immediately sure what the best course of action is. I'll leave that up to you guys.

lildude commented 2 years ago

The use of treesitter grammars is independent of Linguist and would need a change in the syntax highlighting engine. We can however switch to one of the other TextMate compatible grammars in the mean time.

Of the two, https://github.com/dustypomerleau/rust-syntax looks to have been the most recently updated so we can start there.

lildude commented 2 years ago

🤔 Where and when did you see the syntax highlighting in your screenshot?

I ask as it doesn't look like that right now:

    Box<dyn std::error::Error>,
  > #user_code
})
.wrap_err("Parsing generated user trigger")?;

Maybe we won't need to change the grammar right now after all.

lildude commented 2 years ago

Nothing to do here now as the upstream highlighting engine now implements the treesitter Rust grammar. Closing.