tree-sitter / tree-sitter-rust

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

Support try blocks #133

Closed LordMZTE closed 11 months ago

LordMZTE commented 2 years ago

The nightly version of rust supports try blocks, with this sort of syntax:

let n = try {
    do_stuff();
    5
};

It is pretty much the same as unsafe blocks syntax-wise.

Using tree-sitter-rust with tree-sitter.nvim, the syntax highlighting for the code above is pretty messed up, as tree-sitter-rust doesn't understand this syntax yet.

amaanq commented 1 year ago

That's behind an unstable feature, no point adding that now.

ahlinc commented 11 months ago

For the try blocks it would be awesome to make an exception and support them. @amaanq Also it would be good to use rust-analyzer as an orient of what to support in this parser too.

amaanq commented 10 months ago

I've added support for it now, I agree adding commonly-used unstable features is nice to support (e.g. disabling auto traits, generators, try blocks, etc)