1
1
use std:: { fs, path:: PathBuf } ;
2
2
3
3
pub mod codegen;
4
- mod flags;
5
4
mod field_info;
5
+ mod flags;
6
6
7
7
use crate :: codegen:: grammar:: ast_src:: { AstEnumSrc , Cardinality } ;
8
8
use crate :: field_info:: { FieldInfo , FieldType } ;
@@ -77,16 +77,15 @@ fn has_special_emission(type_name: &str) -> bool {
77
77
}
78
78
79
79
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
82
81
}
83
82
84
83
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
86
85
}
87
86
88
87
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
90
89
}
91
90
92
91
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> {
166
165
"HasGenericArgs" => vec ! [ FieldInfo :: optional( "generic_arg_list" , "GenericArgList" ) ] ,
167
166
"HasTypeBounds" => vec ! [ FieldInfo :: optional( "type_bound_list" , "TypeBoundList" ) ] ,
168
167
"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
+ ] ,
172
172
"HasArgList" => vec ! [ FieldInfo :: optional( "arg_list" , "ArgList" ) ] ,
173
173
"HasDocComments" => vec ! [ ] ,
174
174
_ => panic ! ( "Unknown trait {}" , trait_name) ,
@@ -316,7 +316,7 @@ fn get_fields(node: &AstNodeSrc) -> Vec<FieldInfo> {
316
316
let mut result = Vec :: new ( ) ;
317
317
for field in & node. fields {
318
318
if let Field :: Token ( name) = field {
319
- if should_predicate_be_extracted ( & name) {
319
+ if should_predicate_be_extracted ( name) {
320
320
result. push ( FieldInfo {
321
321
name : format ! ( "is_{name}" ) ,
322
322
ty : FieldType :: Predicate ,
@@ -329,7 +329,9 @@ fn get_fields(node: &AstNodeSrc) -> Vec<FieldInfo> {
329
329
330
330
for field in & node. fields {
331
331
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
+ }
333
335
let ty = match field {
334
336
Field :: Token ( _) => continue ,
335
337
Field :: Node {
@@ -342,7 +344,7 @@ fn get_fields(node: &AstNodeSrc) -> Vec<FieldInfo> {
342
344
result. push ( FieldInfo { name, ty } ) ;
343
345
}
344
346
for trait_ in & node. traits {
345
- result. extend ( get_trait_fields ( & trait_) ) ;
347
+ result. extend ( get_trait_fields ( trait_) ) ;
346
348
}
347
349
result. sort_by ( |x, y| x. name . cmp ( & y. name ) ) ;
348
350
result
0 commit comments