@willbooster/tree-sitter-rust 9.0.0 → 10.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -71,10 +71,9 @@ In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-
71
71
  fuzzed with. The parser requires version 7.0.5 or later within major version 7 of that runtime; upstream's
72
72
  `tree-sitter` crate rejects it:
73
73
 
74
- ```toml
75
- [dependencies]
76
- tree-sitter = { package = "willbooster-tree-sitter", version = "7.0.5" }
77
- tree-sitter-rust = { package = "willbooster-tree-sitter-rust", version = "9" }
74
+ ```sh
75
+ cargo add willbooster-tree-sitter@7.0.5 --rename tree-sitter
76
+ cargo add willbooster-tree-sitter-rust --rename tree-sitter-rust
78
77
  ```
79
78
 
80
79
  ```rust
@@ -82,6 +81,13 @@ let mut parser = tree_sitter::Parser::new();
82
81
  parser.set_language(&tree_sitter_rust::LANGUAGE.into())?;
83
82
  ```
84
83
 
84
+ ## Box patterns
85
+
86
+ `box_pattern` exposes its operand through the `pattern` field, including anonymous `_` patterns.
87
+ Nested `box` patterns produce nested nodes; `box 6 | box 7` produces two boxed alternatives.
88
+ The `box` keyword is an anonymous token, including inside macro token trees; `r#box` remains an identifier.
89
+ The grammar parses this feature-gated syntax without evaluating Rust's feature attributes.
90
+
85
91
  ## Macros
86
92
 
87
93
  A macro definition's anonymous `macro_rules!` node covers the `macro_rules` keyword. The `!` is a separate
package/grammar.js CHANGED
@@ -384,6 +384,7 @@ module.exports = grammar({
384
384
  'async',
385
385
  'await',
386
386
  'become',
387
+ 'box',
387
388
  'break',
388
389
  'const',
389
390
  'continue',
@@ -1413,9 +1414,11 @@ module.exports = grammar({
1413
1414
 
1414
1415
  label: ($) => seq("'", $.identifier),
1415
1416
 
1416
- break_expression: ($) => prec.left(seq('break', optional($.label), optional($._expression))),
1417
+ break_expression: ($) => prec.left(seq($._break_expression_head, optional($._expression))),
1417
1418
 
1418
- continue_expression: ($) => prec.left(seq('continue', optional($.label))),
1419
+ _break_expression_head: ($) => prec.right(seq('break', optional($.label))),
1420
+
1421
+ continue_expression: ($) => prec.right(seq('continue', optional($.label))),
1419
1422
 
1420
1423
  index_expression: ($) => prec(PREC.call, seq($._expression, '[', $._expression, ']')),
1421
1424
 
@@ -1461,6 +1464,7 @@ module.exports = grammar({
1461
1464
  $.struct_pattern,
1462
1465
  $._reserved_identifier,
1463
1466
  $.ref_pattern,
1467
+ $.box_pattern,
1464
1468
  $.slice_pattern,
1465
1469
  $.captured_pattern,
1466
1470
  $.reference_pattern,
@@ -1577,6 +1581,8 @@ module.exports = grammar({
1577
1581
 
1578
1582
  ref_pattern: ($) => seq('ref', $._pattern),
1579
1583
 
1584
+ box_pattern: ($) => seq('box', field('pattern', $._pattern)),
1585
+
1580
1586
  captured_pattern: ($) =>
1581
1587
  seq(
1582
1588
  choice($.identifier, $._reserved_identifier, alias(choice(...primitiveTypes), $.identifier)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-rust",
3
- "version": "9.0.0",
3
+ "version": "10.0.1",
4
4
  "description": "Rust grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -101,6 +101,7 @@
101
101
  "auto" @keyword
102
102
  "await" @keyword
103
103
  "become" @keyword
104
+ "box" @keyword
104
105
  "break" @keyword
105
106
  "const" @keyword
106
107
  "continue" @keyword
@@ -347,6 +347,10 @@
347
347
  "type": "_literal_pattern",
348
348
  "named": true
349
349
  },
350
+ {
351
+ "type": "box_pattern",
352
+ "named": true
353
+ },
350
354
  {
351
355
  "type": "captured_pattern",
352
356
  "named": true
@@ -1163,6 +1167,22 @@
1163
1167
  ]
1164
1168
  }
1165
1169
  },
1170
+ {
1171
+ "type": "box_pattern",
1172
+ "named": true,
1173
+ "fields": {
1174
+ "pattern": {
1175
+ "multiple": false,
1176
+ "required": true,
1177
+ "types": [
1178
+ {
1179
+ "type": "_pattern",
1180
+ "named": true
1181
+ }
1182
+ ]
1183
+ }
1184
+ }
1185
+ },
1166
1186
  {
1167
1187
  "type": "bracketed_type",
1168
1188
  "named": true,
@@ -5723,6 +5743,10 @@
5723
5743
  "type": "block",
5724
5744
  "named": false
5725
5745
  },
5746
+ {
5747
+ "type": "box",
5748
+ "named": false
5749
+ },
5726
5750
  {
5727
5751
  "type": "break",
5728
5752
  "named": false
Binary file
package/tree-sitter.json CHANGED
@@ -25,7 +25,7 @@
25
25
  }
26
26
  ],
27
27
  "metadata": {
28
- "version": "9.0.0",
28
+ "version": "10.0.1",
29
29
  "license": "MIT",
30
30
  "description": "Rust grammar for tree-sitter",
31
31
  "authors": [