Skip to content

Commit 8fda879

Browse files
authored
Merge pull request #19967 from github/redsun82/format
Rust: format
2 parents a4de311 + dee1ec3 commit 8fda879

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

rust/ast-generator/src/main.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::{fs, path::PathBuf};
22

33
pub mod codegen;
4-
mod flags;
54
mod field_info;
5+
mod flags;
66

77
use crate::codegen::grammar::ast_src::{AstEnumSrc, Cardinality};
88
use crate::field_info::{FieldInfo, FieldType};
@@ -77,16 +77,15 @@ fn has_special_emission(type_name: &str) -> bool {
7777
}
7878

7979
fn should_enum_be_skipped(name: &str) -> bool {
80-
name == "VariantDef" // remove the VariantDef enum, there is no use for it at the moment
81-
80+
name == "VariantDef" // remove the VariantDef enum, there is no use for it at the moment
8281
}
8382

8483
fn should_node_be_skipped(name: &str) -> bool {
85-
name == "TypeAnchor" // we flatten TypeAnchor into PathSegment in the extractor
84+
name == "TypeAnchor" // we flatten TypeAnchor into PathSegment in the extractor
8685
}
8786

8887
fn should_node_be_skipped_in_extractor(name: &str) -> bool {
89-
name == "Adt" // no fields have `Adt` type, so we don't need extraction for it
88+
name == "Adt" // no fields have `Adt` type, so we don't need extraction for it
9089
}
9190

9291
fn should_field_be_skipped(node_name: &str, field_name: &str) -> bool {
@@ -166,9 +165,10 @@ fn get_trait_fields(trait_name: &str) -> Vec<FieldInfo> {
166165
"HasGenericArgs" => vec![FieldInfo::optional("generic_arg_list", "GenericArgList")],
167166
"HasTypeBounds" => vec![FieldInfo::optional("type_bound_list", "TypeBoundList")],
168167
"HasModuleItem" => vec![FieldInfo::list("items", "Item")],
169-
"HasLoopBody" =>
170-
vec![FieldInfo::optional("label", "Label"),
171-
FieldInfo::optional("loop_body", "BlockExpr")],
168+
"HasLoopBody" => vec![
169+
FieldInfo::optional("label", "Label"),
170+
FieldInfo::optional("loop_body", "BlockExpr"),
171+
],
172172
"HasArgList" => vec![FieldInfo::optional("arg_list", "ArgList")],
173173
"HasDocComments" => vec![],
174174
_ => panic!("Unknown trait {}", trait_name),
@@ -316,7 +316,7 @@ fn get_fields(node: &AstNodeSrc) -> Vec<FieldInfo> {
316316
let mut result = Vec::new();
317317
for field in &node.fields {
318318
if let Field::Token(name) = field {
319-
if should_predicate_be_extracted(&name) {
319+
if should_predicate_be_extracted(name) {
320320
result.push(FieldInfo {
321321
name: format!("is_{name}"),
322322
ty: FieldType::Predicate,
@@ -329,7 +329,9 @@ fn get_fields(node: &AstNodeSrc) -> Vec<FieldInfo> {
329329

330330
for field in &node.fields {
331331
let name = field.method_name();
332-
if should_field_be_skipped(&node.name, &name) { continue; }
332+
if should_field_be_skipped(&node.name, &name) {
333+
continue;
334+
}
333335
let ty = match field {
334336
Field::Token(_) => continue,
335337
Field::Node {
@@ -342,7 +344,7 @@ fn get_fields(node: &AstNodeSrc) -> Vec<FieldInfo> {
342344
result.push(FieldInfo { name, ty });
343345
}
344346
for trait_ in &node.traits {
345-
result.extend(get_trait_fields(&trait_));
347+
result.extend(get_trait_fields(trait_));
346348
}
347349
result.sort_by(|x, y| x.name.cmp(&y.name));
348350
result

0 commit comments

Comments
 (0)