tree-sitter / tree-sitter-rust

Rust grammar for tree-sitter
MIT License
350 stars 98 forks source link

feat: support macros 2.0 #235

Closed roife closed 1 month ago

roife commented 1 month ago

fix #45

This PR rename the former macro_definition (macro_rules!) to macro_rules, and reuse macro_definition for the new macro syntax.

Tests are copied from the RFC: https://github.com/rust-lang/rfcs/blob/master/text/1584-macros.md.

amaanq commented 1 month ago

The syntax is not concretely defined, and it's likely subject to change - we can add it once there is a more proper specification

roife commented 1 month ago

However, this syntax is already being widely used in rustc (for example in https://github.com/rust-lang/rust/blob/9afe7136958edaa403f0b0eb00f0353c125b7352/compiler/rustc_driver_impl/src/lib.rs). When treesit parses this file, it generates a bunch of errors, causing the entire file to fail to highlight correctly.