tree-sitter / tree-sitter-rust

Rust grammar for tree-sitter
MIT License
337 stars 96 forks source link

Double cfg macro inside array isn't parsed correctly #199

Closed ThomasFrans closed 9 months ago

ThomasFrans commented 10 months ago

When you have something like the following, it isn't parsed correctly. The first cfg macro is highlighted the way normal ones are highlighted, but all the next ones in the array are incorrect.

fn foo() {
    [
        #[cfg(feature = "json")]
        "hi",
        #[cfg(feature = "yaml")]
        "bye",
    ];
}

image

amaanq commented 10 months ago

if it's an editor highlighting bug then this is the wrong repo and should be filed w the editor specific repo (neovim would be nvim-treesitter)

if the parse tree is incorrect post the code and tree

ThomasFrans commented 10 months ago

No, it's a parser issue. Here I recreated a minimal example with the tree-sitter cli tool.

Tree-sitter parser output

image

Code

fn main() {
    [
    #[cfg(linux)]
    "a",
    #[cfg(unix)]
    "b",
    ];
}
amaanq commented 9 months ago

thanks for the report, fixed now