tree-sitter / tree-sitter-rust

Rust grammar for tree-sitter
MIT License
359 stars 101 forks source link

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

Closed ThomasFrans closed 1 year ago

ThomasFrans commented 1 year 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 1 year 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 1 year 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 1 year ago

thanks for the report, fixed now