Skip to content

Commit 5f76c94

Browse files
committed
Rust: update rust-analyzer source and run codegen
1 parent 1234471 commit 5f76c94

File tree

92 files changed

+2866
-1020
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+2866
-1020
lines changed

MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ use_repo(
159159
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
160160

161161
# rust-analyzer sources needed by the rust ast-generator (see `rust/ast-generator/README.md`)
162-
RUST_ANALYZER_SRC_TAG = "2025-01-07"
162+
RUST_ANALYZER_SRC_TAG = "2026-04-13"
163163

164164
http_archive(
165165
name = "rust-analyzer-src",
166166
build_file = "//rust/ast-generator:BUILD.rust-analyzer-src.bazel",
167-
integrity = "sha256-eo8mIaUafZL8LOM65bDIIIXw1rNQ/P/x5RK/XUtgo5g=",
167+
integrity = "sha256-UB/+EVx/6j4VGvnb7jfRqPaoc7Uwci3rEt6il+2J1Ds=",
168168
patch_args = ["-p1"],
169169
patches = [
170170
"//rust/ast-generator:patches/rust-analyzer.patch",

rust/ast-generator/patches/rust-analyzer.patch

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/xtask/src/codegen/grammar.rs b/xtask/src/codegen/grammar.rs
2-
index e7534582f2..49c96f1be3 100644
2+
index 257429c..ddbe321 100644
33
--- a/xtask/src/codegen/grammar.rs
44
+++ b/xtask/src/codegen/grammar.rs
55
@@ -3,7 +3,9 @@
@@ -22,7 +22,7 @@ index e7534582f2..49c96f1be3 100644
2222
use self::ast_src::{AstEnumSrc, AstNodeSrc, AstSrc, Cardinality, Field, KindsSrc};
2323

2424
pub(crate) fn generate(check: bool) {
25-
@@ -624,7 +626,7 @@ fn pluralize(s: &str) -> String {
25+
@@ -775,7 +777,7 @@ fn pluralize(s: &str) -> String {
2626
}
2727

2828
impl Field {
@@ -31,26 +31,26 @@ index e7534582f2..49c96f1be3 100644
3131
matches!(self, Field::Node { cardinality: Cardinality::Many, .. })
3232
}
3333
fn token_kind(&self) -> Option<proc_macro2::TokenStream> {
34-
@@ -636,7 +638,7 @@ impl Field {
34+
@@ -787,7 +789,7 @@ impl Field {
3535
_ => None,
3636
}
3737
}
3838
- fn method_name(&self) -> String {
3939
+ pub fn method_name(&self) -> String {
4040
match self {
41-
Field::Token(name) => {
42-
let name = match name.as_str() {
43-
@@ -682,7 +684,7 @@ impl Field {
41+
Field::Token { name, token, .. } => {
42+
if let Some(name) = name {
43+
@@ -836,7 +838,7 @@ impl Field {
4444
}
4545
}
4646
}
4747
- fn ty(&self) -> proc_macro2::Ident {
4848
+ pub fn ty(&self) -> proc_macro2::Ident {
4949
match self {
50-
Field::Token(_) => format_ident!("SyntaxToken"),
50+
Field::Token { .. } => format_ident!("SyntaxToken"),
5151
Field::Node { ty, .. } => format_ident!("{}", ty),
52-
@@ -699,7 +701,7 @@ fn clean_token_name(name: &str) -> String {
53-
}
52+
@@ -849,7 +851,7 @@ fn clean_token_name(name: &str) -> String {
53+
if cleaned.is_empty() { name.to_owned() } else { cleaned.to_owned() }
5454
}
5555

5656
-fn lower(grammar: &Grammar) -> AstSrc {
@@ -59,7 +59,7 @@ index e7534582f2..49c96f1be3 100644
5959
tokens:
6060
"Whitespace Comment String ByteString CString IntNumber FloatNumber Char Byte Ident"
6161
diff --git a/xtask/src/codegen/grammar/ast_src.rs b/xtask/src/codegen/grammar/ast_src.rs
62-
index 9269d15423..babe7ca1bf 100644
62+
index a0abdf0..5f59f97 100644
6363
--- a/xtask/src/codegen/grammar/ast_src.rs
6464
+++ b/xtask/src/codegen/grammar/ast_src.rs
6565
@@ -1,5 +1,8 @@

rust/ast-generator/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,10 @@ fn write_schema(
308308
fn get_fields(node: &AstNodeSrc) -> Vec<FieldInfo> {
309309
let mut result = Vec::new();
310310
for field in &node.fields {
311-
if let Field::Token(name) = field {
312-
if should_predicate_be_extracted(name) {
311+
if let Field::Token { token, .. } = field {
312+
if should_predicate_be_extracted(token) {
313313
result.push(FieldInfo {
314-
name: format!("is_{name}"),
314+
name: format!("is_{token}"),
315315
ty: FieldType::Predicate,
316316
});
317317
}
@@ -326,7 +326,7 @@ fn get_fields(node: &AstNodeSrc) -> Vec<FieldInfo> {
326326
continue;
327327
}
328328
let ty = match field {
329-
Field::Token(_) => continue,
329+
Field::Token { .. } => continue,
330330
Field::Node {
331331
ty, cardinality, ..
332332
} => match cardinality {

rust/extractor/src/generated/.generated.list

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)