Skip to content

Rust: move body skipping logic to code generation #19559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rust: minor refactoring
  • Loading branch information
Paolo Tranquilli committed May 26, 2025
commit e37a24a0d0c58e3ba97c07e1a4ace64577b0c5d3
11 changes: 5 additions & 6 deletions rust/ast-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ fn get_additional_fields(node: &AstNodeSrc) -> Vec<FieldInfo> {
"Fn" => vec![FieldInfo::body("body", "BlockExpr")],
"Const" => vec![FieldInfo::body("body", "Expr")],
"Static" => vec![FieldInfo::body("body", "Expr")],
"Param" => vec![FieldInfo::body("pat", "Pat")],
"ClosureExpr" => vec![FieldInfo::optional("body", "Expr")],
"ArrayExpr" => vec![FieldInfo::predicate("is_semicolon")],
"SelfParam" => vec![FieldInfo::predicate("is_amp")],
Expand Down Expand Up @@ -290,14 +291,12 @@ fn get_fields(node: &AstNodeSrc) -> Vec<FieldInfo> {
result.extend(get_additional_fields(node));

for field in &node.fields {
match (node.name.as_str(), field.method_name().as_str()) {
let name = field.method_name();
match (node.name.as_str(), name.as_str()) {
("ArrayExpr", "expr") // The ArrayExpr type also has an 'exprs' field
| ("PathSegment", "ty" | "path_type") // these are broken, handling them manually
| ("Param", "pat") // handled manually to use `body`
=> continue,
("Param", "pat") => {
result.push(FieldInfo::body("pat", "Pat"));
continue;
},
_ => {}
}
let ty = match field {
Expand All @@ -310,7 +309,7 @@ fn get_fields(node: &AstNodeSrc) -> Vec<FieldInfo> {
},
};
result.push(FieldInfo {
name: field.method_name(),
name,
ty,
});
}
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy