rust-code-analysis-code-split 0.0.26-cs.0

Fork of mozilla/rust-code-analysis bumped to tree-sitter 0.26 for use by code-split. Computes complexity metrics (cyclomatic, cognitive, Halstead, MI, LOC).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
// Code generated; DO NOT EDIT.

use num_derive::FromPrimitive;

#[derive(Clone, Debug, PartialEq, Eq, FromPrimitive)]
pub enum Rust {
    End = 0,
    Identifier = 1,
    SEMI = 2,
    MacroRulesBANG = 3,
    LPAREN = 4,
    RPAREN = 5,
    LBRACK = 6,
    RBRACK = 7,
    LBRACE = 8,
    RBRACE = 9,
    EQGT = 10,
    COLON = 11,
    DOLLAR = 12,
    TokenRepetitionPatternToken1 = 13,
    PLUS = 14,
    STAR = 15,
    QMARK = 16,
    Block2 = 17,
    Expr = 18,
    Ident = 19,
    Item = 20,
    Lifetime2 = 21,
    Literal = 22,
    Meta = 23,
    Pat = 24,
    Path = 25,
    Stmt = 26,
    Tt = 27,
    Ty = 28,
    Vis = 29,
    PrimitiveType = 30,
    PrimitiveType2 = 31,
    PrimitiveType3 = 32,
    PrimitiveType4 = 33,
    PrimitiveType5 = 34,
    PrimitiveType6 = 35,
    PrimitiveType7 = 36,
    PrimitiveType8 = 37,
    PrimitiveType9 = 38,
    PrimitiveType10 = 39,
    PrimitiveType11 = 40,
    PrimitiveType12 = 41,
    PrimitiveType13 = 42,
    PrimitiveType14 = 43,
    PrimitiveType15 = 44,
    PrimitiveType16 = 45,
    PrimitiveType17 = 46,
    DASH = 47,
    SLASH = 48,
    PERCENT = 49,
    CARET = 50,
    BANG = 51,
    AMP = 52,
    PIPE = 53,
    AMPAMP = 54,
    PIPEPIPE = 55,
    LTLT = 56,
    GTGT = 57,
    PLUSEQ = 58,
    DASHEQ = 59,
    STAREQ = 60,
    SLASHEQ = 61,
    PERCENTEQ = 62,
    CARETEQ = 63,
    AMPEQ = 64,
    PIPEEQ = 65,
    LTLTEQ = 66,
    GTGTEQ = 67,
    EQ = 68,
    EQEQ = 69,
    BANGEQ = 70,
    GT = 71,
    LT = 72,
    GTEQ = 73,
    LTEQ = 74,
    AT = 75,
    UNDERSCORE = 76,
    DOT = 77,
    DOTDOT = 78,
    DOTDOTDOT = 79,
    DOTDOTEQ = 80,
    COMMA = 81,
    COLONCOLON = 82,
    DASHGT = 83,
    HASH = 84,
    SQUOTE = 85,
    As = 86,
    Async = 87,
    Await = 88,
    Break = 89,
    Const = 90,
    Continue = 91,
    Default = 92,
    Enum = 93,
    Fn = 94,
    For = 95,
    Gen = 96,
    If = 97,
    Impl = 98,
    Let = 99,
    Loop = 100,
    Match = 101,
    Mod = 102,
    Pub = 103,
    Return = 104,
    Static = 105,
    Struct = 106,
    Trait = 107,
    Type = 108,
    Union = 109,
    Unsafe = 110,
    Use = 111,
    Where = 112,
    While = 113,
    Extern = 114,
    Ref = 115,
    Else = 116,
    In = 117,
    LT2 = 118,
    Dyn = 119,
    MutableSpecifier = 120,
    Raw = 121,
    Yield = 122,
    Move = 123,
    Try = 124,
    IntegerLiteral = 125,
    DQUOTE = 126,
    DQUOTE2 = 127,
    CharLiteral = 128,
    EscapeSequence = 129,
    True = 130,
    False = 131,
    SLASHSLASH = 132,
    LineCommentToken1 = 133,
    LineCommentToken2 = 134,
    LineCommentToken3 = 135,
    BANG2 = 136,
    SLASH2 = 137,
    SLASHSTAR = 138,
    STARSLASH = 139,
    Shebang = 140,
    Zelf = 141,
    Super = 142,
    Crate = 143,
    Metavariable = 144,
    StringContent = 145,
    RawStringLiteralStart = 146,
    StringContent2 = 147,
    RawStringLiteralEnd = 148,
    FloatLiteral = 149,
    OuterDocCommentMarker = 150,
    InnerDocCommentMarker = 151,
    BlockCommentContent = 152,
    DocComment = 153,
    ErrorSentinel = 154,
    SourceFile = 155,
    Statement = 156,
    EmptyStatement = 157,
    ExpressionStatement = 158,
    MacroDefinition = 159,
    MacroRule = 160,
    TokenPattern = 161,
    TokenTreePattern = 162,
    TokenBindingPattern = 163,
    TokenRepetitionPattern = 164,
    FragmentSpecifier = 165,
    TokenTree = 166,
    TokenRepetition = 167,
    AttributeItem = 168,
    InnerAttributeItem = 169,
    Attribute = 170,
    ModItem = 171,
    ForeignModItem = 172,
    DeclarationList = 173,
    StructItem = 174,
    UnionItem = 175,
    EnumItem = 176,
    EnumVariantList = 177,
    EnumVariant = 178,
    FieldDeclarationList = 179,
    FieldDeclaration = 180,
    OrderedFieldDeclarationList = 181,
    ExternCrateDeclaration = 182,
    ConstItem = 183,
    StaticItem = 184,
    TypeItem = 185,
    FunctionItem = 186,
    FunctionSignatureItem = 187,
    FunctionModifiers = 188,
    WhereClause = 189,
    WherePredicate = 190,
    ImplItem = 191,
    TraitItem = 192,
    AssociatedType = 193,
    TraitBounds = 194,
    HigherRankedTraitBound = 195,
    RemovedTraitBound = 196,
    TypeParameters = 197,
    ConstParameter = 198,
    ConstrainedTypeParameter = 199,
    OptionalTypeParameter = 200,
    LetDeclaration = 201,
    UseDeclaration = 202,
    UseClause = 203,
    ScopedUseList = 204,
    UseList = 205,
    UseAsClause = 206,
    UseWildcard = 207,
    Parameters = 208,
    SelfParameter = 209,
    VariadicParameter = 210,
    Parameter = 211,
    ExternModifier = 212,
    VisibilityModifier = 213,
    Type2 = 214,
    BracketedType = 215,
    QualifiedType = 216,
    Lifetime = 217,
    ArrayType = 218,
    ForLifetimes = 219,
    FunctionType = 220,
    TupleType = 221,
    UnitType = 222,
    GenericFunction = 223,
    GenericType = 224,
    GenericTypeWithTurbofish = 225,
    BoundedType = 226,
    TypeArguments = 227,
    TypeBinding = 228,
    ReferenceType = 229,
    PointerType = 230,
    NeverType = 231,
    AbstractType = 232,
    DynamicType = 233,
    ExpressionExceptRange = 234,
    Expression = 235,
    MacroInvocation = 236,
    TokenTree2 = 237,
    DelimTokens = 238,
    NonDelimToken = 239,
    ScopedIdentifier = 240,
    ScopedTypeIdentifier = 241,
    ScopedTypeIdentifier2 = 242,
    RangeExpression = 243,
    UnaryExpression = 244,
    TryExpression = 245,
    ReferenceExpression = 246,
    BinaryExpression = 247,
    AssignmentExpression = 248,
    CompoundAssignmentExpr = 249,
    TypeCastExpression = 250,
    ReturnExpression = 251,
    YieldExpression = 252,
    CallExpression = 253,
    Arguments = 254,
    ArrayExpression = 255,
    ParenthesizedExpression = 256,
    TupleExpression = 257,
    UnitExpression = 258,
    StructExpression = 259,
    FieldInitializerList = 260,
    ShorthandFieldInitializer = 261,
    FieldInitializer = 262,
    BaseFieldInitializer = 263,
    IfExpression = 264,
    LetCondition = 265,
    LetChain2 = 266,
    Condition = 267,
    ElseClause = 268,
    MatchExpression = 269,
    MatchBlock = 270,
    MatchArm = 271,
    MatchArm2 = 272,
    MatchPattern = 273,
    WhileExpression = 274,
    LoopExpression = 275,
    ForExpression = 276,
    ConstBlock = 277,
    ClosureExpression = 278,
    ClosureParameters = 279,
    Label = 280,
    BreakExpression = 281,
    ContinueExpression = 282,
    IndexExpression = 283,
    AwaitExpression = 284,
    FieldExpression = 285,
    UnsafeBlock = 286,
    AsyncBlock = 287,
    GenBlock = 288,
    TryBlock = 289,
    Block = 290,
    Pattern = 291,
    TuplePattern = 292,
    SlicePattern = 293,
    TupleStructPattern = 294,
    StructPattern = 295,
    FieldPattern = 296,
    RemainingFieldPattern = 297,
    MutPattern = 298,
    RangePattern = 299,
    RefPattern = 300,
    CapturedPattern = 301,
    ReferencePattern = 302,
    OrPattern = 303,
    Literal2 = 304,
    LiteralPattern = 305,
    NegativeLiteral = 306,
    StringLiteral = 307,
    RawStringLiteral = 308,
    BooleanLiteral = 309,
    LineComment = 310,
    LineDocCommentMarker = 311,
    InnerDocCommentMarker2 = 312,
    OuterDocCommentMarker2 = 313,
    BlockComment = 314,
    BlockDocCommentMarker = 315,
    SourceFileRepeat1 = 316,
    MacroDefinitionRepeat1 = 317,
    TokenTreePatternRepeat1 = 318,
    TokenTreeRepeat1 = 319,
    NonSpecialTokenRepeat1 = 320,
    DeclarationListRepeat1 = 321,
    EnumVariantListRepeat1 = 322,
    EnumVariantListRepeat2 = 323,
    FieldDeclarationListRepeat1 = 324,
    OrderedFieldDeclarationListRepeat1 = 325,
    FunctionModifiersRepeat1 = 326,
    WhereClauseRepeat1 = 327,
    TraitBoundsRepeat1 = 328,
    TypeParametersRepeat1 = 329,
    UseListRepeat1 = 330,
    ParametersRepeat1 = 331,
    ForLifetimesRepeat1 = 332,
    TupleTypeRepeat1 = 333,
    TypeArgumentsRepeat1 = 334,
    DelimTokenTreeRepeat1 = 335,
    ArgumentsRepeat1 = 336,
    TupleExpressionRepeat1 = 337,
    FieldInitializerListRepeat1 = 338,
    MatchBlockRepeat1 = 339,
    MatchArmRepeat1 = 340,
    ClosureParametersRepeat1 = 341,
    TuplePatternRepeat1 = 342,
    SlicePatternRepeat1 = 343,
    StructPatternRepeat1 = 344,
    StringLiteralRepeat1 = 345,
    FieldIdentifier = 346,
    LetChain = 347,
    ShorthandFieldIdentifier = 348,
    TypeIdentifier = 349,
    Error = 350,
}

impl From<Rust> for &'static str {
    #[inline(always)]
    fn from(tok: Rust) -> Self {
        match tok {
            Rust::End => "end",
            Rust::Identifier => "identifier",
            Rust::SEMI => ";",
            Rust::MacroRulesBANG => "macro_rules!",
            Rust::LPAREN => "(",
            Rust::RPAREN => ")",
            Rust::LBRACK => "[",
            Rust::RBRACK => "]",
            Rust::LBRACE => "{",
            Rust::RBRACE => "}",
            Rust::EQGT => "=>",
            Rust::COLON => ":",
            Rust::DOLLAR => "$",
            Rust::TokenRepetitionPatternToken1 => "token_repetition_pattern_token1",
            Rust::PLUS => "+",
            Rust::STAR => "*",
            Rust::QMARK => "?",
            Rust::Block2 => "block",
            Rust::Expr => "expr",
            Rust::Ident => "ident",
            Rust::Item => "item",
            Rust::Lifetime2 => "lifetime",
            Rust::Literal => "literal",
            Rust::Meta => "meta",
            Rust::Pat => "pat",
            Rust::Path => "path",
            Rust::Stmt => "stmt",
            Rust::Tt => "tt",
            Rust::Ty => "ty",
            Rust::Vis => "vis",
            Rust::PrimitiveType => "primitive_type",
            Rust::PrimitiveType2 => "primitive_type",
            Rust::PrimitiveType3 => "primitive_type",
            Rust::PrimitiveType4 => "primitive_type",
            Rust::PrimitiveType5 => "primitive_type",
            Rust::PrimitiveType6 => "primitive_type",
            Rust::PrimitiveType7 => "primitive_type",
            Rust::PrimitiveType8 => "primitive_type",
            Rust::PrimitiveType9 => "primitive_type",
            Rust::PrimitiveType10 => "primitive_type",
            Rust::PrimitiveType11 => "primitive_type",
            Rust::PrimitiveType12 => "primitive_type",
            Rust::PrimitiveType13 => "primitive_type",
            Rust::PrimitiveType14 => "primitive_type",
            Rust::PrimitiveType15 => "primitive_type",
            Rust::PrimitiveType16 => "primitive_type",
            Rust::PrimitiveType17 => "primitive_type",
            Rust::DASH => "-",
            Rust::SLASH => "/",
            Rust::PERCENT => "%",
            Rust::CARET => "^",
            Rust::BANG => "!",
            Rust::AMP => "&",
            Rust::PIPE => "|",
            Rust::AMPAMP => "&&",
            Rust::PIPEPIPE => "||",
            Rust::LTLT => "<<",
            Rust::GTGT => ">>",
            Rust::PLUSEQ => "+=",
            Rust::DASHEQ => "-=",
            Rust::STAREQ => "*=",
            Rust::SLASHEQ => "/=",
            Rust::PERCENTEQ => "%=",
            Rust::CARETEQ => "^=",
            Rust::AMPEQ => "&=",
            Rust::PIPEEQ => "|=",
            Rust::LTLTEQ => "<<=",
            Rust::GTGTEQ => ">>=",
            Rust::EQ => "=",
            Rust::EQEQ => "==",
            Rust::BANGEQ => "!=",
            Rust::GT => ">",
            Rust::LT => "<",
            Rust::GTEQ => ">=",
            Rust::LTEQ => "<=",
            Rust::AT => "@",
            Rust::UNDERSCORE => "_",
            Rust::DOT => ".",
            Rust::DOTDOT => "..",
            Rust::DOTDOTDOT => "...",
            Rust::DOTDOTEQ => "..=",
            Rust::COMMA => ",",
            Rust::COLONCOLON => "::",
            Rust::DASHGT => "->",
            Rust::HASH => "#",
            Rust::SQUOTE => "'",
            Rust::As => "as",
            Rust::Async => "async",
            Rust::Await => "await",
            Rust::Break => "break",
            Rust::Const => "const",
            Rust::Continue => "continue",
            Rust::Default => "default",
            Rust::Enum => "enum",
            Rust::Fn => "fn",
            Rust::For => "for",
            Rust::Gen => "gen",
            Rust::If => "if",
            Rust::Impl => "impl",
            Rust::Let => "let",
            Rust::Loop => "loop",
            Rust::Match => "match",
            Rust::Mod => "mod",
            Rust::Pub => "pub",
            Rust::Return => "return",
            Rust::Static => "static",
            Rust::Struct => "struct",
            Rust::Trait => "trait",
            Rust::Type => "type",
            Rust::Union => "union",
            Rust::Unsafe => "unsafe",
            Rust::Use => "use",
            Rust::Where => "where",
            Rust::While => "while",
            Rust::Extern => "extern",
            Rust::Ref => "ref",
            Rust::Else => "else",
            Rust::In => "in",
            Rust::LT2 => "<",
            Rust::Dyn => "dyn",
            Rust::MutableSpecifier => "mutable_specifier",
            Rust::Raw => "raw",
            Rust::Yield => "yield",
            Rust::Move => "move",
            Rust::Try => "try",
            Rust::IntegerLiteral => "integer_literal",
            Rust::DQUOTE => "\"",
            Rust::DQUOTE2 => "\"",
            Rust::CharLiteral => "char_literal",
            Rust::EscapeSequence => "escape_sequence",
            Rust::True => "true",
            Rust::False => "false",
            Rust::SLASHSLASH => "//",
            Rust::LineCommentToken1 => "line_comment_token1",
            Rust::LineCommentToken2 => "line_comment_token2",
            Rust::LineCommentToken3 => "line_comment_token3",
            Rust::BANG2 => "!",
            Rust::SLASH2 => "/",
            Rust::SLASHSTAR => "/*",
            Rust::STARSLASH => "*/",
            Rust::Shebang => "shebang",
            Rust::Zelf => "self",
            Rust::Super => "super",
            Rust::Crate => "crate",
            Rust::Metavariable => "metavariable",
            Rust::StringContent => "string_content",
            Rust::RawStringLiteralStart => "_raw_string_literal_start",
            Rust::StringContent2 => "string_content",
            Rust::RawStringLiteralEnd => "_raw_string_literal_end",
            Rust::FloatLiteral => "float_literal",
            Rust::OuterDocCommentMarker => "outer_doc_comment_marker",
            Rust::InnerDocCommentMarker => "inner_doc_comment_marker",
            Rust::BlockCommentContent => "_block_comment_content",
            Rust::DocComment => "doc_comment",
            Rust::ErrorSentinel => "_error_sentinel",
            Rust::SourceFile => "source_file",
            Rust::Statement => "_statement",
            Rust::EmptyStatement => "empty_statement",
            Rust::ExpressionStatement => "expression_statement",
            Rust::MacroDefinition => "macro_definition",
            Rust::MacroRule => "macro_rule",
            Rust::TokenPattern => "_token_pattern",
            Rust::TokenTreePattern => "token_tree_pattern",
            Rust::TokenBindingPattern => "token_binding_pattern",
            Rust::TokenRepetitionPattern => "token_repetition_pattern",
            Rust::FragmentSpecifier => "fragment_specifier",
            Rust::TokenTree => "token_tree",
            Rust::TokenRepetition => "token_repetition",
            Rust::AttributeItem => "attribute_item",
            Rust::InnerAttributeItem => "inner_attribute_item",
            Rust::Attribute => "attribute",
            Rust::ModItem => "mod_item",
            Rust::ForeignModItem => "foreign_mod_item",
            Rust::DeclarationList => "declaration_list",
            Rust::StructItem => "struct_item",
            Rust::UnionItem => "union_item",
            Rust::EnumItem => "enum_item",
            Rust::EnumVariantList => "enum_variant_list",
            Rust::EnumVariant => "enum_variant",
            Rust::FieldDeclarationList => "field_declaration_list",
            Rust::FieldDeclaration => "field_declaration",
            Rust::OrderedFieldDeclarationList => "ordered_field_declaration_list",
            Rust::ExternCrateDeclaration => "extern_crate_declaration",
            Rust::ConstItem => "const_item",
            Rust::StaticItem => "static_item",
            Rust::TypeItem => "type_item",
            Rust::FunctionItem => "function_item",
            Rust::FunctionSignatureItem => "function_signature_item",
            Rust::FunctionModifiers => "function_modifiers",
            Rust::WhereClause => "where_clause",
            Rust::WherePredicate => "where_predicate",
            Rust::ImplItem => "impl_item",
            Rust::TraitItem => "trait_item",
            Rust::AssociatedType => "associated_type",
            Rust::TraitBounds => "trait_bounds",
            Rust::HigherRankedTraitBound => "higher_ranked_trait_bound",
            Rust::RemovedTraitBound => "removed_trait_bound",
            Rust::TypeParameters => "type_parameters",
            Rust::ConstParameter => "const_parameter",
            Rust::ConstrainedTypeParameter => "constrained_type_parameter",
            Rust::OptionalTypeParameter => "optional_type_parameter",
            Rust::LetDeclaration => "let_declaration",
            Rust::UseDeclaration => "use_declaration",
            Rust::UseClause => "_use_clause",
            Rust::ScopedUseList => "scoped_use_list",
            Rust::UseList => "use_list",
            Rust::UseAsClause => "use_as_clause",
            Rust::UseWildcard => "use_wildcard",
            Rust::Parameters => "parameters",
            Rust::SelfParameter => "self_parameter",
            Rust::VariadicParameter => "variadic_parameter",
            Rust::Parameter => "parameter",
            Rust::ExternModifier => "extern_modifier",
            Rust::VisibilityModifier => "visibility_modifier",
            Rust::Type2 => "_type",
            Rust::BracketedType => "bracketed_type",
            Rust::QualifiedType => "qualified_type",
            Rust::Lifetime => "lifetime",
            Rust::ArrayType => "array_type",
            Rust::ForLifetimes => "for_lifetimes",
            Rust::FunctionType => "function_type",
            Rust::TupleType => "tuple_type",
            Rust::UnitType => "unit_type",
            Rust::GenericFunction => "generic_function",
            Rust::GenericType => "generic_type",
            Rust::GenericTypeWithTurbofish => "generic_type_with_turbofish",
            Rust::BoundedType => "bounded_type",
            Rust::TypeArguments => "type_arguments",
            Rust::TypeBinding => "type_binding",
            Rust::ReferenceType => "reference_type",
            Rust::PointerType => "pointer_type",
            Rust::NeverType => "never_type",
            Rust::AbstractType => "abstract_type",
            Rust::DynamicType => "dynamic_type",
            Rust::ExpressionExceptRange => "_expression_except_range",
            Rust::Expression => "_expression",
            Rust::MacroInvocation => "macro_invocation",
            Rust::TokenTree2 => "token_tree",
            Rust::DelimTokens => "_delim_tokens",
            Rust::NonDelimToken => "_non_delim_token",
            Rust::ScopedIdentifier => "scoped_identifier",
            Rust::ScopedTypeIdentifier => "scoped_type_identifier",
            Rust::ScopedTypeIdentifier2 => "scoped_type_identifier",
            Rust::RangeExpression => "range_expression",
            Rust::UnaryExpression => "unary_expression",
            Rust::TryExpression => "try_expression",
            Rust::ReferenceExpression => "reference_expression",
            Rust::BinaryExpression => "binary_expression",
            Rust::AssignmentExpression => "assignment_expression",
            Rust::CompoundAssignmentExpr => "compound_assignment_expr",
            Rust::TypeCastExpression => "type_cast_expression",
            Rust::ReturnExpression => "return_expression",
            Rust::YieldExpression => "yield_expression",
            Rust::CallExpression => "call_expression",
            Rust::Arguments => "arguments",
            Rust::ArrayExpression => "array_expression",
            Rust::ParenthesizedExpression => "parenthesized_expression",
            Rust::TupleExpression => "tuple_expression",
            Rust::UnitExpression => "unit_expression",
            Rust::StructExpression => "struct_expression",
            Rust::FieldInitializerList => "field_initializer_list",
            Rust::ShorthandFieldInitializer => "shorthand_field_initializer",
            Rust::FieldInitializer => "field_initializer",
            Rust::BaseFieldInitializer => "base_field_initializer",
            Rust::IfExpression => "if_expression",
            Rust::LetCondition => "let_condition",
            Rust::LetChain2 => "_let_chain",
            Rust::Condition => "_condition",
            Rust::ElseClause => "else_clause",
            Rust::MatchExpression => "match_expression",
            Rust::MatchBlock => "match_block",
            Rust::MatchArm => "match_arm",
            Rust::MatchArm2 => "match_arm",
            Rust::MatchPattern => "match_pattern",
            Rust::WhileExpression => "while_expression",
            Rust::LoopExpression => "loop_expression",
            Rust::ForExpression => "for_expression",
            Rust::ConstBlock => "const_block",
            Rust::ClosureExpression => "closure_expression",
            Rust::ClosureParameters => "closure_parameters",
            Rust::Label => "label",
            Rust::BreakExpression => "break_expression",
            Rust::ContinueExpression => "continue_expression",
            Rust::IndexExpression => "index_expression",
            Rust::AwaitExpression => "await_expression",
            Rust::FieldExpression => "field_expression",
            Rust::UnsafeBlock => "unsafe_block",
            Rust::AsyncBlock => "async_block",
            Rust::GenBlock => "gen_block",
            Rust::TryBlock => "try_block",
            Rust::Block => "block",
            Rust::Pattern => "_pattern",
            Rust::TuplePattern => "tuple_pattern",
            Rust::SlicePattern => "slice_pattern",
            Rust::TupleStructPattern => "tuple_struct_pattern",
            Rust::StructPattern => "struct_pattern",
            Rust::FieldPattern => "field_pattern",
            Rust::RemainingFieldPattern => "remaining_field_pattern",
            Rust::MutPattern => "mut_pattern",
            Rust::RangePattern => "range_pattern",
            Rust::RefPattern => "ref_pattern",
            Rust::CapturedPattern => "captured_pattern",
            Rust::ReferencePattern => "reference_pattern",
            Rust::OrPattern => "or_pattern",
            Rust::Literal2 => "_literal",
            Rust::LiteralPattern => "_literal_pattern",
            Rust::NegativeLiteral => "negative_literal",
            Rust::StringLiteral => "string_literal",
            Rust::RawStringLiteral => "raw_string_literal",
            Rust::BooleanLiteral => "boolean_literal",
            Rust::LineComment => "line_comment",
            Rust::LineDocCommentMarker => "_line_doc_comment_marker",
            Rust::InnerDocCommentMarker2 => "inner_doc_comment_marker",
            Rust::OuterDocCommentMarker2 => "outer_doc_comment_marker",
            Rust::BlockComment => "block_comment",
            Rust::BlockDocCommentMarker => "_block_doc_comment_marker",
            Rust::SourceFileRepeat1 => "source_file_repeat1",
            Rust::MacroDefinitionRepeat1 => "macro_definition_repeat1",
            Rust::TokenTreePatternRepeat1 => "token_tree_pattern_repeat1",
            Rust::TokenTreeRepeat1 => "token_tree_repeat1",
            Rust::NonSpecialTokenRepeat1 => "_non_special_token_repeat1",
            Rust::DeclarationListRepeat1 => "declaration_list_repeat1",
            Rust::EnumVariantListRepeat1 => "enum_variant_list_repeat1",
            Rust::EnumVariantListRepeat2 => "enum_variant_list_repeat2",
            Rust::FieldDeclarationListRepeat1 => "field_declaration_list_repeat1",
            Rust::OrderedFieldDeclarationListRepeat1 => "ordered_field_declaration_list_repeat1",
            Rust::FunctionModifiersRepeat1 => "function_modifiers_repeat1",
            Rust::WhereClauseRepeat1 => "where_clause_repeat1",
            Rust::TraitBoundsRepeat1 => "trait_bounds_repeat1",
            Rust::TypeParametersRepeat1 => "type_parameters_repeat1",
            Rust::UseListRepeat1 => "use_list_repeat1",
            Rust::ParametersRepeat1 => "parameters_repeat1",
            Rust::ForLifetimesRepeat1 => "for_lifetimes_repeat1",
            Rust::TupleTypeRepeat1 => "tuple_type_repeat1",
            Rust::TypeArgumentsRepeat1 => "type_arguments_repeat1",
            Rust::DelimTokenTreeRepeat1 => "delim_token_tree_repeat1",
            Rust::ArgumentsRepeat1 => "arguments_repeat1",
            Rust::TupleExpressionRepeat1 => "tuple_expression_repeat1",
            Rust::FieldInitializerListRepeat1 => "field_initializer_list_repeat1",
            Rust::MatchBlockRepeat1 => "match_block_repeat1",
            Rust::MatchArmRepeat1 => "match_arm_repeat1",
            Rust::ClosureParametersRepeat1 => "closure_parameters_repeat1",
            Rust::TuplePatternRepeat1 => "tuple_pattern_repeat1",
            Rust::SlicePatternRepeat1 => "slice_pattern_repeat1",
            Rust::StructPatternRepeat1 => "struct_pattern_repeat1",
            Rust::StringLiteralRepeat1 => "string_literal_repeat1",
            Rust::FieldIdentifier => "field_identifier",
            Rust::LetChain => "let_chain",
            Rust::ShorthandFieldIdentifier => "shorthand_field_identifier",
            Rust::TypeIdentifier => "type_identifier",
            Rust::Error => "ERROR",
        }
    }
}

impl From<u16> for Rust {
    #[inline(always)]
    fn from(x: u16) -> Self {
        num::FromPrimitive::from_u16(x).unwrap_or(Self::Error)
    }
}

// Rust == u16
impl PartialEq<u16> for Rust {
    #[inline(always)]
    fn eq(&self, x: &u16) -> bool {
        *self == Into::<Self>::into(*x)
    }
}

// u16 == Rust
impl PartialEq<Rust> for u16 {
    #[inline(always)]
    fn eq(&self, x: &Rust) -> bool {
        *x == *self
    }
}