Giter VIP home page Giter VIP logo

Comments (10)

lucario387 avatar lucario387 commented on June 17, 2024

Please report this to tree-sitter-rust. We don't control nor fix parser issues

from nvim-treesitter.

mkatychev avatar mkatychev commented on June 17, 2024

@lucario387 as mentioned in the Additional Context above,
this issue is not reproducible upstream.

I am using the latest parser for both the CLI and nvim-treesitter layout:

local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.rust = {
  install_info = {
    url = "https://github.com/tree-sitter/tree-sitter-rust",
    revision = "e0e8b6de6e4aa354749c794f5f36a906dcccda74",
    files = { "src/parser.c", "src/scanner.c" },
  },
}

running tree-sitter parse ./src/lib.rs on the rust file above produces this tree:

(source_file [0, 0] - [5, 0]
  (function_item [0, 0] - [3, 1]
    name: (identifier [0, 3] - [0, 7])
    parameters: (parameters [0, 7] - [0, 9])
    body: (block [0, 10] - [3, 1]
      (expression_statement [1, 4] - [1, 23]
        (macro_invocation [1, 4] - [1, 22]
          macro: (identifier [1, 4] - [1, 11])
          (token_tree [1, 12] - [1, 22]
            (string_literal [1, 13] - [1, 17])
            (identifier [1, 19] - [1, 21]))))
      (expression_statement [2, 4] - [2, 19]
        (macro_invocation [2, 4] - [2, 18]
          macro: (identifier [2, 4] - [2, 11])
          (token_tree [2, 12] - [2, 18]
            (string_literal [2, 13] - [2, 17])))))))

running vim.treesitter.inspect_tree() on the same lib.rs produces the tree below:

(function_item ; [1:1 - 4:1]
  name: (identifier) ; [1:4 - 7]
  parameters: (parameters) ; [1:8 - 9]
  body: (block ; [1:11 - 4:1]
    (expression_statement ; [2:5 - 23]
      (macro_invocation ; [2:5 - 22]
        macro: (identifier) ; [2:5 - 11]
        (token_tree ; [2:13 - 22]
          (ERROR ; [2:13 - 22]
            (unit_expression ; [2:13 - 22]
              (ERROR))) ; [2:18 - 18]
          (string_literal) ; [2:14 - 17]
          (identifier)))) ; [2:20 - 21]
    (expression_statement ; [3:5 - 19]
      (macro_invocation ; [3:5 - 18]
        macro: (identifier) ; [3:5 - 11]
        (token_tree ; [3:13 - 18]
          (ERROR ; [3:13 - 18]
            (unit_expression)) ; [3:13 - 18]
          (string_literal)))))) ; [3:14 - 17]

This is not a tree-sitter-rust problem, could we reopen this issue?

from nvim-treesitter.

clason avatar clason commented on June 17, 2024

Not here; it's a Neovim issue (if it is indeed not an upstream issue, e.g., different behaviour between lib and crate).

Also note that Neovim (nightly) uses a pre-release commit of the tree-sitter lib (in fact, the HEAD of master). Make sure you test the same commit of the CLI.

from nvim-treesitter.

mkatychev avatar mkatychev commented on June 17, 2024

@clason should I file an issue in https://github.com/neovim/neovim/ then?

from nvim-treesitter.

clason avatar clason commented on June 17, 2024

First you should test on equal footing. But if it is not an upstream issue (which I still believe is the case, since the parser output is different), neovim/neovim is the right place, yes.

But you need to verify first that this cannot be reproduced with tree-sitter HEAD and tree-sitter-rust HEAD.

(@amaanq )

from nvim-treesitter.

mkatychev avatar mkatychev commented on June 17, 2024

since the parser output is different

I don't think that they will currently match up regardless since vim.treesitter.inspect_tree() does not render the source_file top level node:

neovim/neovim#26932

from nvim-treesitter.

clason avatar clason commented on June 17, 2024

Don't think, test! (That issue is unrelated, and clearly not a relevant difference in this context.)

from nvim-treesitter.

lucario387 avatar lucario387 commented on June 17, 2024

Just woke up 😴

But I tried using upstream queries to see if it's our issue or not (tree-sitter/tree-sitter-rust@8023833)

But it doesn't seem to change anything

; fn main() {
;     println!("ok");
; }

(function_item ; [1:1 - 3:1]
  name: (identifier) ; [1:4 - 7]
  parameters: (parameters) ; [1:8 - 9]
  body: (block ; [1:11 - 3:1]
    (expression_statement ; [2:5 - 19]
      (macro_invocation ; [2:5 - 18]
        macro: (identifier) ; [2:5 - 11]
        (token_tree ; [2:13 - 18]
          (ERROR ; [2:13 - 18]
            (parenthesized_expression ; [2:13 - 18]
              (string_literal))) ; [2:14 - 17]
          (string_literal)))))) ; [2:14 - 17]

So it doesn't seem like our issue :). Either its the parser or neovim

from nvim-treesitter.

mkatychev avatar mkatychev commented on June 17, 2024

@lucario387 you are correct, I've submitted an issue in neovim:
neovim/neovim#27159

Neovim 0.8.x doesn't make the issue show up with latest nvim-treesitter checked out

from nvim-treesitter.

lucario387 avatar lucario387 commented on June 17, 2024

Not really
🤔
I figured out why

from nvim-treesitter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.