Skip to content

Conversation

wetneb
Copy link
Contributor

@wetneb wetneb commented Jun 17, 2025

This proposes to update the Rust grammar, to benefit from the following improvements:

  • fix the attachment of attributes (and doc comments) to functions (and many other types of nodes).
  • fixes the parsing of various stable language constructs
  • add support for newer language constructs (including unstable ones).

See the changelog for details about those improvements.

Those are improvements I made for mergiraf but I figured they might also be useful for difftastic, and indeed I found that this change indeed fixes #35.

Unfortunately the tree-sitter-rust maintainers rarely have capacity to review external contributions, hence it being a fork called tree-sitter-rust-orchard, which is available on crates.io. The lack of capacity to review seems to be a recurrent problem according to the PR backlog, not just a passing one, but should it change, I would of course submit my changes upstream to have them integrated there too. In the meantime, the fork welcomes contributions and co-maintainers.

@wetneb wetneb force-pushed the update_rust_parser branch from 01ab83c to 1a07299 Compare June 17, 2025 08:15
Offers better attachment of attributes and doc comments
and supports newer language constructs.
Closes Wilfred#35.
@Wilfred
Copy link
Owner

Wilfred commented Sep 16, 2025

Thanks! This largely looks good.

I noticed that block_outer_doc_comment isn't handled as a comment in this PR, but you've just fixed it: https://codeberg.org/grammar-orchard/tree-sitter-rust-orchard/commit/d52d4268f15b9c715cd52010cc909f92511610d3 :)

I did also notice that there's an unnecessary token, so I've filed https://codeberg.org/grammar-orchard/tree-sitter-rust-orchard/issues/70. I think it's harmless for difftastic, which flattens AST subtrees which are comments anyway.

@Wilfred Wilfred merged commit dc4ce18 into Wilfred:master Sep 17, 2025
15 checks passed
@Wilfred
Copy link
Owner

Wilfred commented Sep 17, 2025

I see the tests are all passing with 0.13, so merging. Thanks for the PR! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rust attribute changes are not ideally associated
2 participants