From d5c0d41f98f65935b8c4164ec52c64dad053927d Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Mon, 16 Sep 2024 10:48:20 +0200 Subject: [PATCH 01/12] Rust: add generate-schema project --- Cargo.lock | 13 +++++++++++++ Cargo.toml | 1 + rust/generate-schema/.gitignore | 2 ++ rust/generate-schema/Cargo.lock | 16 ++++++++++++++++ rust/generate-schema/Cargo.toml | 8 ++++++++ rust/generate-schema/src/main.rs | 0 6 files changed, 40 insertions(+) create mode 100644 rust/generate-schema/.gitignore create mode 100644 rust/generate-schema/Cargo.lock create mode 100644 rust/generate-schema/Cargo.toml create mode 100644 rust/generate-schema/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 675a5200d2ba..8fc64a693101 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -680,6 +680,13 @@ version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ab85b9b05e3978cc9a9cf8fea7f01b494e1a09ed3037e16ba39edc7a29eb61a" +[[package]] +name = "generate-schema" +version = "0.1.0" +dependencies = [ + "ungrammar", +] + [[package]] name = "getrandom" version = "0.2.15" @@ -2335,6 +2342,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "ungrammar" +version = "1.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e5df347f0bf3ec1d670aad6ca5c6a1859cd9ea61d2113125794654ccced68f" + [[package]] name = "unicode-ident" version = "1.0.13" diff --git a/Cargo.toml b/Cargo.toml index 4aacef79adc8..4b80e2ac9b77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ members = [ "ruby/extractor", "rust/extractor", "rust/extractor/macros", + "rust/generate-schema", ] [patch.crates-io] diff --git a/rust/generate-schema/.gitignore b/rust/generate-schema/.gitignore new file mode 100644 index 000000000000..d81f12ed1b1c --- /dev/null +++ b/rust/generate-schema/.gitignore @@ -0,0 +1,2 @@ +/target +/.idea diff --git a/rust/generate-schema/Cargo.lock b/rust/generate-schema/Cargo.lock new file mode 100644 index 000000000000..9ca5960b7803 --- /dev/null +++ b/rust/generate-schema/Cargo.lock @@ -0,0 +1,16 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "generate-schema" +version = "0.1.0" +dependencies = [ + "ungrammar", +] + +[[package]] +name = "ungrammar" +version = "1.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e5df347f0bf3ec1d670aad6ca5c6a1859cd9ea61d2113125794654ccced68f" diff --git a/rust/generate-schema/Cargo.toml b/rust/generate-schema/Cargo.toml new file mode 100644 index 000000000000..e5167ebfd20b --- /dev/null +++ b/rust/generate-schema/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "generate-schema" +version = "0.1.0" +edition = "2021" + +[dependencies] +ungrammar = "1.16.1" + diff --git a/rust/generate-schema/src/main.rs b/rust/generate-schema/src/main.rs new file mode 100644 index 000000000000..e69de29bb2d1 From 5ccb45e7d3b6cfb0048e40e1a79a88dbf107a29b Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Mon, 16 Sep 2024 10:49:42 +0200 Subject: [PATCH 02/12] Rust: add rust.ungram Copied from https://github.com/rust-lang/rust-analyzer/blob/50882fbfa204027c84753e6d51a1a12884dc1b19/crates/syntax/rust.ungram --- rust/generate-schema/rust.ungram | 718 +++++++++++++++++++++++++++++++ 1 file changed, 718 insertions(+) create mode 100644 rust/generate-schema/rust.ungram diff --git a/rust/generate-schema/rust.ungram b/rust/generate-schema/rust.ungram new file mode 100644 index 000000000000..43375ce6ae05 --- /dev/null +++ b/rust/generate-schema/rust.ungram @@ -0,0 +1,718 @@ +// Rust Un-Grammar. +// +// This grammar specifies the structure of Rust's concrete syntax tree. +// It does not specify parsing rules (ambiguities, precedence, etc are out of scope). +// Tokens are processed -- contextual keywords are recognised, compound operators glued. +// +// Legend: +// +// // -- comment +// Name = -- non-terminal definition +// 'ident' -- keyword or punct token (terminal) +// '#ident' -- generic token (terminal) +// '@ident' -- literal token (terminal) +// A B -- sequence +// A | B -- alternation +// A* -- zero or more repetition +// A? -- zero or one repetition +// (A) -- same as A +// label:A -- suggested name for field of AST node + +//*************************// +// Paths // +//*************************// + +Name = + '#ident' | 'self' + +NameRef = + '#ident' | '@int_number' | 'self' | 'super' | 'crate' | 'Self' + +Lifetime = + '#lifetime_ident' + +Path = + (qualifier:Path '::')? segment:PathSegment + +PathSegment = + '::'? NameRef +| NameRef GenericArgList? +| NameRef ParamList RetType? +| NameRef ReturnTypeSyntax +| '<' Type ('as' PathType)? '>' + +ReturnTypeSyntax = + '(' '..' ')' + + +//*************************// +// Generics // +//*************************// + +GenericArgList = + '::'? '<' (GenericArg (',' GenericArg)* ','?)? '>' + +GenericArg = + TypeArg +| AssocTypeArg +| LifetimeArg +| ConstArg + +TypeArg = + Type + +AssocTypeArg = + NameRef + (GenericArgList | ParamList RetType? | ReturnTypeSyntax)? + (':' TypeBoundList | ('=' Type | ConstArg)) + +LifetimeArg = + Lifetime + +ConstArg = + Expr + +GenericParamList = + '<' (GenericParam (',' GenericParam)* ','?)? '>' + +GenericParam = + ConstParam +| LifetimeParam +| TypeParam + +TypeParam = + Attr* Name (':' TypeBoundList?)? + ('=' default_type:Type)? + +ConstParam = + Attr* 'const' Name ':' Type + ('=' default_val:ConstArg)? + +LifetimeParam = + Attr* Lifetime (':' TypeBoundList?)? + +WhereClause = + 'where' predicates:(WherePred (',' WherePred)* ','?) + +WherePred = + ('for' GenericParamList)? (Lifetime | Type) ':' TypeBoundList? + + +//*************************// +// Macro // +//*************************// + +MacroCall = + Attr* Path '!' TokenTree ';'? + +TokenTree = + '(' ')' +| '{' '}' +| '[' ']' + +MacroItems = + Item* + +MacroStmts = + statements:Stmt* + Expr? + +Attr = + '#' '!'? '[' Meta ']' + +Meta = + 'unsafe' '(' Path ('=' Expr | TokenTree)? ')' +| Path ('=' Expr | TokenTree)? + +//*************************// +// Items // +//*************************// + +SourceFile = + '#shebang'? + Attr* + Item* + +Item = + Const +| Enum +| ExternBlock +| ExternCrate +| Fn +| Impl +| MacroCall +| MacroRules +| MacroDef +| Module +| Static +| Struct +| Trait +| TraitAlias +| TypeAlias +| Union +| Use + +MacroRules = + Attr* Visibility? + 'macro_rules' '!' Name + TokenTree + +MacroDef = + Attr* Visibility? + 'macro' Name args:TokenTree? + body:TokenTree + +Module = + Attr* Visibility? + 'mod' Name + (ItemList | ';') + +ItemList = + '{' Attr* Item* '}' + +ExternCrate = + Attr* Visibility? + 'extern' 'crate' NameRef Rename? ';' + +Rename = + 'as' (Name | '_') + +Use = + Attr* Visibility? + 'use' UseTree ';' + +UseTree = + (Path? '::')? ('*' | UseTreeList) +| Path Rename? + +UseTreeList = + '{' (UseTree (',' UseTree)* ','?)? '}' + +Fn = + Attr* Visibility? + 'default'? 'const'? 'async'? 'gen'? 'unsafe'? Abi? + 'fn' Name GenericParamList? ParamList RetType? WhereClause? + (body:BlockExpr | ';') + +Abi = + 'extern' '@string'? + +ParamList = + '('( + SelfParam + | (SelfParam ',')? (Param (',' Param)* ','?)? + )')' +| '|' (Param (',' Param)* ','?)? '|' + +SelfParam = + Attr* ( + ('&' Lifetime?)? 'mut'? Name + | 'mut'? Name ':' Type + ) + +Param = + Attr* ( + Pat (':' Type)? + | Type + | '...' + ) + +RetType = + '->' Type + +TypeAlias = + Attr* Visibility? + 'default'? + 'type' Name GenericParamList? (':' TypeBoundList?)? WhereClause? + ('=' Type)? ';' + +Struct = + Attr* Visibility? + 'struct' Name GenericParamList? ( + WhereClause? (RecordFieldList | ';') + | TupleFieldList WhereClause? ';' + ) + +RecordFieldList = + '{' fields:(RecordField (',' RecordField)* ','?)? '}' + +RecordField = + Attr* Visibility? + Name ':' Type + +TupleFieldList = + '(' fields:(TupleField (',' TupleField)* ','?)? ')' + +TupleField = + Attr* Visibility? + Type + +FieldList = + RecordFieldList +| TupleFieldList + +Enum = + Attr* Visibility? + 'enum' Name GenericParamList? WhereClause? + VariantList + +VariantList = + '{' (Variant (',' Variant)* ','?)? '}' + +Variant = + Attr* Visibility? + Name FieldList? ('=' Expr)? + +Union = + Attr* Visibility? + 'union' Name GenericParamList? WhereClause? + RecordFieldList + +// A Data Type. +// +// Not used directly in the grammar, but handy to have anyway. +Adt = + Enum +| Struct +| Union + +Const = + Attr* Visibility? + 'default'? + 'const' (Name | '_') ':' Type + ('=' body:Expr)? ';' + +Static = + Attr* Visibility? + 'static' 'mut'? Name ':' Type + ('=' body:Expr)? ';' + +Trait = + Attr* Visibility? + 'unsafe'? 'auto'? + 'trait' Name GenericParamList? + (':' TypeBoundList?)? WhereClause? AssocItemList + +TraitAlias = + Attr* Visibility? + 'trait' Name GenericParamList? '=' TypeBoundList? WhereClause? ';' + +AssocItemList = + '{' Attr* AssocItem* '}' + +AssocItem = + Const +| Fn +| MacroCall +| TypeAlias + +Impl = + Attr* Visibility? + 'default'? 'unsafe'? + 'impl' GenericParamList? ('const'? '!'? trait:Type 'for')? self_ty:Type WhereClause? + AssocItemList + +ExternBlock = + Attr* 'unsafe'? Abi ExternItemList + +ExternItemList = + '{' Attr* ExternItem* '}' + +ExternItem = + Fn +| MacroCall +| Static +| TypeAlias + +Visibility = + 'pub' ('(' 'in'? Path ')')? + + +//****************************// +// Statements and Expressions // +//****************************// + +Stmt = + ';' +| ExprStmt +| Item +| LetStmt + +LetStmt = + Attr* 'let' Pat (':' Type)? + '=' initializer:Expr + LetElse? + ';' + +LetElse = + 'else' BlockExpr + +ExprStmt = + Expr ';'? + +Expr = + ArrayExpr +| AsmExpr +| AwaitExpr +| BinExpr +| BlockExpr +| BreakExpr +| CallExpr +| CastExpr +| ClosureExpr +| ContinueExpr +| FieldExpr +| ForExpr +| FormatArgsExpr +| IfExpr +| IndexExpr +| Literal +| LoopExpr +| MacroExpr +| MatchExpr +| MethodCallExpr +| OffsetOfExpr +| ParenExpr +| PathExpr +| PrefixExpr +| RangeExpr +| RecordExpr +| RefExpr +| ReturnExpr +| BecomeExpr +| TryExpr +| TupleExpr +| WhileExpr +| YieldExpr +| YeetExpr +| LetExpr +| UnderscoreExpr + +OffsetOfExpr = + Attr* 'builtin' '#' 'offset_of' '(' Type ',' fields:(NameRef ('.' NameRef)* ) ')' + +AsmExpr = + Attr* 'builtin' '#' 'asm' '(' Expr ')' + +FormatArgsExpr = + Attr* 'builtin' '#' 'format_args' '(' + template:Expr + (',' args:(FormatArgsArg (',' FormatArgsArg)* ','?)? )? + ')' + +FormatArgsArg = + (Name '=')? Expr + +MacroExpr = + MacroCall + +Literal = + Attr* value:( + '@int_number' | '@float_number' + | '@string' | '@raw_string' + | '@byte_string' | '@raw_byte_string' + | '@c_string' | '@raw_c_string' + | '@char' | '@byte' + | 'true' | 'false' + ) + +PathExpr = + Attr* Path + +StmtList = + '{' + Attr* + statements:Stmt* + tail_expr:Expr? + '}' + +RefExpr = + Attr* '&' (('raw' 'const'?)| ('raw'? 'mut') ) Expr + +TryExpr = + Attr* Expr '?' + +BlockExpr = + Attr* Label? ('try' | 'unsafe' | ('async' 'move'?) | ('gen' 'move'?) | 'const') StmtList + +PrefixExpr = + Attr* op:('-' | '!' | '*') Expr + +BinExpr = + Attr* + lhs:Expr + op:( + '||' | '&&' + | '==' | '!=' | '<=' | '>=' | '<' | '>' + | '+' | '*' | '-' | '/' | '%' | '<<' | '>>' | '^' | '|' | '&' + | '=' | '+=' | '/=' | '*=' | '%=' | '>>=' | '<<=' | '-=' | '|=' | '&=' | '^=' + ) + rhs:Expr + +CastExpr = + Attr* Expr 'as' Type + +ParenExpr = + Attr* '(' Attr* Expr ')' + +ArrayExpr = + Attr* '[' Attr* ( + (Expr (',' Expr)* ','?)? + | Expr ';' Expr + ) ']' + +IndexExpr = + Attr* base:Expr '[' index:Expr ']' + +TupleExpr = + Attr* '(' Attr* fields:(Expr (',' Expr)* ','?)? ')' + +RecordExpr = + Path RecordExprFieldList + +RecordExprFieldList = + '{' + Attr* + fields:(RecordExprField (',' RecordExprField)* ','?)? + ('..' spread:Expr?)? + '}' + +RecordExprField = + Attr* (NameRef ':')? Expr + +CallExpr = + Attr* Expr ArgList + +ArgList = + '(' args:(Expr (',' Expr)* ','?)? ')' + +MethodCallExpr = + Attr* receiver:Expr '.' NameRef GenericArgList? ArgList + +FieldExpr = + Attr* Expr '.' NameRef + +ClosureExpr = + Attr* ClosureBinder? 'const'? 'static'? 'async'? 'gen'? 'move'? ParamList RetType? + body:Expr + +ClosureBinder = + 'for' GenericParamList + +IfExpr = + Attr* 'if' condition:Expr then_branch:BlockExpr + ('else' else_branch:(IfExpr | BlockExpr))? + +LoopExpr = + Attr* Label? 'loop' + loop_body:BlockExpr + +ForExpr = + Attr* Label? 'for' Pat 'in' iterable:Expr + loop_body:BlockExpr + +WhileExpr = + Attr* Label? 'while' condition:Expr + loop_body:BlockExpr + +Label = + Lifetime ':' + +BreakExpr = + Attr* 'break' Lifetime? Expr? + +ContinueExpr = + Attr* 'continue' Lifetime? + +RangeExpr = + Attr* start:Expr? op:('..' | '..=') end:Expr? + +MatchExpr = + Attr* 'match' Expr MatchArmList + +MatchArmList = + '{' + Attr* + arms:MatchArm* + '}' + +MatchArm = + Attr* Pat guard:MatchGuard? '=>' Expr ','? + +MatchGuard = + 'if' condition:Expr + +ReturnExpr = + Attr* 'return' Expr? + +BecomeExpr = + Attr* 'become' Expr + +YieldExpr = + Attr* 'yield' Expr? + +YeetExpr = + Attr* 'do' 'yeet' Expr? + +LetExpr = + Attr* 'let' Pat '=' Expr + +UnderscoreExpr = + Attr* '_' + +AwaitExpr = + Attr* Expr '.' 'await' + +//*************************// +// Types // +//*************************// + +Type = + ArrayType +| DynTraitType +| FnPtrType +| ForType +| ImplTraitType +| InferType +| MacroType +| NeverType +| ParenType +| PathType +| PtrType +| RefType +| SliceType +| TupleType + +ParenType = + '(' Type ')' + +NeverType = + '!' + +MacroType = + MacroCall + +PathType = + Path + +TupleType = + '(' fields:(Type (',' Type)* ','?)? ')' + +PtrType = + '*' ('const' | 'mut') Type + +RefType = + '&' Lifetime? 'mut'? Type + +ArrayType = + '[' Type ';' ConstArg ']' + +SliceType = + '[' Type ']' + +InferType = + '_' + +FnPtrType = + 'const'? 'async'? 'unsafe'? Abi? 'fn' ParamList RetType? + +ForType = + 'for' GenericParamList Type + +ImplTraitType = + 'impl' TypeBoundList + +DynTraitType = + 'dyn'? TypeBoundList + +TypeBoundList = + bounds:(TypeBound ('+' TypeBound)* '+'?) + +TypeBound = + Lifetime +| ('~' 'const' | 'const')? 'async'? '?'? Type +| 'use' GenericParamList + +//************************// +// Patterns // +//************************// + +Pat = + IdentPat +| BoxPat +| RestPat +| LiteralPat +| MacroPat +| OrPat +| ParenPat +| PathPat +| WildcardPat +| RangePat +| RecordPat +| RefPat +| SlicePat +| TuplePat +| TupleStructPat +| ConstBlockPat + +LiteralPat = + '-'? Literal + +IdentPat = + Attr* 'ref'? 'mut'? Name ('@' Pat)? + +WildcardPat = + '_' + +RangePat = + // 1.. + start:Pat op:('..' | '..=') + // 1..2 + | start:Pat op:('..' | '..=') end:Pat + // ..2 + | op:('..' | '..=') end:Pat + +RefPat = + '&' 'mut'? Pat + +RecordPat = + Path RecordPatFieldList + +RecordPatFieldList = + '{' + fields:(RecordPatField (',' RecordPatField)* ','?)? + RestPat? + '}' + +RecordPatField = + Attr* (NameRef ':')? Pat + +TupleStructPat = + Path '(' fields:(Pat (',' Pat)* ','?)? ')' + +TuplePat = + '(' fields:(Pat (',' Pat)* ','?)? ')' + +ParenPat = + '(' Pat ')' + +SlicePat = + '[' (Pat (',' Pat)* ','?)? ']' + +PathPat = + Path + +OrPat = + (Pat ('|' Pat)* '|'?) + +BoxPat = + 'box' Pat + +RestPat = + Attr* '..' + +MacroPat = + MacroCall + +ConstBlockPat = + 'const' BlockExpr From fabdb3c8410776b1983f3c033d336d6eb1a11044 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Mon, 16 Sep 2024 11:25:59 +0200 Subject: [PATCH 03/12] Rust: copy files from rust-analyzer's codegenerator Files copied from: https://github.com/rust-lang/rust-analyzer/tree/50882fbfa204027c84753e6d51a1a12884dc1b19/xtask/src/codegen/grammar --- rust/generate-schema/Cargo.toml | 3 + rust/generate-schema/src/codegen/grammar.rs | 1001 +++++++++++++++++ .../src/codegen/grammar/ast_src.rs | 244 ++++ 3 files changed, 1248 insertions(+) create mode 100644 rust/generate-schema/src/codegen/grammar.rs create mode 100644 rust/generate-schema/src/codegen/grammar/ast_src.rs diff --git a/rust/generate-schema/Cargo.toml b/rust/generate-schema/Cargo.toml index e5167ebfd20b..0eb36ecbc63c 100644 --- a/rust/generate-schema/Cargo.toml +++ b/rust/generate-schema/Cargo.toml @@ -5,4 +5,7 @@ edition = "2021" [dependencies] ungrammar = "1.16.1" +proc-macro2 = "1.0.33" +quote = "1.0.12" +itertools = "0.10.1" diff --git a/rust/generate-schema/src/codegen/grammar.rs b/rust/generate-schema/src/codegen/grammar.rs new file mode 100644 index 000000000000..39e06f9642db --- /dev/null +++ b/rust/generate-schema/src/codegen/grammar.rs @@ -0,0 +1,1001 @@ +//! This module generates AST datatype used by rust-analyzer. +//! +//! Specifically, it generates the `SyntaxKind` enum and a number of newtype +//! wrappers around `SyntaxNode` which implement `syntax::AstNode`. + +#![allow(clippy::disallowed_types)] + +use std::{ + collections::{BTreeSet, HashSet}, + fmt::Write, + fs, +}; + +use itertools::Itertools; +use proc_macro2::{Punct, Spacing}; +use quote::{format_ident, quote}; +use ungrammar::{Grammar, Rule}; + +use crate::{ + codegen::{add_preamble, ensure_file_contents, grammar::ast_src::generate_kind_src, reformat}, + project_root, +}; + +mod ast_src; +use self::ast_src::{AstEnumSrc, AstNodeSrc, AstSrc, Cardinality, Field, KindsSrc}; + +pub(crate) fn generate(check: bool) { + let grammar = fs::read_to_string(project_root().join("crates/syntax/rust.ungram")) + .unwrap() + .parse() + .unwrap(); + let ast = lower(&grammar); + let kinds_src = generate_kind_src(&ast.nodes, &ast.enums, &grammar); + + let syntax_kinds = generate_syntax_kinds(kinds_src); + let syntax_kinds_file = project_root().join("crates/parser/src/syntax_kind/generated.rs"); + ensure_file_contents( + crate::flags::CodegenType::Grammar, + syntax_kinds_file.as_path(), + &syntax_kinds, + check, + ); + + let ast_tokens = generate_tokens(&ast); + let ast_tokens_file = project_root().join("crates/syntax/src/ast/generated/tokens.rs"); + ensure_file_contents( + crate::flags::CodegenType::Grammar, + ast_tokens_file.as_path(), + &ast_tokens, + check, + ); + + let ast_nodes = generate_nodes(kinds_src, &ast); + let ast_nodes_file = project_root().join("crates/syntax/src/ast/generated/nodes.rs"); + ensure_file_contents( + crate::flags::CodegenType::Grammar, + ast_nodes_file.as_path(), + &ast_nodes, + check, + ); +} + +fn generate_tokens(grammar: &AstSrc) -> String { + let tokens = grammar.tokens.iter().map(|token| { + let name = format_ident!("{}", token); + let kind = format_ident!("{}", to_upper_snake_case(token)); + quote! { + #[derive(Debug, Clone, PartialEq, Eq, Hash)] + pub struct #name { + pub(crate) syntax: SyntaxToken, + } + impl std::fmt::Display for #name { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(&self.syntax, f) + } + } + impl AstToken for #name { + fn can_cast(kind: SyntaxKind) -> bool { kind == #kind } + fn cast(syntax: SyntaxToken) -> Option { + if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } + } + fn syntax(&self) -> &SyntaxToken { &self.syntax } + } + } + }); + + add_preamble( + crate::flags::CodegenType::Grammar, + reformat( + quote! { + use crate::{SyntaxKind::{self, *}, SyntaxToken, ast::AstToken}; + #(#tokens)* + } + .to_string(), + ), + ) + .replace("#[derive", "\n#[derive") +} + +fn generate_nodes(kinds: KindsSrc, grammar: &AstSrc) -> String { + let (node_defs, node_boilerplate_impls): (Vec<_>, Vec<_>) = grammar + .nodes + .iter() + .map(|node| { + let name = format_ident!("{}", node.name); + let kind = format_ident!("{}", to_upper_snake_case(&node.name)); + let traits = node + .traits + .iter() + .filter(|trait_name| { + // Loops have two expressions so this might collide, therefore manual impl it + node.name != "ForExpr" && node.name != "WhileExpr" + || trait_name.as_str() != "HasLoopBody" + }) + .map(|trait_name| { + let trait_name = format_ident!("{}", trait_name); + quote!(impl ast::#trait_name for #name {}) + }); + + let methods = node.fields.iter().map(|field| { + let method_name = format_ident!("{}", field.method_name()); + let ty = field.ty(); + + if field.is_many() { + quote! { + #[inline] + pub fn #method_name(&self) -> AstChildren<#ty> { + support::children(&self.syntax) + } + } + } else if let Some(token_kind) = field.token_kind() { + quote! { + #[inline] + pub fn #method_name(&self) -> Option<#ty> { + support::token(&self.syntax, #token_kind) + } + } + } else { + quote! { + #[inline] + pub fn #method_name(&self) -> Option<#ty> { + support::child(&self.syntax) + } + } + } + }); + ( + quote! { + #[pretty_doc_comment_placeholder_workaround] + #[derive(Debug, Clone, PartialEq, Eq, Hash)] + pub struct #name { + pub(crate) syntax: SyntaxNode, + } + + #(#traits)* + + impl #name { + #(#methods)* + } + }, + quote! { + impl AstNode for #name { + #[inline] + fn can_cast(kind: SyntaxKind) -> bool { + kind == #kind + } + #[inline] + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } + } + #[inline] + fn syntax(&self) -> &SyntaxNode { &self.syntax } + } + }, + ) + }) + .unzip(); + + let (enum_defs, enum_boilerplate_impls): (Vec<_>, Vec<_>) = grammar + .enums + .iter() + .map(|en| { + let variants: Vec<_> = + en.variants.iter().map(|var| format_ident!("{}", var)).sorted().collect(); + let name = format_ident!("{}", en.name); + let kinds: Vec<_> = variants + .iter() + .map(|name| format_ident!("{}", to_upper_snake_case(&name.to_string()))) + .collect(); + let traits = en.traits.iter().sorted().map(|trait_name| { + let trait_name = format_ident!("{}", trait_name); + quote!(impl ast::#trait_name for #name {}) + }); + + let ast_node = if en.name == "Stmt" { + quote! {} + } else { + quote! { + impl AstNode for #name { + #[inline] + fn can_cast(kind: SyntaxKind) -> bool { + matches!(kind, #(#kinds)|*) + } + #[inline] + fn cast(syntax: SyntaxNode) -> Option { + let res = match syntax.kind() { + #( + #kinds => #name::#variants(#variants { syntax }), + )* + _ => return None, + }; + Some(res) + } + #[inline] + fn syntax(&self) -> &SyntaxNode { + match self { + #( + #name::#variants(it) => &it.syntax, + )* + } + } + } + } + }; + + ( + quote! { + #[pretty_doc_comment_placeholder_workaround] + #[derive(Debug, Clone, PartialEq, Eq, Hash)] + pub enum #name { + #(#variants(#variants),)* + } + + #(#traits)* + }, + quote! { + #( + impl From<#variants> for #name { + #[inline] + fn from(node: #variants) -> #name { + #name::#variants(node) + } + } + )* + #ast_node + }, + ) + }) + .unzip(); + let (any_node_defs, any_node_boilerplate_impls): (Vec<_>, Vec<_>) = grammar + .nodes + .iter() + .flat_map(|node| node.traits.iter().map(move |t| (t, node))) + .into_group_map() + .into_iter() + .sorted_by_key(|(name, _)| *name) + .map(|(trait_name, nodes)| { + let name = format_ident!("Any{}", trait_name); + let trait_name = format_ident!("{}", trait_name); + let kinds: Vec<_> = nodes + .iter() + .map(|name| format_ident!("{}", to_upper_snake_case(&name.name.to_string()))) + .collect(); + let nodes = nodes.iter().map(|node| format_ident!("{}", node.name)); + ( + quote! { + #[pretty_doc_comment_placeholder_workaround] + #[derive(Debug, Clone, PartialEq, Eq, Hash)] + pub struct #name { + pub(crate) syntax: SyntaxNode, + } + impl ast::#trait_name for #name {} + }, + quote! { + impl #name { + #[inline] + pub fn new(node: T) -> #name { + #name { + syntax: node.syntax().clone() + } + } + } + impl AstNode for #name { + #[inline] + fn can_cast(kind: SyntaxKind) -> bool { + matches!(kind, #(#kinds)|*) + } + #[inline] + fn cast(syntax: SyntaxNode) -> Option { + Self::can_cast(syntax.kind()).then_some(#name { syntax }) + } + #[inline] + fn syntax(&self) -> &SyntaxNode { + &self.syntax + } + } + + #( + impl From<#nodes> for #name { + #[inline] + fn from(node: #nodes) -> #name { + #name { syntax: node.syntax } + } + } + )* + }, + ) + }) + .unzip(); + + let enum_names = grammar.enums.iter().map(|it| &it.name); + let node_names = grammar.nodes.iter().map(|it| &it.name); + + let display_impls = + enum_names.chain(node_names.clone()).map(|it| format_ident!("{}", it)).map(|name| { + quote! { + impl std::fmt::Display for #name { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } + } + } + }); + + let defined_nodes: HashSet<_> = node_names.collect(); + + for node in kinds + .nodes + .iter() + .map(|kind| to_pascal_case(kind)) + .filter(|name| !defined_nodes.iter().any(|&it| it == name)) + { + drop(node) + // FIXME: restore this + // eprintln!("Warning: node {} not defined in ast source", node); + } + + let ast = quote! { + #![allow(non_snake_case)] + use crate::{ + SyntaxNode, SyntaxToken, SyntaxKind::{self, *}, + ast::{self, AstNode, AstChildren, support}, + T, + }; + + #(#node_defs)* + #(#enum_defs)* + #(#any_node_defs)* + #(#node_boilerplate_impls)* + #(#enum_boilerplate_impls)* + #(#any_node_boilerplate_impls)* + #(#display_impls)* + }; + + let ast = ast.to_string().replace("T ! [", "T!["); + + let mut res = String::with_capacity(ast.len() * 2); + + let mut docs = + grammar.nodes.iter().map(|it| &it.doc).chain(grammar.enums.iter().map(|it| &it.doc)); + + for chunk in ast.split("# [pretty_doc_comment_placeholder_workaround] ") { + res.push_str(chunk); + if let Some(doc) = docs.next() { + write_doc_comment(doc, &mut res); + } + } + + let res = add_preamble(crate::flags::CodegenType::Grammar, reformat(res)); + res.replace("#[derive", "\n#[derive") +} + +fn write_doc_comment(contents: &[String], dest: &mut String) { + for line in contents { + writeln!(dest, "///{line}").unwrap(); + } +} + +fn generate_syntax_kinds(grammar: KindsSrc) -> String { + let (single_byte_tokens_values, single_byte_tokens): (Vec<_>, Vec<_>) = grammar + .punct + .iter() + .filter(|(token, _name)| token.len() == 1) + .map(|(token, name)| (token.chars().next().unwrap(), format_ident!("{}", name))) + .unzip(); + + let punctuation_values = grammar.punct.iter().map(|(token, _name)| { + if "{}[]()".contains(token) { + let c = token.chars().next().unwrap(); + quote! { #c } + } else { + let cs = token.chars().map(|c| Punct::new(c, Spacing::Joint)); + quote! { #(#cs)* } + } + }); + let punctuation = + grammar.punct.iter().map(|(_token, name)| format_ident!("{}", name)).collect::>(); + + let fmt_kw_as_variant = |&name| match name { + "Self" => format_ident!("SELF_TYPE_KW"), + name => format_ident!("{}_KW", to_upper_snake_case(name)), + }; + let strict_keywords = grammar.keywords; + let strict_keywords_variants = + strict_keywords.iter().map(fmt_kw_as_variant).collect::>(); + let strict_keywords_tokens = strict_keywords.iter().map(|it| format_ident!("{it}")); + + let edition_dependent_keywords_variants_match_arm = grammar + .edition_dependent_keywords + .iter() + .map(|(kw, ed)| { + let kw = fmt_kw_as_variant(kw); + quote! { #kw if #ed <= edition } + }) + .collect::>(); + let edition_dependent_keywords_str_match_arm = grammar + .edition_dependent_keywords + .iter() + .map(|(kw, ed)| { + quote! { #kw if #ed <= edition } + }) + .collect::>(); + let edition_dependent_keywords_variants = grammar + .edition_dependent_keywords + .iter() + .map(|(kw, _)| fmt_kw_as_variant(kw)) + .collect::>(); + let edition_dependent_keywords_tokens = + grammar.edition_dependent_keywords.iter().map(|(it, _)| format_ident!("{it}")); + + let contextual_keywords = grammar.contextual_keywords; + let contextual_keywords_variants = + contextual_keywords.iter().map(fmt_kw_as_variant).collect::>(); + let contextual_keywords_tokens = contextual_keywords.iter().map(|it| format_ident!("{it}")); + let contextual_keywords_str_match_arm = grammar.contextual_keywords.iter().map(|kw| { + match grammar.edition_dependent_keywords.iter().find(|(ed_kw, _)| ed_kw == kw) { + Some((_, ed)) => quote! { #kw if edition < #ed }, + None => quote! { #kw }, + } + }); + let contextual_keywords_variants_match_arm = grammar + .contextual_keywords + .iter() + .map(|kw_s| { + let kw = fmt_kw_as_variant(kw_s); + match grammar.edition_dependent_keywords.iter().find(|(ed_kw, _)| ed_kw == kw_s) { + Some((_, ed)) => quote! { #kw if edition < #ed }, + None => quote! { #kw }, + } + }) + .collect::>(); + + let non_strict_keyword_variants = contextual_keywords_variants + .iter() + .chain(edition_dependent_keywords_variants.iter()) + .sorted() + .dedup() + .collect::>(); + + let literals = + grammar.literals.iter().map(|name| format_ident!("{}", name)).collect::>(); + + let tokens = grammar.tokens.iter().map(|name| format_ident!("{}", name)).collect::>(); + + let nodes = grammar.nodes.iter().map(|name| format_ident!("{}", name)).collect::>(); + + let ast = quote! { + #![allow(bad_style, missing_docs, unreachable_pub)] + use crate::Edition; + + /// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT`. + #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] + #[repr(u16)] + pub enum SyntaxKind { + // Technical SyntaxKinds: they appear temporally during parsing, + // but never end up in the final tree + #[doc(hidden)] + TOMBSTONE, + #[doc(hidden)] + EOF, + #(#punctuation,)* + #(#strict_keywords_variants,)* + #(#non_strict_keyword_variants,)* + #(#literals,)* + #(#tokens,)* + #(#nodes,)* + + // Technical kind so that we can cast from u16 safely + #[doc(hidden)] + __LAST, + } + use self::SyntaxKind::*; + + impl SyntaxKind { + /// Checks whether this syntax kind is a strict keyword for the given edition. + /// Strict keywords are identifiers that are always considered keywords. + pub fn is_strict_keyword(self, edition: Edition) -> bool { + matches!(self, #(#strict_keywords_variants)|*) + || match self { + #(#edition_dependent_keywords_variants_match_arm => true,)* + _ => false, + } + } + + /// Checks whether this syntax kind is a weak keyword for the given edition. + /// Weak keywords are identifiers that are considered keywords only in certain contexts. + pub fn is_contextual_keyword(self, edition: Edition) -> bool { + match self { + #(#contextual_keywords_variants_match_arm => true,)* + _ => false, + } + } + + /// Checks whether this syntax kind is a strict or weak keyword for the given edition. + pub fn is_keyword(self, edition: Edition) -> bool { + matches!(self, #(#strict_keywords_variants)|*) + || match self { + #(#edition_dependent_keywords_variants_match_arm => true,)* + #(#contextual_keywords_variants_match_arm => true,)* + _ => false, + } + } + + pub fn is_punct(self) -> bool { + matches!(self, #(#punctuation)|*) + } + + pub fn is_literal(self) -> bool { + matches!(self, #(#literals)|*) + } + + pub fn from_keyword(ident: &str, edition: Edition) -> Option { + let kw = match ident { + #(#strict_keywords => #strict_keywords_variants,)* + #(#edition_dependent_keywords_str_match_arm => #edition_dependent_keywords_variants,)* + _ => return None, + }; + Some(kw) + } + + pub fn from_contextual_keyword(ident: &str, edition: Edition) -> Option { + let kw = match ident { + #(#contextual_keywords_str_match_arm => #contextual_keywords_variants,)* + _ => return None, + }; + Some(kw) + } + + pub fn from_char(c: char) -> Option { + let tok = match c { + #(#single_byte_tokens_values => #single_byte_tokens,)* + _ => return None, + }; + Some(tok) + } + } + + #[macro_export] + macro_rules! T { + #([#punctuation_values] => { $crate::SyntaxKind::#punctuation };)* + #([#strict_keywords_tokens] => { $crate::SyntaxKind::#strict_keywords_variants };)* + #([#contextual_keywords_tokens] => { $crate::SyntaxKind::#contextual_keywords_variants };)* + #([#edition_dependent_keywords_tokens] => { $crate::SyntaxKind::#edition_dependent_keywords_variants };)* + [lifetime_ident] => { $crate::SyntaxKind::LIFETIME_IDENT }; + [int_number] => { $crate::SyntaxKind::INT_NUMBER }; + [ident] => { $crate::SyntaxKind::IDENT }; + [string] => { $crate::SyntaxKind::STRING }; + [shebang] => { $crate::SyntaxKind::SHEBANG }; + } + }; + + add_preamble(crate::flags::CodegenType::Grammar, reformat(ast.to_string())) +} + +fn to_upper_snake_case(s: &str) -> String { + let mut buf = String::with_capacity(s.len()); + let mut prev = false; + for c in s.chars() { + if c.is_ascii_uppercase() && prev { + buf.push('_') + } + prev = true; + + buf.push(c.to_ascii_uppercase()); + } + buf +} + +fn to_lower_snake_case(s: &str) -> String { + let mut buf = String::with_capacity(s.len()); + let mut prev = false; + for c in s.chars() { + if c.is_ascii_uppercase() && prev { + buf.push('_') + } + prev = true; + + buf.push(c.to_ascii_lowercase()); + } + buf +} + +fn to_pascal_case(s: &str) -> String { + let mut buf = String::with_capacity(s.len()); + let mut prev_is_underscore = true; + for c in s.chars() { + if c == '_' { + prev_is_underscore = true; + } else if prev_is_underscore { + buf.push(c.to_ascii_uppercase()); + prev_is_underscore = false; + } else { + buf.push(c.to_ascii_lowercase()); + } + } + buf +} + +fn pluralize(s: &str) -> String { + format!("{s}s") +} + +impl Field { + fn is_many(&self) -> bool { + matches!(self, Field::Node { cardinality: Cardinality::Many, .. }) + } + fn token_kind(&self) -> Option { + match self { + Field::Token(token) => { + let token: proc_macro2::TokenStream = token.parse().unwrap(); + Some(quote! { T![#token] }) + } + _ => None, + } + } + fn method_name(&self) -> String { + match self { + Field::Token(name) => { + let name = match name.as_str() { + ";" => "semicolon", + "->" => "thin_arrow", + "'{'" => "l_curly", + "'}'" => "r_curly", + "'('" => "l_paren", + "')'" => "r_paren", + "'['" => "l_brack", + "']'" => "r_brack", + "<" => "l_angle", + ">" => "r_angle", + "=" => "eq", + "!" => "excl", + "*" => "star", + "&" => "amp", + "-" => "minus", + "_" => "underscore", + "." => "dot", + ".." => "dotdot", + "..." => "dotdotdot", + "..=" => "dotdoteq", + "=>" => "fat_arrow", + "@" => "at", + ":" => "colon", + "::" => "coloncolon", + "#" => "pound", + "?" => "question_mark", + "," => "comma", + "|" => "pipe", + "~" => "tilde", + _ => name, + }; + format!("{name}_token",) + } + Field::Node { name, .. } => { + if name == "type" { + String::from("ty") + } else { + name.to_owned() + } + } + } + } + fn ty(&self) -> proc_macro2::Ident { + match self { + Field::Token(_) => format_ident!("SyntaxToken"), + Field::Node { ty, .. } => format_ident!("{}", ty), + } + } +} + +fn clean_token_name(name: &str) -> String { + let cleaned = name.trim_start_matches(['@', '#', '?']); + if cleaned.is_empty() { + name.to_owned() + } else { + cleaned.to_owned() + } +} + +fn lower(grammar: &Grammar) -> AstSrc { + let mut res = AstSrc { + tokens: + "Whitespace Comment String ByteString CString IntNumber FloatNumber Char Byte Ident" + .split_ascii_whitespace() + .map(|it| it.to_owned()) + .collect::>(), + ..Default::default() + }; + + let nodes = grammar.iter().collect::>(); + + for &node in &nodes { + let name = grammar[node].name.clone(); + let rule = &grammar[node].rule; + match lower_enum(grammar, rule) { + Some(variants) => { + let enum_src = AstEnumSrc { doc: Vec::new(), name, traits: Vec::new(), variants }; + res.enums.push(enum_src); + } + None => { + let mut fields = Vec::new(); + lower_rule(&mut fields, grammar, None, rule); + res.nodes.push(AstNodeSrc { doc: Vec::new(), name, traits: Vec::new(), fields }); + } + } + } + + deduplicate_fields(&mut res); + extract_enums(&mut res); + extract_struct_traits(&mut res); + extract_enum_traits(&mut res); + res.nodes.sort_by_key(|it| it.name.clone()); + res.enums.sort_by_key(|it| it.name.clone()); + res.tokens.sort(); + res.nodes.iter_mut().for_each(|it| { + it.traits.sort(); + it.fields.sort_by_key(|it| match it { + Field::Token(name) => (true, name.clone()), + Field::Node { name, .. } => (false, name.clone()), + }); + }); + res.enums.iter_mut().for_each(|it| { + it.traits.sort(); + it.variants.sort(); + }); + res +} + +fn lower_enum(grammar: &Grammar, rule: &Rule) -> Option> { + let alternatives = match rule { + Rule::Alt(it) => it, + _ => return None, + }; + let mut variants = Vec::new(); + for alternative in alternatives { + match alternative { + Rule::Node(it) => variants.push(grammar[*it].name.clone()), + Rule::Token(it) if grammar[*it].name == ";" => (), + _ => return None, + } + } + Some(variants) +} + +fn lower_rule(acc: &mut Vec, grammar: &Grammar, label: Option<&String>, rule: &Rule) { + if lower_separated_list(acc, grammar, label, rule) { + return; + } + + match rule { + Rule::Node(node) => { + let ty = grammar[*node].name.clone(); + let name = label.cloned().unwrap_or_else(|| to_lower_snake_case(&ty)); + let field = Field::Node { name, ty, cardinality: Cardinality::Optional }; + acc.push(field); + } + Rule::Token(token) => { + assert!(label.is_none()); + let mut name = clean_token_name(&grammar[*token].name); + if "[]{}()".contains(&name) { + name = format!("'{name}'"); + } + let field = Field::Token(name); + acc.push(field); + } + Rule::Rep(inner) => { + if let Rule::Node(node) = &**inner { + let ty = grammar[*node].name.clone(); + let name = label.cloned().unwrap_or_else(|| pluralize(&to_lower_snake_case(&ty))); + let field = Field::Node { name, ty, cardinality: Cardinality::Many }; + acc.push(field); + return; + } + panic!("unhandled rule: {rule:?}") + } + Rule::Labeled { label: l, rule } => { + assert!(label.is_none()); + let manually_implemented = matches!( + l.as_str(), + "lhs" + | "rhs" + | "then_branch" + | "else_branch" + | "start" + | "end" + | "op" + | "index" + | "base" + | "value" + | "trait" + | "self_ty" + | "iterable" + | "condition" + | "args" + | "body" + ); + if manually_implemented { + return; + } + lower_rule(acc, grammar, Some(l), rule); + } + Rule::Seq(rules) | Rule::Alt(rules) => { + for rule in rules { + lower_rule(acc, grammar, label, rule) + } + } + Rule::Opt(rule) => lower_rule(acc, grammar, label, rule), + } +} + +// (T (',' T)* ','?) +fn lower_separated_list( + acc: &mut Vec, + grammar: &Grammar, + label: Option<&String>, + rule: &Rule, +) -> bool { + let rule = match rule { + Rule::Seq(it) => it, + _ => return false, + }; + let (node, repeat, trailing_sep) = match rule.as_slice() { + [Rule::Node(node), Rule::Rep(repeat), Rule::Opt(trailing_sep)] => { + (node, repeat, Some(trailing_sep)) + } + [Rule::Node(node), Rule::Rep(repeat)] => (node, repeat, None), + _ => return false, + }; + let repeat = match &**repeat { + Rule::Seq(it) => it, + _ => return false, + }; + if !matches!( + repeat.as_slice(), + [comma, Rule::Node(n)] + if trailing_sep.map_or(true, |it| comma == &**it) && n == node + ) { + return false; + } + let ty = grammar[*node].name.clone(); + let name = label.cloned().unwrap_or_else(|| pluralize(&to_lower_snake_case(&ty))); + let field = Field::Node { name, ty, cardinality: Cardinality::Many }; + acc.push(field); + true +} + +fn deduplicate_fields(ast: &mut AstSrc) { + for node in &mut ast.nodes { + let mut i = 0; + 'outer: while i < node.fields.len() { + for j in 0..i { + let f1 = &node.fields[i]; + let f2 = &node.fields[j]; + if f1 == f2 { + node.fields.remove(i); + continue 'outer; + } + } + i += 1; + } + } +} + +fn extract_enums(ast: &mut AstSrc) { + for node in &mut ast.nodes { + for enm in &ast.enums { + let mut to_remove = Vec::new(); + for (i, field) in node.fields.iter().enumerate() { + let ty = field.ty().to_string(); + if enm.variants.iter().any(|it| it == &ty) { + to_remove.push(i); + } + } + if to_remove.len() == enm.variants.len() { + node.remove_field(to_remove); + let ty = enm.name.clone(); + let name = to_lower_snake_case(&ty); + node.fields.push(Field::Node { name, ty, cardinality: Cardinality::Optional }); + } + } + } +} + +const TRAITS: &[(&str, &[&str])] = &[ + ("HasAttrs", &["attrs"]), + ("HasName", &["name"]), + ("HasVisibility", &["visibility"]), + ("HasGenericParams", &["generic_param_list", "where_clause"]), + ("HasGenericArgs", &["generic_arg_list"]), + ("HasTypeBounds", &["type_bound_list", "colon_token"]), + ("HasModuleItem", &["items"]), + ("HasLoopBody", &["label", "loop_body"]), + ("HasArgList", &["arg_list"]), +]; + +fn extract_struct_traits(ast: &mut AstSrc) { + for node in &mut ast.nodes { + for (name, methods) in TRAITS { + extract_struct_trait(node, name, methods); + } + } + + let nodes_with_doc_comments = [ + "SourceFile", + "Fn", + "Struct", + "Union", + "RecordField", + "TupleField", + "Enum", + "Variant", + "Trait", + "TraitAlias", + "Module", + "Static", + "Const", + "TypeAlias", + "Impl", + "ExternBlock", + "ExternCrate", + "MacroCall", + "MacroRules", + "MacroDef", + "Use", + ]; + + for node in &mut ast.nodes { + if nodes_with_doc_comments.contains(&&*node.name) { + node.traits.push("HasDocComments".into()); + } + } +} + +fn extract_struct_trait(node: &mut AstNodeSrc, trait_name: &str, methods: &[&str]) { + let mut to_remove = Vec::new(); + for (i, field) in node.fields.iter().enumerate() { + let method_name = field.method_name(); + if methods.iter().any(|&it| it == method_name) { + to_remove.push(i); + } + } + if to_remove.len() == methods.len() { + node.traits.push(trait_name.to_owned()); + node.remove_field(to_remove); + } +} + +fn extract_enum_traits(ast: &mut AstSrc) { + for enm in &mut ast.enums { + if enm.name == "Stmt" { + continue; + } + let nodes = &ast.nodes; + let mut variant_traits = enm + .variants + .iter() + .map(|var| nodes.iter().find(|it| &it.name == var).unwrap()) + .map(|node| node.traits.iter().cloned().collect::>()); + + let mut enum_traits = match variant_traits.next() { + Some(it) => it, + None => continue, + }; + for traits in variant_traits { + enum_traits = enum_traits.intersection(&traits).cloned().collect(); + } + enm.traits = enum_traits.into_iter().collect(); + } +} + +impl AstNodeSrc { + fn remove_field(&mut self, to_remove: Vec) { + to_remove.into_iter().rev().for_each(|idx| { + self.fields.remove(idx); + }); + } +} + +#[test] +fn test() { + generate(true); +} diff --git a/rust/generate-schema/src/codegen/grammar/ast_src.rs b/rust/generate-schema/src/codegen/grammar/ast_src.rs new file mode 100644 index 000000000000..34151bd95876 --- /dev/null +++ b/rust/generate-schema/src/codegen/grammar/ast_src.rs @@ -0,0 +1,244 @@ +//! Defines input for code generation process. + +use quote::ToTokens; + +use crate::codegen::grammar::to_upper_snake_case; + +#[derive(Copy, Clone, Debug)] +pub(crate) struct KindsSrc { + pub(crate) punct: &'static [(&'static str, &'static str)], + pub(crate) keywords: &'static [&'static str], + pub(crate) contextual_keywords: &'static [&'static str], + pub(crate) literals: &'static [&'static str], + pub(crate) tokens: &'static [&'static str], + pub(crate) nodes: &'static [&'static str], + pub(crate) edition_dependent_keywords: &'static [(&'static str, Edition)], +} + +#[allow(dead_code)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub(super) enum Edition { + Edition2015, + Edition2018, + Edition2021, + Edition2024, +} + +impl ToTokens for Edition { + fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { + match self { + Edition::Edition2015 => { + tokens.extend(quote::quote! { Edition::Edition2015 }); + } + Edition::Edition2018 => { + tokens.extend(quote::quote! { Edition::Edition2018 }); + } + Edition::Edition2021 => { + tokens.extend(quote::quote! { Edition::Edition2021 }); + } + Edition::Edition2024 => { + tokens.extend(quote::quote! { Edition::Edition2024 }); + } + } + } +} + +/// The punctuations of the language. +const PUNCT: &[(&str, &str)] = &[ + // KEEP THE DOLLAR AT THE TOP ITS SPECIAL + ("$", "DOLLAR"), + (";", "SEMICOLON"), + (",", "COMMA"), + ("(", "L_PAREN"), + (")", "R_PAREN"), + ("{", "L_CURLY"), + ("}", "R_CURLY"), + ("[", "L_BRACK"), + ("]", "R_BRACK"), + ("<", "L_ANGLE"), + (">", "R_ANGLE"), + ("@", "AT"), + ("#", "POUND"), + ("~", "TILDE"), + ("?", "QUESTION"), + ("&", "AMP"), + ("|", "PIPE"), + ("+", "PLUS"), + ("*", "STAR"), + ("/", "SLASH"), + ("^", "CARET"), + ("%", "PERCENT"), + ("_", "UNDERSCORE"), + (".", "DOT"), + ("..", "DOT2"), + ("...", "DOT3"), + ("..=", "DOT2EQ"), + (":", "COLON"), + ("::", "COLON2"), + ("=", "EQ"), + ("==", "EQ2"), + ("=>", "FAT_ARROW"), + ("!", "BANG"), + ("!=", "NEQ"), + ("-", "MINUS"), + ("->", "THIN_ARROW"), + ("<=", "LTEQ"), + (">=", "GTEQ"), + ("+=", "PLUSEQ"), + ("-=", "MINUSEQ"), + ("|=", "PIPEEQ"), + ("&=", "AMPEQ"), + ("^=", "CARETEQ"), + ("/=", "SLASHEQ"), + ("*=", "STAREQ"), + ("%=", "PERCENTEQ"), + ("&&", "AMP2"), + ("||", "PIPE2"), + ("<<", "SHL"), + (">>", "SHR"), + ("<<=", "SHLEQ"), + (">>=", "SHREQ"), +]; +const TOKENS: &[&str] = &["ERROR", "WHITESPACE", "NEWLINE", "COMMENT"]; +// &["ERROR", "IDENT", "WHITESPACE", "LIFETIME_IDENT", "COMMENT", "SHEBANG"],; + +const EOF: &str = "EOF"; + +const RESERVED: &[&str] = &[ + "abstract", "become", "box", "do", "final", "macro", "override", "priv", "typeof", "unsized", + "virtual", "yield", +]; +// keywords that are keywords only in specific parse contexts +#[doc(alias = "WEAK_KEYWORDS")] +const CONTEXTUAL_KEYWORDS: &[&str] = + &["macro_rules", "union", "default", "raw", "dyn", "auto", "yeet"]; +// keywords we use for special macro expansions +const CONTEXTUAL_BUILTIN_KEYWORDS: &[&str] = &["builtin", "offset_of", "format_args", "asm"]; +// keywords that are keywords depending on the edition +const EDITION_DEPENDENT_KEYWORDS: &[(&str, Edition)] = &[ + ("try", Edition::Edition2018), + ("dyn", Edition::Edition2018), + ("async", Edition::Edition2018), + ("await", Edition::Edition2018), + ("gen", Edition::Edition2024), +]; + +pub(crate) fn generate_kind_src( + nodes: &[AstNodeSrc], + enums: &[AstEnumSrc], + grammar: &ungrammar::Grammar, +) -> KindsSrc { + let mut contextual_keywords: Vec<&_> = + CONTEXTUAL_KEYWORDS.iter().chain(CONTEXTUAL_BUILTIN_KEYWORDS).copied().collect(); + + let mut keywords: Vec<&_> = Vec::new(); + let mut tokens: Vec<&_> = TOKENS.to_vec(); + let mut literals: Vec<&_> = Vec::new(); + let mut used_puncts = vec![false; PUNCT.len()]; + // Mark $ as used + used_puncts[0] = true; + grammar.tokens().for_each(|token| { + let name = &*grammar[token].name; + if name == EOF { + return; + } + match name.split_at(1) { + ("@", lit) if !lit.is_empty() => { + literals.push(String::leak(to_upper_snake_case(lit))); + } + ("#", token) if !token.is_empty() => { + tokens.push(String::leak(to_upper_snake_case(token))); + } + _ if contextual_keywords.contains(&name) => {} + _ if name.chars().all(char::is_alphabetic) => { + keywords.push(String::leak(name.to_owned())); + } + _ => { + let idx = PUNCT + .iter() + .position(|(punct, _)| punct == &name) + .unwrap_or_else(|| panic!("Grammar references unknown punctuation {name:?}")); + used_puncts[idx] = true; + } + } + }); + PUNCT.iter().zip(used_puncts).filter(|(_, used)| !used).for_each(|((punct, _), _)| { + panic!("Punctuation {punct:?} is not used in grammar"); + }); + keywords.extend(RESERVED.iter().copied()); + keywords.sort(); + keywords.dedup(); + contextual_keywords.sort(); + contextual_keywords.dedup(); + let mut edition_dependent_keywords: Vec<(&_, _)> = EDITION_DEPENDENT_KEYWORDS.to_vec(); + edition_dependent_keywords.sort(); + edition_dependent_keywords.dedup(); + + keywords.retain(|&it| !contextual_keywords.contains(&it)); + keywords.retain(|&it| !edition_dependent_keywords.iter().any(|&(kw, _)| kw == it)); + + // we leak things here for simplicity, that way we don't have to deal with lifetimes + // The execution is a one shot job so thats fine + let nodes = nodes + .iter() + .map(|it| &it.name) + .chain(enums.iter().map(|it| &it.name)) + .map(|it| to_upper_snake_case(it)) + .map(String::leak) + .map(|it| &*it) + .collect(); + let nodes = Vec::leak(nodes); + nodes.sort(); + let keywords = Vec::leak(keywords); + let contextual_keywords = Vec::leak(contextual_keywords); + let edition_dependent_keywords = Vec::leak(edition_dependent_keywords); + let literals = Vec::leak(literals); + literals.sort(); + let tokens = Vec::leak(tokens); + tokens.sort(); + + KindsSrc { + punct: PUNCT, + nodes, + keywords, + contextual_keywords, + edition_dependent_keywords, + literals, + tokens, + } +} + +#[derive(Default, Debug)] +pub(crate) struct AstSrc { + pub(crate) tokens: Vec, + pub(crate) nodes: Vec, + pub(crate) enums: Vec, +} + +#[derive(Debug)] +pub(crate) struct AstNodeSrc { + pub(crate) doc: Vec, + pub(crate) name: String, + pub(crate) traits: Vec, + pub(crate) fields: Vec, +} + +#[derive(Debug, Eq, PartialEq)] +pub(crate) enum Field { + Token(String), + Node { name: String, ty: String, cardinality: Cardinality }, +} + +#[derive(Debug, Eq, PartialEq)] +pub(crate) enum Cardinality { + Optional, + Many, +} + +#[derive(Debug)] +pub(crate) struct AstEnumSrc { + pub(crate) doc: Vec, + pub(crate) name: String, + pub(crate) traits: Vec, + pub(crate) variants: Vec, +} From 61ac8d66f545a8f81cb7a5f1fd0331a2fd37b3a0 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Fri, 13 Sep 2024 16:57:54 +0200 Subject: [PATCH 04/12] Rust: make things compile --- Cargo.lock | 12 ++++++++++++ rust/generate-schema/src/codegen.rs | 17 +++++++++++++++++ rust/generate-schema/src/flags.rs | 11 +++++++++++ rust/generate-schema/src/main.rs | 12 ++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 rust/generate-schema/src/codegen.rs create mode 100644 rust/generate-schema/src/flags.rs diff --git a/Cargo.lock b/Cargo.lock index 8fc64a693101..c7310c075153 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -684,6 +684,9 @@ checksum = "7ab85b9b05e3978cc9a9cf8fea7f01b494e1a09ed3037e16ba39edc7a29eb61a" name = "generate-schema" version = "0.1.0" dependencies = [ + "itertools 0.10.5", + "proc-macro2", + "quote", "ungrammar", ] @@ -856,6 +859,15 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.12.1" diff --git a/rust/generate-schema/src/codegen.rs b/rust/generate-schema/src/codegen.rs new file mode 100644 index 000000000000..94ee8ef7a75a --- /dev/null +++ b/rust/generate-schema/src/codegen.rs @@ -0,0 +1,17 @@ +pub mod grammar; + +pub fn reformat(x: String) -> String { + x +} + +pub fn add_preamble(_x: crate::flags::CodegenType, y: String) -> String { + y +} +pub fn ensure_file_contents( + _x: crate::flags::CodegenType, + path: &std::path::Path, + contents: &String, + _check: bool, +) { + std::fs::write(path, contents).expect("Unable to write file"); +} diff --git a/rust/generate-schema/src/flags.rs b/rust/generate-schema/src/flags.rs new file mode 100644 index 000000000000..4938ed46b453 --- /dev/null +++ b/rust/generate-schema/src/flags.rs @@ -0,0 +1,11 @@ +use std::fmt::Display; + +pub enum CodegenType { + Grammar, +} + +impl Display for CodegenType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "Grammar") + } +} diff --git a/rust/generate-schema/src/main.rs b/rust/generate-schema/src/main.rs index e69de29bb2d1..4b3656339ca4 100644 --- a/rust/generate-schema/src/main.rs +++ b/rust/generate-schema/src/main.rs @@ -0,0 +1,12 @@ +use std::path::PathBuf; + +mod codegen; +mod flags; +use std::env; + +fn project_root() -> PathBuf { + let dir = + env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| env!("CARGO_MANIFEST_DIR").to_owned()); + PathBuf::from(dir).parent().unwrap().to_owned() +} +fn main() {} From 1f30d5f41b6a921bcc2b4b2cbf5f4cf236d96ca4 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Fri, 13 Sep 2024 16:57:54 +0200 Subject: [PATCH 05/12] Rust: generate schema.py and extractor from ungrammar --- Cargo.lock | 1 + MODULE.bazel | 1 + rust/extractor/Cargo.toml | 1 + rust/extractor/src/main.rs | 88 +--- rust/generate-schema/BUILD.bazel | 14 + rust/generate-schema/src/codegen.rs | 1 - rust/generate-schema/src/codegen/grammar.rs | 20 +- rust/generate-schema/src/main.rs | 497 +++++++++++++++++++- 8 files changed, 539 insertions(+), 84 deletions(-) create mode 100644 rust/generate-schema/BUILD.bazel diff --git a/Cargo.lock b/Cargo.lock index c7310c075153..a0d31f77ad8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -382,6 +382,7 @@ dependencies = [ "ra_ap_hir_def", "ra_ap_ide_db", "ra_ap_load-cargo", + "ra_ap_parser", "ra_ap_paths", "ra_ap_project_model", "ra_ap_syntax", diff --git a/MODULE.bazel b/MODULE.bazel index b539dee7874f..d1ff8b0b8d2a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -61,6 +61,7 @@ r.from_cargo( "//ruby/extractor:Cargo.toml", "//rust/extractor:Cargo.toml", "//rust/extractor/macros:Cargo.toml", + "//rust/generate-schema:Cargo.toml", "//shared/tree-sitter-extractor:Cargo.toml", ], ) diff --git a/rust/extractor/Cargo.toml b/rust/extractor/Cargo.toml index 550c3b514411..71ad6d8ac452 100644 --- a/rust/extractor/Cargo.toml +++ b/rust/extractor/Cargo.toml @@ -18,6 +18,7 @@ ra_ap_paths = "0.0.232" ra_ap_project_model = "0.0.232" ra_ap_syntax = "0.0.232" ra_ap_vfs = "0.0.232" +ra_ap_parser = "0.0.232" serde = "1.0.209" serde_with = "3.9.0" stderrlog = "0.6.0" diff --git a/rust/extractor/src/main.rs b/rust/extractor/src/main.rs index 77c15d994a8e..160421456626 100644 --- a/rust/extractor/src/main.rs +++ b/rust/extractor/src/main.rs @@ -1,37 +1,11 @@ -use crate::trap::TrapId; use anyhow::Context; -use itertools::Itertools; -use log::info; -use ra_ap_hir::db::DefDatabase; -use ra_ap_hir::Crate; -use ra_ap_load_cargo::{load_workspace_at, LoadCargoConfig, ProcMacroServerChoice}; -use ra_ap_project_model::CargoConfig; -use ra_ap_project_model::RustLibSource; -use ra_ap_vfs::AbsPathBuf; -use std::path::PathBuf; - +use ra_ap_ide_db::line_index::LineIndex; mod archive; mod config; pub mod generated; mod translate; pub mod trap; -fn find_project_manifests( - files: &[PathBuf], -) -> anyhow::Result> { - let current = std::env::current_dir()?; - let abs_files: Vec<_> = files - .iter() - .map(|path| AbsPathBuf::assert_utf8(current.join(path))) - .collect(); - let ret = ra_ap_project_model::ProjectManifest::discover_all(&abs_files); - info!( - "found manifests: {}", - ret.iter().map(|m| format!("{m}")).join(", ") - ); - Ok(ret) -} - fn main() -> anyhow::Result<()> { let cfg = config::Config::extract().context("failed to load configuration")?; stderrlog::new() @@ -43,52 +17,20 @@ fn main() -> anyhow::Result<()> { let archiver = archive::Archiver { root: cfg.source_archive_dir, }; - - let config = CargoConfig { - sysroot: Some(RustLibSource::Discover), - target_dir: ra_ap_paths::Utf8PathBuf::from_path_buf(cfg.scratch_dir) - .map(|x| x.join("target")) - .ok(), - ..Default::default() - }; - let progress = |t| (log::info!("progress: {}", t)); - let load_config = LoadCargoConfig { - load_out_dirs_from_check: true, - with_proc_macro_server: ProcMacroServerChoice::Sysroot, - prefill_caches: false, - }; - let projects = find_project_manifests(&cfg.inputs).context("loading inputs")?; - for project in projects { - let (db, vfs, _macro_server) = load_workspace_at( - project.manifest_path().as_ref(), - &config, - &load_config, - &progress, - )?; - - let crates = ::crate_graph(&db); - for crate_id in crates.iter() { - let krate = Crate::from(crate_id); - if !cfg.extract_dependencies && !krate.origin(&db).is_local() { - continue; - } - let name = krate.display_name(&db); - let crate_name = name - .as_ref() - .map(|n| n.canonical_name().as_str()) - .unwrap_or(""); - let trap = traps.create( - "crates", - &PathBuf::from(format!( - "/{}_{}", - crate_name, - crate_id.into_raw().into_u32() - )), - ); - translate::CrateTranslator::new(&db, trap, &krate, &vfs, &archiver) - .emit_crate() - .context("writing trap file")?; - } + for file in cfg.inputs { + let file = std::path::absolute(&file).unwrap_or(file); + let file = std::fs::canonicalize(&file).unwrap_or(file); + archiver.archive(&file); + let input = std::fs::read(&file)?; + let input = String::from_utf8(input)?; + let line_index = LineIndex::new(&input); + let display_path = file.to_string_lossy(); + let mut trap = traps.create("source", &file); + let label = trap.emit_file(&file); + translate::SourceFileTranslator::new(trap, label, line_index) + .extract(&display_path, &input) + .context("writing trap file")?; } + Ok(()) } diff --git a/rust/generate-schema/BUILD.bazel b/rust/generate-schema/BUILD.bazel new file mode 100644 index 000000000000..2a1be1d2c1ad --- /dev/null +++ b/rust/generate-schema/BUILD.bazel @@ -0,0 +1,14 @@ +load("//misc/bazel:rust.bzl", "codeql_rust_binary") + +codeql_rust_binary( + name = "generate-schema", + srcs = glob(["src/**/*.rs"]), + aliases = aliases(), + proc_macro_deps = all_crate_deps( + proc_macro = True, + ), + visibility = ["//rust:__subpackages__"], + deps = all_crate_deps( + normal = True, + ), +) diff --git a/rust/generate-schema/src/codegen.rs b/rust/generate-schema/src/codegen.rs index 94ee8ef7a75a..337a42bef195 100644 --- a/rust/generate-schema/src/codegen.rs +++ b/rust/generate-schema/src/codegen.rs @@ -1,5 +1,4 @@ pub mod grammar; - pub fn reformat(x: String) -> String { x } diff --git a/rust/generate-schema/src/codegen/grammar.rs b/rust/generate-schema/src/codegen/grammar.rs index 39e06f9642db..85a84bf05f77 100644 --- a/rust/generate-schema/src/codegen/grammar.rs +++ b/rust/generate-schema/src/codegen/grammar.rs @@ -21,7 +21,7 @@ use crate::{ project_root, }; -mod ast_src; +pub mod ast_src; use self::ast_src::{AstEnumSrc, AstNodeSrc, AstSrc, Cardinality, Field, KindsSrc}; pub(crate) fn generate(check: bool) { @@ -621,10 +621,16 @@ fn pluralize(s: &str) -> String { } impl Field { - fn is_many(&self) -> bool { - matches!(self, Field::Node { cardinality: Cardinality::Many, .. }) + pub fn is_many(&self) -> bool { + matches!( + self, + Field::Node { + cardinality: Cardinality::Many, + .. + } + ) } - fn token_kind(&self) -> Option { + pub fn token_kind(&self) -> Option { match self { Field::Token(token) => { let token: proc_macro2::TokenStream = token.parse().unwrap(); @@ -633,7 +639,7 @@ impl Field { _ => None, } } - fn method_name(&self) -> String { + pub fn method_name(&self) -> String { match self { Field::Token(name) => { let name = match name.as_str() { @@ -679,7 +685,7 @@ impl Field { } } } - fn ty(&self) -> proc_macro2::Ident { + pub fn ty(&self) -> proc_macro2::Ident { match self { Field::Token(_) => format_ident!("SyntaxToken"), Field::Node { ty, .. } => format_ident!("{}", ty), @@ -696,7 +702,7 @@ fn clean_token_name(name: &str) -> String { } } -fn lower(grammar: &Grammar) -> AstSrc { +pub(crate) fn lower(grammar: &Grammar) -> AstSrc { let mut res = AstSrc { tokens: "Whitespace Comment String ByteString CString IntNumber FloatNumber Char Byte Ident" diff --git a/rust/generate-schema/src/main.rs b/rust/generate-schema/src/main.rs index 4b3656339ca4..693614044461 100644 --- a/rust/generate-schema/src/main.rs +++ b/rust/generate-schema/src/main.rs @@ -1,12 +1,503 @@ -use std::path::PathBuf; +use std::{fs, path::PathBuf}; -mod codegen; +pub mod codegen; mod flags; +use codegen::grammar::ast_src::{AstNodeSrc, AstSrc}; +use std::collections::{BTreeMap, BTreeSet}; use std::env; +use ungrammar::Grammar; fn project_root() -> PathBuf { let dir = env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| env!("CARGO_MANIFEST_DIR").to_owned()); PathBuf::from(dir).parent().unwrap().to_owned() } -fn main() {} + +fn class_name(type_name: &String) -> String { + match type_name.as_str() { + "BinExpr" => "BinaryExpr".to_owned(), + "ElseBranch" => "Expr".to_owned(), + "Fn" => "Function".to_owned(), + "Literal" => "LiteralExpr".to_owned(), + "Type" => "TypeRef".to_owned(), + _ => type_name.to_owned(), + } +} + +fn property_name(type_name: &String, field_name: &String) -> String { + match (type_name.as_str(), field_name.as_str()) { + ("Path", "segment") => "part".to_owned(), + (_, "then_branch") => "then".to_owned(), + (_, "else_branch") => "else_".to_owned(), + _ => field_name.to_owned(), + } +} + +fn to_lower_snake_case(s: &str) -> String { + let mut buf = String::with_capacity(s.len()); + let mut prev = false; + for c in s.chars() { + if c.is_ascii_uppercase() && prev { + buf.push('_') + } + prev = true; + + buf.push(c.to_ascii_lowercase()); + } + buf +} + +fn print_schema(grammar: &AstSrc, super_types: BTreeMap>) { + for node in &grammar.enums { + let super_classses = if let Some(cls) = super_types.get(&node.name) { + let super_classes: Vec = cls.iter().map(|x| class_name(x)).collect(); + super_classes.join(",") + } else { + "AstNode".to_owned() + }; + println!("class {}({}):", class_name(&node.name), super_classses); + println!(" pass"); + println!(""); + } + for node in &grammar.nodes { + let super_classses = if let Some(cls) = super_types.get(&node.name) { + let super_classes: Vec = cls.iter().map(|x| class_name(x)).collect(); + super_classes.join(",") + } else { + "AstNode".to_owned() + }; + println!("class {}({}):", class_name(&node.name), super_classses); + let mut empty = true; + for field in get_fields(node) { + if field.tp == "SyntaxToken" { + continue; + } + + empty = false; + if field.tp == "string" { + println!( + " {}: optional[string]", + property_name(&node.name, &field.name), + ); + } else { + let list = field.is_many; + let (o, c) = if list { + ("list[", "]") + } else { + ("optional[", "]") + }; + println!( + " {}: {}\"{}\"{} | child", + property_name(&node.name, &field.name), + o, + class_name(&field.tp), + c + ); + }; + } + if empty { + println!(" pass"); + } + println!(""); + } +} + +struct FieldInfo { + name: String, + tp: String, + is_many: bool, +} +fn get_fields(node: &AstNodeSrc) -> Vec { + let mut result = Vec::new(); + + match node.name.as_str() { + "Name" | "NameRef" | "Lifetime" => { + result.push(FieldInfo { + name: "text".to_string(), + tp: "string".to_string(), + is_many: false, + }); + } + "Abi" => { + result.push(FieldInfo { + name: "abi_string".to_string(), + tp: "string".to_string(), + is_many: false, + }); + } + "Literal" => { + result.push(FieldInfo { + name: "text_value".to_string(), + tp: "string".to_string(), + is_many: false, + }); + } + "PrefixExpr" => { + result.push(FieldInfo { + name: "operator_name".to_string(), + tp: "string".to_string(), + is_many: false, + }); + } + "BinExpr" => { + result.push(FieldInfo { + name: "lhs".to_string(), + tp: "Expr".to_string(), + is_many: false, + }); + result.push(FieldInfo { + name: "rhs".to_string(), + tp: "Expr".to_string(), + is_many: false, + }); + result.push(FieldInfo { + name: "operator_name".to_string(), + tp: "string".to_string(), + is_many: false, + }); + } + "IfExpr" => { + result.push(FieldInfo { + name: "then_branch".to_string(), + tp: "BlockExpr".to_string(), + is_many: false, + }); + result.push(FieldInfo { + name: "else_branch".to_string(), + tp: "ElseBranch".to_string(), + is_many: false, + }); + result.push(FieldInfo { + name: "condition".to_string(), + tp: "Expr".to_string(), + is_many: false, + }); + } + "RangeExpr" => { + result.push(FieldInfo { + name: "start".to_string(), + tp: "Expr".to_string(), + is_many: false, + }); + result.push(FieldInfo { + name: "end".to_string(), + tp: "Expr".to_string(), + is_many: false, + }); + result.push(FieldInfo { + name: "operator_name".to_string(), + tp: "string".to_string(), + is_many: false, + }); + } + "RangePat" => { + result.push(FieldInfo { + name: "start".to_string(), + tp: "Pat".to_string(), + is_many: false, + }); + result.push(FieldInfo { + name: "end".to_string(), + tp: "Pat".to_string(), + is_many: false, + }); + result.push(FieldInfo { + name: "operator_name".to_string(), + tp: "string".to_string(), + is_many: false, + }); + } + "IndexExpr" => { + result.push(FieldInfo { + name: "index".to_string(), + tp: "Expr".to_string(), + is_many: false, + }); + result.push(FieldInfo { + name: "base".to_string(), + tp: "Expr".to_string(), + is_many: false, + }); + } + "Impl" => { + result.push(FieldInfo { + name: "trait_".to_string(), + tp: "Type".to_string(), + is_many: false, + }); + result.push(FieldInfo { + name: "self_ty".to_string(), + tp: "Type".to_string(), + is_many: false, + }); + } + "ForExpr" => { + result.push(FieldInfo { + name: "iterable".to_string(), + tp: "Expr".to_string(), + is_many: false, + }); + } + "WhileExpr" => { + result.push(FieldInfo { + name: "condition".to_string(), + tp: "Expr".to_string(), + is_many: false, + }); + } + "MatchGuard" => { + result.push(FieldInfo { + name: "condition".to_string(), + tp: "Expr".to_string(), + is_many: false, + }); + } + "MacroDef" => { + result.push(FieldInfo { + name: "args".to_string(), + tp: "TokenTree".to_string(), + is_many: false, + }); + result.push(FieldInfo { + name: "body".to_string(), + tp: "TokenTree".to_string(), + is_many: false, + }); + } + "FormatArgsExpr" => { + result.push(FieldInfo { + name: "args".to_string(), + tp: "FormatArgsArg".to_string(), + is_many: true, + }); + } + "ArgList" => { + result.push(FieldInfo { + name: "args".to_string(), + tp: "Expr".to_string(), + is_many: true, + }); + } + "Fn" => { + result.push(FieldInfo { + name: "body".to_string(), + tp: "BlockExpr".to_string(), + is_many: false, + }); + } + "Const" => { + result.push(FieldInfo { + name: "body".to_string(), + tp: "Expr".to_string(), + is_many: false, + }); + } + "Static" => { + result.push(FieldInfo { + name: "body".to_string(), + tp: "Expr".to_string(), + is_many: false, + }); + } + "ClosureExpr" => { + result.push(FieldInfo { + name: "body".to_string(), + tp: "Expr".to_string(), + is_many: false, + }); + } + _ => {} + } + + for field in &node.fields { + // The ArrayExpr type also has an 'exprs' field + if node.name == "ArrayExpr" && field.method_name() == "expr" { + continue; + } + result.push(FieldInfo { + name: field.method_name(), + tp: field.ty().to_string(), + is_many: field.is_many(), + }); + } + for trait_ in &node.traits { + match trait_.as_str() { + "HasAttrs" => result.push(FieldInfo { + name: "attrs".to_owned(), + tp: "Attr".to_owned(), + is_many: true, + }), + "HasName" => result.push(FieldInfo { + name: "name".to_owned(), + tp: "Name".to_owned(), + is_many: false, + }), + "HasVisibility" => result.push(FieldInfo { + name: "visibility".to_owned(), + tp: "Visibility".to_owned(), + is_many: false, + }), + "HasGenericParams" => { + result.push(FieldInfo { + name: "generic_param_list".to_owned(), + tp: "GenericParamList".to_owned(), + is_many: false, + }); + result.push(FieldInfo { + name: "where_clause".to_owned(), + tp: "WhereClause".to_owned(), + is_many: false, + }) + } + "HasGenericArgs" => result.push(FieldInfo { + name: "generic_arg_list".to_owned(), + tp: "GenericArgList".to_owned(), + is_many: false, + }), + "HasTypeBounds" => result.push(FieldInfo { + name: "type_bound_list".to_owned(), + tp: "TypeBoundList".to_owned(), + is_many: false, + }), + "HasModuleItem" => result.push(FieldInfo { + name: "items".to_owned(), + tp: "Item".to_owned(), + is_many: true, + }), + "HasLoopBody" => { + result.push(FieldInfo { + name: "label".to_owned(), + tp: "Label".to_owned(), + is_many: false, + }); + result.push(FieldInfo { + name: "loop_body".to_owned(), + tp: "BlockExpr".to_owned(), + is_many: false, + }) + } + "HasArgList" => result.push(FieldInfo { + name: "arg_list".to_owned(), + tp: "ArgList".to_owned(), + is_many: false, + }), + "HasDocComments" => {} + + _ => panic!("Unknown trait {}", trait_), + }; + } + result.sort_by(|x, y| x.name.cmp(&y.name)); + result +} + +fn print_extractor(grammar: &AstSrc) { + for node in &grammar.enums { + let type_name = &node.name; + let class_name = class_name(&node.name); + + println!( + " fn emit_{}(&mut self, node: ast::{}) -> Label {{", + to_lower_snake_case(type_name), + type_name, + class_name + ); + println!(" match node {{"); + for variant in &node.variants { + println!( + " ast::{}::{}(inner) => self.emit_{}(inner).into(),", + type_name, + variant, + to_lower_snake_case(variant) + ); + } + println!(" }}"); + println!(" }}\n"); + } + + for node in &grammar.nodes { + let type_name = &node.name; + let class_name = class_name(&node.name); + + println!( + " fn emit_{}(&mut self, node: ast::{}) -> Label {{", + to_lower_snake_case(type_name), + type_name, + class_name + ); + for field in get_fields(&node) { + if &field.tp == "SyntaxToken" { + continue; + } + + let type_name = &field.tp; + let struct_field_name = &field.name; + let class_field_name = property_name(&node.name, &field.name); + if field.tp == "string" { + println!(" let {} = node.try_get_text();", class_field_name,); + } else if field.is_many { + println!( + " let {} = node.{}().map(|x| self.emit_{}(x)).collect();", + class_field_name, + struct_field_name, + to_lower_snake_case(type_name) + ); + } else { + println!( + " let {} = node.{}().map(|x| self.emit_{}(x));", + class_field_name, + struct_field_name, + to_lower_snake_case(type_name) + ); + } + } + println!( + " let label = self.trap.emit(generated::{} {{", + class_name + ); + println!(" id: TrapId::Star,"); + for field in get_fields(&node) { + if field.tp == "SyntaxToken" { + continue; + } + + let class_field_name: String = property_name(&node.name, &field.name); + println!(" {},", class_field_name); + } + println!(" }});"); + println!(" self.emit_location(label, node);"); + println!(" label"); + + println!(" }}\n"); + } +} + +fn main() { + let grammar: Grammar = fs::read_to_string(project_root().join("generate-schema/rust.ungram")) + .unwrap() + .parse() + .unwrap(); + let mut grammar = codegen::grammar::lower(&grammar); + grammar + .nodes + .retain(|x| x.name != "MacroStmts" && x.name != "MacroItems"); + + grammar.enums.retain(|x| x.name != "Adt"); + + let mut super_types: BTreeMap> = BTreeMap::new(); + for node in &grammar.enums { + for variant in &node.variants { + let set = super_types + .entry(variant.to_owned()) + .or_insert_with(|| BTreeSet::new()); + set.insert(node.name.to_owned()); + } + } + // sort things while ensuring super clases are defined before they are used + grammar.enums.sort_by(|x, y| { + let super_class_x = super_types.get(&x.name).into_iter().flatten().max(); + let super_class_y = super_types.get(&y.name).into_iter().flatten().max(); + super_class_x.cmp(&super_class_y).then(x.name.cmp(&y.name)) + }); + //print_schema(&grammar, super_types); + print_extractor(&grammar); +} From 9104c3fc81eae0e991f4c95a924c8f147b9348f0 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Mon, 16 Sep 2024 18:59:26 +0200 Subject: [PATCH 06/12] Rust: re-generate schema and extractor --- rust/extractor/src/translate.rs | 3186 ++++++++++++++++++++----------- rust/schema.py | 1459 +++++++------- 2 files changed, 2777 insertions(+), 1868 deletions(-) diff --git a/rust/extractor/src/translate.rs b/rust/extractor/src/translate.rs index d67f8dcbcdaa..3e415db0e7cc 100644 --- a/rust/extractor/src/translate.rs +++ b/rust/extractor/src/translate.rs @@ -1,1120 +1,2176 @@ -use crate::archive::Archiver; -use crate::trap::{AsTrapKeyPart, Label, TrapClass, TrapFile, TrapId}; -use crate::{generated, trap_key}; -use codeql_extractor::trap; -use ra_ap_hir::db::{DefDatabase, InternDatabase}; -use ra_ap_hir::HasSource; -use ra_ap_hir::TypeRef; -use ra_ap_hir::{Crate, Module, ModuleDef}; -use ra_ap_hir_def::body::{Body, BodySourceMap}; -use ra_ap_hir_def::hir::{ - CaptureBy, ExprId, LabelId, MatchArm, PatId, RecordFieldPat, RecordLitField, Statement, -}; -use ra_ap_hir_def::path::Path; +use crate::generated; +use crate::trap::{Label, TrapClass, TrapFile, TrapId}; +use codeql_extractor::trap::{self}; use ra_ap_ide_db::line_index::LineIndex; -use ra_ap_ide_db::{LineIndexDatabase, RootDatabase}; -use ra_ap_syntax::ast::RangeOp; -use ra_ap_syntax::{AstNode, Edition, TextRange, TextSize}; -use ra_ap_vfs::{FileId, Vfs}; -use std::collections::HashMap; -use std::fs; -use std::path::PathBuf; -use triomphe::Arc; - -#[derive(Clone)] -struct FileData { +use ra_ap_syntax::ast::{ + HasArgList, HasAttrs, HasGenericArgs, HasGenericParams, HasLoopBody, HasModuleItem, HasName, + HasTypeBounds, HasVisibility, RangeItem, +}; +use ra_ap_syntax::{ast, AstNode, Edition, SourceFile, TextSize}; + +pub struct SourceFileTranslator { + trap: TrapFile, label: trap::Label, - line_index: Arc, + line_index: LineIndex, } -pub struct CrateTranslator<'a> { - db: &'a RootDatabase, - trap: TrapFile, - krate: &'a Crate, - vfs: &'a Vfs, - archiver: &'a Archiver, - file_labels: HashMap, + +trait TextValue { + fn try_get_text(&self) -> Option; +} + +impl TextValue for ast::Lifetime { + fn try_get_text(&self) -> Option { + self.text().to_string().into() + } +} +impl TextValue for ast::Name { + fn try_get_text(&self) -> Option { + self.text().to_string().into() + } +} +impl TextValue for ast::Literal { + fn try_get_text(&self) -> Option { + self.token().text().to_string().into() + } +} +impl TextValue for ast::NameRef { + fn try_get_text(&self) -> Option { + self.text().to_string().into() + } +} +impl TextValue for ast::Abi { + fn try_get_text(&self) -> Option { + self.abi_string().map(|x| x.to_string()) + } } -impl CrateTranslator<'_> { - pub fn new<'a>( - db: &'a RootDatabase, - trap: TrapFile, - krate: &'a Crate, - vfs: &'a Vfs, - archiver: &'a Archiver, - ) -> CrateTranslator<'a> { - CrateTranslator { - db, +impl TextValue for ast::BinExpr { + fn try_get_text(&self) -> Option { + self.op_token().map(|x| x.text().to_string()) + } +} +impl TextValue for ast::PrefixExpr { + fn try_get_text(&self) -> Option { + self.op_token().map(|x| x.text().to_string()) + } +} +impl TextValue for ast::RangeExpr { + fn try_get_text(&self) -> Option { + self.op_token().map(|x| x.text().to_string()) + } +} +impl TextValue for ast::RangePat { + fn try_get_text(&self) -> Option { + self.op_token().map(|x| x.text().to_string()) + } +} +impl SourceFileTranslator { + pub fn new(trap: TrapFile, label: trap::Label, line_index: LineIndex) -> SourceFileTranslator { + SourceFileTranslator { trap, - krate, - vfs, - archiver, - file_labels: HashMap::new(), + label, + line_index, + } + } + pub fn extract(&mut self, path: &str, input: &str) -> Result<(), std::io::Error> { + let parse = ra_ap_syntax::ast::SourceFile::parse(input, Edition::CURRENT); + for err in parse.errors() { + let start = self.line_index.line_col(err.range().start()); + log::warn!("{}:{}:{}: {}", path, start.line + 1, start.col + 1, err); + } + if let Some(ast) = SourceFile::cast(parse.syntax_node()) { + self.emit_source_file(ast); + } else { + log::warn!("Skipped {}", path); + } + self.trap.commit() + } + fn emit_else_branch(&mut self, node: ast::ElseBranch) -> Label { + match node { + ast::ElseBranch::IfExpr(inner) => self.emit_if_expr(inner).into(), + ast::ElseBranch::Block(inner) => self.emit_block_expr(inner).into(), + } + } + fn emit_location(&mut self, label: Label, node: impl AstNode) { + let range = node.syntax().text_range(); + let start = self.line_index.line_col(range.start()); + let end = self.line_index.line_col( + range + .end() + .checked_sub(TextSize::new(1)) + .unwrap_or(range.end()), + ); + self.trap.emit_location(self.label, label, start, end) + } + fn emit_assoc_item(&mut self, node: ast::AssocItem) -> Label { + match node { + ast::AssocItem::Const(inner) => self.emit_const(inner).into(), + ast::AssocItem::Fn(inner) => self.emit_fn(inner).into(), + ast::AssocItem::MacroCall(inner) => self.emit_macro_call(inner).into(), + ast::AssocItem::TypeAlias(inner) => self.emit_type_alias(inner).into(), } } - fn emit_file(&mut self, file_id: FileId) -> Option { - self.vfs.file_path(file_id).as_path().and_then(|abs_path| { - let mut canonical = PathBuf::from(abs_path.as_str()); - if !self.file_labels.contains_key(&canonical) { - self.archiver.archive(&canonical); - canonical = fs::canonicalize(&canonical).unwrap_or(canonical); - let label = self.trap.emit_file(&canonical); - let line_index = ::line_index(self.db, file_id); - self.file_labels - .insert(canonical.clone(), FileData { label, line_index }); - } - self.file_labels.get(&canonical).cloned() - }) + fn emit_expr(&mut self, node: ast::Expr) -> Label { + match node { + ast::Expr::ArrayExpr(inner) => self.emit_array_expr(inner).into(), + ast::Expr::AsmExpr(inner) => self.emit_asm_expr(inner).into(), + ast::Expr::AwaitExpr(inner) => self.emit_await_expr(inner).into(), + ast::Expr::BecomeExpr(inner) => self.emit_become_expr(inner).into(), + ast::Expr::BinExpr(inner) => self.emit_bin_expr(inner).into(), + ast::Expr::BlockExpr(inner) => self.emit_block_expr(inner).into(), + ast::Expr::BreakExpr(inner) => self.emit_break_expr(inner).into(), + ast::Expr::CallExpr(inner) => self.emit_call_expr(inner).into(), + ast::Expr::CastExpr(inner) => self.emit_cast_expr(inner).into(), + ast::Expr::ClosureExpr(inner) => self.emit_closure_expr(inner).into(), + ast::Expr::ContinueExpr(inner) => self.emit_continue_expr(inner).into(), + ast::Expr::FieldExpr(inner) => self.emit_field_expr(inner).into(), + ast::Expr::ForExpr(inner) => self.emit_for_expr(inner).into(), + ast::Expr::FormatArgsExpr(inner) => self.emit_format_args_expr(inner).into(), + ast::Expr::IfExpr(inner) => self.emit_if_expr(inner).into(), + ast::Expr::IndexExpr(inner) => self.emit_index_expr(inner).into(), + ast::Expr::LetExpr(inner) => self.emit_let_expr(inner).into(), + ast::Expr::Literal(inner) => self.emit_literal(inner).into(), + ast::Expr::LoopExpr(inner) => self.emit_loop_expr(inner).into(), + ast::Expr::MacroExpr(inner) => self.emit_macro_expr(inner).into(), + ast::Expr::MatchExpr(inner) => self.emit_match_expr(inner).into(), + ast::Expr::MethodCallExpr(inner) => self.emit_method_call_expr(inner).into(), + ast::Expr::OffsetOfExpr(inner) => self.emit_offset_of_expr(inner).into(), + ast::Expr::ParenExpr(inner) => self.emit_paren_expr(inner).into(), + ast::Expr::PathExpr(inner) => self.emit_path_expr(inner).into(), + ast::Expr::PrefixExpr(inner) => self.emit_prefix_expr(inner).into(), + ast::Expr::RangeExpr(inner) => self.emit_range_expr(inner).into(), + ast::Expr::RecordExpr(inner) => self.emit_record_expr(inner).into(), + ast::Expr::RefExpr(inner) => self.emit_ref_expr(inner).into(), + ast::Expr::ReturnExpr(inner) => self.emit_return_expr(inner).into(), + ast::Expr::TryExpr(inner) => self.emit_try_expr(inner).into(), + ast::Expr::TupleExpr(inner) => self.emit_tuple_expr(inner).into(), + ast::Expr::UnderscoreExpr(inner) => self.emit_underscore_expr(inner).into(), + ast::Expr::WhileExpr(inner) => self.emit_while_expr(inner).into(), + ast::Expr::YeetExpr(inner) => self.emit_yeet_expr(inner).into(), + ast::Expr::YieldExpr(inner) => self.emit_yield_expr(inner).into(), + } } - fn emit_location_for_ast_ptr( - &mut self, - label: Label, - source: ra_ap_hir::InFile>, - ) { - if let Some(data) = source - .file_id - .file_id() - .map(|f| f.file_id()) - .and_then(|file_id| self.emit_file(file_id)) - { - let range = source.value.text_range(); - self.emit_location_for_textrange(label, data, range) + fn emit_extern_item(&mut self, node: ast::ExternItem) -> Label { + match node { + ast::ExternItem::Fn(inner) => self.emit_fn(inner).into(), + ast::ExternItem::MacroCall(inner) => self.emit_macro_call(inner).into(), + ast::ExternItem::Static(inner) => self.emit_static(inner).into(), + ast::ExternItem::TypeAlias(inner) => self.emit_type_alias(inner).into(), } } - fn emit_location_for_expr( - &mut self, - label: Label, - expr: ra_ap_hir_def::hir::ExprId, - source_map: &BodySourceMap, - ) { - if let Ok(source) = source_map.expr_syntax(expr) { - self.emit_location_for_ast_ptr(label, source); + fn emit_field_list(&mut self, node: ast::FieldList) -> Label { + match node { + ast::FieldList::RecordFieldList(inner) => self.emit_record_field_list(inner).into(), + ast::FieldList::TupleFieldList(inner) => self.emit_tuple_field_list(inner).into(), } } - fn emit_location_for_pat( - &mut self, - label: Label, - pat_id: ra_ap_hir_def::hir::PatId, - source_map: &BodySourceMap, - ) { - if let Ok(source) = source_map.pat_syntax(pat_id) { - self.emit_location_for_ast_ptr(label, source); + fn emit_generic_arg(&mut self, node: ast::GenericArg) -> Label { + match node { + ast::GenericArg::AssocTypeArg(inner) => self.emit_assoc_type_arg(inner).into(), + ast::GenericArg::ConstArg(inner) => self.emit_const_arg(inner).into(), + ast::GenericArg::LifetimeArg(inner) => self.emit_lifetime_arg(inner).into(), + ast::GenericArg::TypeArg(inner) => self.emit_type_arg(inner).into(), } } - fn emit_literal_or_const_pat( - &mut self, - pat: &ra_ap_hir_def::hir::LiteralOrConst, - body: &Body, - source_map: &BodySourceMap, - emit_location: impl FnOnce(&mut CrateTranslator<'_>, Label), - ) -> Label { - match pat { - ra_ap_hir_def::hir::LiteralOrConst::Literal(_literal) => { - let expr = self.trap.emit(generated::LiteralExpr { id: TrapId::Star }); - let label = self.trap.emit(generated::LiteralPat { - id: TrapId::Star, - expr: expr.into(), - }); - emit_location(self, label); - label.into() - } - ra_ap_hir_def::hir::LiteralOrConst::Const(inner) => { - self.emit_pat(*inner, body, source_map) - } + fn emit_generic_param(&mut self, node: ast::GenericParam) -> Label { + match node { + ast::GenericParam::ConstParam(inner) => self.emit_const_param(inner).into(), + ast::GenericParam::LifetimeParam(inner) => self.emit_lifetime_param(inner).into(), + ast::GenericParam::TypeParam(inner) => self.emit_type_param(inner).into(), } } - fn emit_location_for_label( - &mut self, - label: Label, - label_id: ra_ap_hir_def::hir::LabelId, - source_map: &BodySourceMap, - ) { - // 'catch' a panic if the source map is incomplete - let source = std::panic::catch_unwind(|| source_map.label_syntax(label_id)).ok(); - if let Some(source) = source { - self.emit_location_for_ast_ptr(label, source) + fn emit_pat(&mut self, node: ast::Pat) -> Label { + match node { + ast::Pat::BoxPat(inner) => self.emit_box_pat(inner).into(), + ast::Pat::ConstBlockPat(inner) => self.emit_const_block_pat(inner).into(), + ast::Pat::IdentPat(inner) => self.emit_ident_pat(inner).into(), + ast::Pat::LiteralPat(inner) => self.emit_literal_pat(inner).into(), + ast::Pat::MacroPat(inner) => self.emit_macro_pat(inner).into(), + ast::Pat::OrPat(inner) => self.emit_or_pat(inner).into(), + ast::Pat::ParenPat(inner) => self.emit_paren_pat(inner).into(), + ast::Pat::PathPat(inner) => self.emit_path_pat(inner).into(), + ast::Pat::RangePat(inner) => self.emit_range_pat(inner).into(), + ast::Pat::RecordPat(inner) => self.emit_record_pat(inner).into(), + ast::Pat::RefPat(inner) => self.emit_ref_pat(inner).into(), + ast::Pat::RestPat(inner) => self.emit_rest_pat(inner).into(), + ast::Pat::SlicePat(inner) => self.emit_slice_pat(inner).into(), + ast::Pat::TuplePat(inner) => self.emit_tuple_pat(inner).into(), + ast::Pat::TupleStructPat(inner) => self.emit_tuple_struct_pat(inner).into(), + ast::Pat::WildcardPat(inner) => self.emit_wildcard_pat(inner).into(), } } - fn emit_location(&mut self, label: Label, entity: T) - where - T::Ast: AstNode, - { - if let Some((data, source)) = entity - .source(self.db) - .and_then(|source| source.file_id.file_id().map(|f| (f.file_id(), source))) - .and_then(|(file_id, source)| self.emit_file(file_id).map(|data| (data, source))) - { - let range = source.value.syntax().text_range(); - self.emit_location_for_textrange(label, data, range); + + fn emit_stmt(&mut self, node: ast::Stmt) -> Label { + match node { + ast::Stmt::ExprStmt(inner) => self.emit_expr_stmt(inner).into(), + ast::Stmt::Item(inner) => self.emit_item(inner).into(), + ast::Stmt::LetStmt(inner) => self.emit_let_stmt(inner).into(), } } - fn emit_location_for_textrange( - &mut self, - label: Label, - data: FileData, - range: TextRange, - ) { - let start = data.line_index.line_col(range.start()); - let end = data.line_index.line_col( - range - .end() - .checked_sub(TextSize::new(1)) - .unwrap_or(range.end()), - ); - self.trap.emit_location(data.label, label, start, end) + + fn emit_type(&mut self, node: ast::Type) -> Label { + match node { + ast::Type::ArrayType(inner) => self.emit_array_type(inner).into(), + ast::Type::DynTraitType(inner) => self.emit_dyn_trait_type(inner).into(), + ast::Type::FnPtrType(inner) => self.emit_fn_ptr_type(inner).into(), + ast::Type::ForType(inner) => self.emit_for_type(inner).into(), + ast::Type::ImplTraitType(inner) => self.emit_impl_trait_type(inner).into(), + ast::Type::InferType(inner) => self.emit_infer_type(inner).into(), + ast::Type::MacroType(inner) => self.emit_macro_type(inner).into(), + ast::Type::NeverType(inner) => self.emit_never_type(inner).into(), + ast::Type::ParenType(inner) => self.emit_paren_type(inner).into(), + ast::Type::PathType(inner) => self.emit_path_type(inner).into(), + ast::Type::PtrType(inner) => self.emit_ptr_type(inner).into(), + ast::Type::RefType(inner) => self.emit_ref_type(inner).into(), + ast::Type::SliceType(inner) => self.emit_slice_type(inner).into(), + ast::Type::TupleType(inner) => self.emit_tuple_type(inner).into(), + } } - fn emit_label( - &mut self, - label_id: LabelId, - body: &Body, - source_map: &BodySourceMap, - ) -> Label { - let label = &body.labels[label_id]; - let ret = self.trap.emit(generated::Label { + + fn emit_item(&mut self, node: ast::Item) -> Label { + match node { + ast::Item::Const(inner) => self.emit_const(inner).into(), + ast::Item::Enum(inner) => self.emit_enum(inner).into(), + ast::Item::ExternBlock(inner) => self.emit_extern_block(inner).into(), + ast::Item::ExternCrate(inner) => self.emit_extern_crate(inner).into(), + ast::Item::Fn(inner) => self.emit_fn(inner).into(), + ast::Item::Impl(inner) => self.emit_impl(inner).into(), + ast::Item::MacroCall(inner) => self.emit_macro_call(inner).into(), + ast::Item::MacroDef(inner) => self.emit_macro_def(inner).into(), + ast::Item::MacroRules(inner) => self.emit_macro_rules(inner).into(), + ast::Item::Module(inner) => self.emit_module(inner).into(), + ast::Item::Static(inner) => self.emit_static(inner).into(), + ast::Item::Struct(inner) => self.emit_struct(inner).into(), + ast::Item::Trait(inner) => self.emit_trait(inner).into(), + ast::Item::TraitAlias(inner) => self.emit_trait_alias(inner).into(), + ast::Item::TypeAlias(inner) => self.emit_type_alias(inner).into(), + ast::Item::Union(inner) => self.emit_union(inner).into(), + ast::Item::Use(inner) => self.emit_use(inner).into(), + } + } + + fn emit_abi(&mut self, node: ast::Abi) -> Label { + let abi_string = node.try_get_text(); + let label = self.trap.emit(generated::Abi { id: TrapId::Star, - name: label.name.as_str().into(), + abi_string, }); - self.emit_location_for_label(ret, label_id, source_map); - ret + self.emit_location(label, node); + label } - fn emit_path(&mut self, _path: &Path) -> Label { - self.trap.emit(generated::Path { id: TrapId::Star }) + fn emit_arg_list(&mut self, node: ast::ArgList) -> Label { + let args = node.args().map(|x| self.emit_expr(x)).collect(); + let label = self.trap.emit(generated::ArgList { + id: TrapId::Star, + args, + }); + self.emit_location(label, node); + label } - fn emit_record_field_pat( - &mut self, - field_pat: &RecordFieldPat, - body: &Body, - source_map: &BodySourceMap, - ) -> Label { - let RecordFieldPat { name, pat } = field_pat; - let pat_label = self.emit_pat(*pat, body, source_map); - let ret = self.trap.emit(generated::RecordPatField { + fn emit_array_expr(&mut self, node: ast::ArrayExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let exprs = node.exprs().map(|x| self.emit_expr(x)).collect(); + let label = self.trap.emit(generated::ArrayExpr { + id: TrapId::Star, + attrs, + exprs, + }); + self.emit_location(label, node); + label + } + + fn emit_array_type(&mut self, node: ast::ArrayType) -> Label { + let const_arg = node.const_arg().map(|x| self.emit_const_arg(x)); + let ty = node.ty().map(|x| self.emit_type(x)); + let label = self.trap.emit(generated::ArrayType { + id: TrapId::Star, + const_arg, + ty, + }); + self.emit_location(label, node); + label + } + + fn emit_asm_expr(&mut self, node: ast::AsmExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::AsmExpr { id: TrapId::Star, - name: name.as_str().into(), - pat: pat_label, + attrs, + expr, }); - self.emit_location_for_pat(ret, *pat, source_map); - ret + self.emit_location(label, node); + label } - fn emit_record_lit_field( + fn emit_assoc_item_list( &mut self, - field_expr: &RecordLitField, - body: &Body, - source_map: &BodySourceMap, - ) -> Label { - let RecordLitField { name, expr } = field_expr; - let expr_label = self.emit_expr(*expr, body, source_map); - let ret = self.trap.emit(generated::RecordExprField { + node: ast::AssocItemList, + ) -> Label { + let assoc_items = node + .assoc_items() + .map(|x| self.emit_assoc_item(x)) + .collect(); + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let label = self.trap.emit(generated::AssocItemList { + id: TrapId::Star, + assoc_items, + attrs, + }); + self.emit_location(label, node); + label + } + + fn emit_assoc_type_arg(&mut self, node: ast::AssocTypeArg) -> Label { + let const_arg = node.const_arg().map(|x| self.emit_const_arg(x)); + let generic_arg_list = node + .generic_arg_list() + .map(|x| self.emit_generic_arg_list(x)); + let name_ref = node.name_ref().map(|x| self.emit_name_ref(x)); + let param_list = node.param_list().map(|x| self.emit_param_list(x)); + let ret_type = node.ret_type().map(|x| self.emit_ret_type(x)); + let return_type_syntax = node + .return_type_syntax() + .map(|x| self.emit_return_type_syntax(x)); + let ty = node.ty().map(|x| self.emit_type(x)); + let type_bound_list = node.type_bound_list().map(|x| self.emit_type_bound_list(x)); + let label = self.trap.emit(generated::AssocTypeArg { + id: TrapId::Star, + const_arg, + generic_arg_list, + name_ref, + param_list, + ret_type, + return_type_syntax, + ty, + type_bound_list, + }); + self.emit_location(label, node); + label + } + + fn emit_attr(&mut self, node: ast::Attr) -> Label { + let meta = node.meta().map(|x| self.emit_meta(x)); + let label = self.trap.emit(generated::Attr { + id: TrapId::Star, + meta, + }); + self.emit_location(label, node); + label + } + + fn emit_await_expr(&mut self, node: ast::AwaitExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::AwaitExpr { + id: TrapId::Star, + attrs, + expr, + }); + self.emit_location(label, node); + label + } + + fn emit_become_expr(&mut self, node: ast::BecomeExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::BecomeExpr { + id: TrapId::Star, + attrs, + expr, + }); + self.emit_location(label, node); + label + } + + fn emit_bin_expr(&mut self, node: ast::BinExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let lhs = node.lhs().map(|x| self.emit_expr(x)); + let operator_name = node.try_get_text(); + let rhs = node.rhs().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::BinaryExpr { + id: TrapId::Star, + attrs, + lhs, + operator_name, + rhs, + }); + self.emit_location(label, node); + label + } + + fn emit_block_expr(&mut self, node: ast::BlockExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let label = node.label().map(|x| self.emit_label(x)); + let stmt_list = node.stmt_list().map(|x| self.emit_stmt_list(x)); + let label = self.trap.emit(generated::BlockExpr { + id: TrapId::Star, + attrs, + label, + stmt_list, + }); + self.emit_location(label, node); + label + } + + fn emit_box_pat(&mut self, node: ast::BoxPat) -> Label { + let pat = node.pat().map(|x| self.emit_pat(x)); + let label = self.trap.emit(generated::BoxPat { + id: TrapId::Star, + pat, + }); + self.emit_location(label, node); + label + } + + fn emit_break_expr(&mut self, node: ast::BreakExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let lifetime = node.lifetime().map(|x| self.emit_lifetime(x)); + let label = self.trap.emit(generated::BreakExpr { + id: TrapId::Star, + attrs, + expr, + lifetime, + }); + self.emit_location(label, node); + label + } + + fn emit_call_expr(&mut self, node: ast::CallExpr) -> Label { + let arg_list = node.arg_list().map(|x| self.emit_arg_list(x)); + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::CallExpr { + id: TrapId::Star, + arg_list, + attrs, + expr, + }); + self.emit_location(label, node); + label + } + + fn emit_cast_expr(&mut self, node: ast::CastExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let ty = node.ty().map(|x| self.emit_type(x)); + let label = self.trap.emit(generated::CastExpr { + id: TrapId::Star, + attrs, + expr, + ty, + }); + self.emit_location(label, node); + label + } + + fn emit_closure_binder(&mut self, node: ast::ClosureBinder) -> Label { + let generic_param_list = node + .generic_param_list() + .map(|x| self.emit_generic_param_list(x)); + let label = self.trap.emit(generated::ClosureBinder { + id: TrapId::Star, + generic_param_list, + }); + self.emit_location(label, node); + label + } + + fn emit_closure_expr(&mut self, node: ast::ClosureExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let body = node.body().map(|x| self.emit_expr(x)); + let closure_binder = node.closure_binder().map(|x| self.emit_closure_binder(x)); + let param_list = node.param_list().map(|x| self.emit_param_list(x)); + let ret_type = node.ret_type().map(|x| self.emit_ret_type(x)); + let label = self.trap.emit(generated::ClosureExpr { + id: TrapId::Star, + attrs, + body, + closure_binder, + param_list, + ret_type, + }); + self.emit_location(label, node); + label + } + + fn emit_const(&mut self, node: ast::Const) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let body = node.body().map(|x| self.emit_expr(x)); + let name = node.name().map(|x| self.emit_name(x)); + let ty = node.ty().map(|x| self.emit_type(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let label = self.trap.emit(generated::Const { + id: TrapId::Star, + attrs, + body, + name, + ty, + visibility, + }); + self.emit_location(label, node); + label + } + + fn emit_const_arg(&mut self, node: ast::ConstArg) -> Label { + let expr = node.expr().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::ConstArg { id: TrapId::Star, - name: name.as_str().into(), - expr: expr_label, + expr, }); - self.emit_location_for_expr(ret, *expr, source_map); - ret + self.emit_location(label, node); + label } - fn emit_pat( + + fn emit_const_block_pat( &mut self, - pat_id: PatId, - body: &Body, - source_map: &BodySourceMap, - ) -> Label { - let pat = &body.pats[pat_id]; - let ret = match pat { - ra_ap_hir_def::hir::Pat::Missing => self - .trap - .emit(generated::MissingPat { id: TrapId::Star }) - .into(), - ra_ap_hir_def::hir::Pat::Wild => self - .trap - .emit(generated::WildcardPat { id: TrapId::Star }) - .into(), - ra_ap_hir_def::hir::Pat::Tuple { args, ellipsis } => { - let args = args - .into_iter() - .map(|pat| self.emit_pat(*pat, body, source_map)) - .collect(); - let ellipsis_index = ellipsis.and_then(|x| x.try_into().ok()); - self.trap - .emit(generated::TuplePat { - id: TrapId::Star, - args, - ellipsis_index, - }) - .into() - } - ra_ap_hir_def::hir::Pat::Or(args) => { - let args = args - .into_iter() - .map(|pat| self.emit_pat(*pat, body, source_map)) - .collect(); - self.trap - .emit(generated::OrPat { - id: TrapId::Star, - args, - }) - .into() - } - ra_ap_hir_def::hir::Pat::Record { - path, - args, - ellipsis, - } => { - let path = path.as_ref().map(|path| self.emit_path(path)); - if let Some(p) = path { - self.emit_location_for_pat(p, pat_id, source_map) - } - let flds = args - .into_iter() - .map(|arg| self.emit_record_field_pat(arg, body, source_map)) - .collect(); - self.trap - .emit(generated::RecordPat { - id: TrapId::Star, - path, - flds, - has_ellipsis: *ellipsis, - }) - .into() - } - ra_ap_hir_def::hir::Pat::Range { start, end } => { - let emit_location_for_const = - |this: &mut CrateTranslator, label: Label| { - this.emit_location_for_pat(label, pat_id, source_map) - }; - let start = start.as_ref().map(|x| { - self.emit_literal_or_const_pat(x, body, source_map, emit_location_for_const) - }); - - let end = end.as_ref().map(|x| { - self.emit_literal_or_const_pat(x, body, source_map, emit_location_for_const) - }); - self.trap - .emit(generated::RangePat { - id: TrapId::Star, - start, - end, - }) - .into() - } - ra_ap_hir_def::hir::Pat::Slice { - prefix, - slice, - suffix, - } => { - let prefix = prefix - .into_iter() - .map(|pat| self.emit_pat(*pat, body, source_map)) - .collect(); - let slice = slice.map(|pat| self.emit_pat(pat, body, source_map)); - let suffix = suffix - .into_iter() - .map(|pat| self.emit_pat(*pat, body, source_map)) - .collect(); - self.trap - .emit(generated::SlicePat { - id: TrapId::Star, - prefix, - slice, - suffix, - }) - .into() - } - ra_ap_hir_def::hir::Pat::Path(path) => { - let path = self.emit_path(path); - self.emit_location_for_pat(path, pat_id, source_map); - - self.trap - .emit(generated::PathPat { - id: TrapId::Star, - path, - }) - .into() - } - ra_ap_hir_def::hir::Pat::Lit(expr) => { - let expr = self.emit_expr(*expr, body, source_map); - self.trap - .emit(generated::LiteralPat { - id: TrapId::Star, - expr, - }) - .into() - } - ra_ap_hir_def::hir::Pat::Bind { id, subpat } => { - let subpat = subpat.map(|pat| self.emit_pat(pat, body, source_map)); - self.trap - .emit(generated::IdentPat { - id: TrapId::Star, - subpat, - binding_id: body.bindings[*id].name.as_str().into(), - }) - .into() - } - ra_ap_hir_def::hir::Pat::TupleStruct { - path, - args, - ellipsis, - } => { - let path = path.as_ref().map(|path| self.emit_path(path)); - if let Some(p) = path { - self.emit_location_for_pat(p, pat_id, source_map) - } - - let args = args - .into_iter() - .map(|arg| self.emit_pat(*arg, body, source_map)) - .collect(); - self.trap - .emit(generated::TupleStructPat { - id: TrapId::Star, - path, - args, - ellipsis_index: ellipsis.map(|x| x as usize), - }) - .into() - } - ra_ap_hir_def::hir::Pat::Ref { pat, mutability } => { - let pat = self.emit_pat(*pat, body, source_map); - self.trap - .emit(generated::RefPat { - id: TrapId::Star, - pat, - is_mut: mutability.is_mut(), - }) - .into() - } - ra_ap_hir_def::hir::Pat::Box { inner } => { - let inner = self.emit_pat(*inner, body, source_map); - self.trap - .emit(generated::BoxPat { - id: TrapId::Star, - inner, - }) - .into() - } - ra_ap_hir_def::hir::Pat::ConstBlock(expr) => { - let expr = self.emit_expr(*expr, body, source_map); - self.trap - .emit(generated::ConstBlockPat { - id: TrapId::Star, - expr, - }) - .into() - } - }; - self.emit_location_for_pat(ret, pat_id, source_map); - ret - } - fn emit_type_ref(&mut self, _type_ref: &TypeRef) -> Label { - self.trap.emit(generated::TypeRef { id: TrapId::Star }) - } - fn emit_match_arm( + node: ast::ConstBlockPat, + ) -> Label { + let block_expr = node.block_expr().map(|x| self.emit_block_expr(x)); + let label = self.trap.emit(generated::ConstBlockPat { + id: TrapId::Star, + block_expr, + }); + self.emit_location(label, node); + label + } + + fn emit_const_param(&mut self, node: ast::ConstParam) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let default_val = node.default_val().map(|x| self.emit_const_arg(x)); + let name = node.name().map(|x| self.emit_name(x)); + let ty = node.ty().map(|x| self.emit_type(x)); + let label = self.trap.emit(generated::ConstParam { + id: TrapId::Star, + attrs, + default_val, + name, + ty, + }); + self.emit_location(label, node); + label + } + + fn emit_continue_expr(&mut self, node: ast::ContinueExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let lifetime = node.lifetime().map(|x| self.emit_lifetime(x)); + let label = self.trap.emit(generated::ContinueExpr { + id: TrapId::Star, + attrs, + lifetime, + }); + self.emit_location(label, node); + label + } + + fn emit_dyn_trait_type(&mut self, node: ast::DynTraitType) -> Label { + let type_bound_list = node.type_bound_list().map(|x| self.emit_type_bound_list(x)); + let label = self.trap.emit(generated::DynTraitType { + id: TrapId::Star, + type_bound_list, + }); + self.emit_location(label, node); + label + } + + fn emit_enum(&mut self, node: ast::Enum) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let generic_param_list = node + .generic_param_list() + .map(|x| self.emit_generic_param_list(x)); + let name = node.name().map(|x| self.emit_name(x)); + let variant_list = node.variant_list().map(|x| self.emit_variant_list(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let where_clause = node.where_clause().map(|x| self.emit_where_clause(x)); + let label = self.trap.emit(generated::Enum { + id: TrapId::Star, + attrs, + generic_param_list, + name, + variant_list, + visibility, + where_clause, + }); + self.emit_location(label, node); + label + } + + fn emit_expr_stmt(&mut self, node: ast::ExprStmt) -> Label { + let expr = node.expr().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::ExprStmt { + id: TrapId::Star, + expr, + }); + self.emit_location(label, node); + label + } + + fn emit_extern_block(&mut self, node: ast::ExternBlock) -> Label { + let abi = node.abi().map(|x| self.emit_abi(x)); + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let extern_item_list = node + .extern_item_list() + .map(|x| self.emit_extern_item_list(x)); + let label = self.trap.emit(generated::ExternBlock { + id: TrapId::Star, + abi, + attrs, + extern_item_list, + }); + self.emit_location(label, node); + label + } + + fn emit_extern_crate(&mut self, node: ast::ExternCrate) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let name_ref = node.name_ref().map(|x| self.emit_name_ref(x)); + let rename = node.rename().map(|x| self.emit_rename(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let label = self.trap.emit(generated::ExternCrate { + id: TrapId::Star, + attrs, + name_ref, + rename, + visibility, + }); + self.emit_location(label, node); + label + } + + fn emit_extern_item_list( &mut self, - arm: &MatchArm, - body: &Body, - source_map: &BodySourceMap, - ) -> Label { - let pat = self.emit_pat(arm.pat, body, source_map); - let guard = arm.guard.map(|g| self.emit_expr(g, body, source_map)); - let expr = self.emit_expr(arm.expr, body, source_map); - let ret = self.trap.emit(generated::MatchArm { + node: ast::ExternItemList, + ) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let extern_items = node + .extern_items() + .map(|x| self.emit_extern_item(x)) + .collect(); + let label = self.trap.emit(generated::ExternItemList { + id: TrapId::Star, + attrs, + extern_items, + }); + self.emit_location(label, node); + label + } + + fn emit_field_expr(&mut self, node: ast::FieldExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let name_ref = node.name_ref().map(|x| self.emit_name_ref(x)); + let label = self.trap.emit(generated::FieldExpr { + id: TrapId::Star, + attrs, + expr, + name_ref, + }); + self.emit_location(label, node); + label + } + + fn emit_fn(&mut self, node: ast::Fn) -> Label { + let abi = node.abi().map(|x| self.emit_abi(x)); + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let body = node.body().map(|x| self.emit_block_expr(x)); + let generic_param_list = node + .generic_param_list() + .map(|x| self.emit_generic_param_list(x)); + let name = node.name().map(|x| self.emit_name(x)); + let param_list = node.param_list().map(|x| self.emit_param_list(x)); + let ret_type = node.ret_type().map(|x| self.emit_ret_type(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let where_clause = node.where_clause().map(|x| self.emit_where_clause(x)); + let label = self.trap.emit(generated::Function { + id: TrapId::Star, + abi, + attrs, + body, + generic_param_list, + name, + param_list, + ret_type, + visibility, + where_clause, + }); + self.emit_location(label, node); + label + } + + fn emit_fn_ptr_type(&mut self, node: ast::FnPtrType) -> Label { + let abi = node.abi().map(|x| self.emit_abi(x)); + let param_list = node.param_list().map(|x| self.emit_param_list(x)); + let ret_type = node.ret_type().map(|x| self.emit_ret_type(x)); + let label = self.trap.emit(generated::FnPtrType { + id: TrapId::Star, + abi, + param_list, + ret_type, + }); + self.emit_location(label, node); + label + } + + fn emit_for_expr(&mut self, node: ast::ForExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let iterable = node.iterable().map(|x| self.emit_expr(x)); + let label = node.label().map(|x| self.emit_label(x)); + let loop_body = node.loop_body().map(|x| self.emit_block_expr(x)); + let pat = node.pat().map(|x| self.emit_pat(x)); + let label = self.trap.emit(generated::ForExpr { id: TrapId::Star, + attrs, + iterable, + label, + loop_body, pat, - guard, + }); + self.emit_location(label, node); + label + } + + fn emit_for_type(&mut self, node: ast::ForType) -> Label { + let generic_param_list = node + .generic_param_list() + .map(|x| self.emit_generic_param_list(x)); + let ty = node.ty().map(|x| self.emit_type(x)); + let label = self.trap.emit(generated::ForType { + id: TrapId::Star, + generic_param_list, + ty, + }); + self.emit_location(label, node); + label + } + + fn emit_format_args_arg( + &mut self, + node: ast::FormatArgsArg, + ) -> Label { + let expr = node.expr().map(|x| self.emit_expr(x)); + let name = node.name().map(|x| self.emit_name(x)); + let label = self.trap.emit(generated::FormatArgsArg { + id: TrapId::Star, expr, + name, }); - self.emit_location_for_pat(ret, arm.pat, source_map); - ret + self.emit_location(label, node); + label } - fn emit_stmt( + + fn emit_format_args_expr( &mut self, - stmt: &Statement, - body: &Body, - source_map: &BodySourceMap, - ) -> Label { - match stmt { - Statement::Let { - pat, - type_ref, - initializer, - else_branch, - } => { - let pat_label = self.emit_pat(*pat, body, source_map); - let type_ = type_ref - .as_ref() - .map(|type_ref| self.emit_type_ref(type_ref)); - let initializer = - initializer.map(|initializer| self.emit_expr(initializer, body, source_map)); - let else_ = else_branch.map(|else_| self.emit_expr(else_, body, source_map)); - - let ret = self.trap.emit(generated::LetStmt { - id: TrapId::Star, - pat: pat_label, - type_, - initializer, - else_, - }); - // TODO: find a way to get the location of the entire statement - self.emit_location_for_pat(ret, *pat, source_map); - ret.into() - } - Statement::Expr { expr, has_semi } => { - let expr_label = self.emit_expr(*expr, body, source_map); - let ret = self.trap.emit(generated::ExprStmt { - id: TrapId::Star, - expr: expr_label, - has_semicolon: *has_semi, - }); - // TODO: find a way to get the location of the entire statement - self.emit_location_for_expr(ret, *expr, source_map); - ret.into() - } - Statement::Item => self - .trap - .emit(generated::ItemStmt { id: TrapId::Star }) - .into(), - } + node: ast::FormatArgsExpr, + ) -> Label { + let args = node.args().map(|x| self.emit_format_args_arg(x)).collect(); + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let template = node.template().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::FormatArgsExpr { + id: TrapId::Star, + args, + attrs, + template, + }); + self.emit_location(label, node); + label } - fn emit_expr( + + fn emit_generic_arg_list( &mut self, - expr_id: ExprId, - body: &Body, - source_map: &BodySourceMap, - ) -> Label { - let expr = &body[expr_id]; - let ret = match expr { - ra_ap_hir_def::hir::Expr::Missing => self - .trap - .emit(generated::MissingExpr { id: TrapId::Star }) - .into(), - ra_ap_hir_def::hir::Expr::Path(path) => { - let path = self.emit_path(path); - self.emit_location_for_expr(path, expr_id, source_map); - - self.trap - .emit(generated::PathExpr { - id: TrapId::Star, - path, - }) - .into() - } - ra_ap_hir_def::hir::Expr::If { - condition, - then_branch, - else_branch, - } => { - let condition = self.emit_expr(*condition, body, source_map); - let then = self.emit_expr(*then_branch, body, source_map); - let else_ = else_branch.map(|x| self.emit_expr(x, body, source_map)); - self.trap - .emit(generated::IfExpr { - id: TrapId::Star, - condition, - then, - else_, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Let { pat, expr } => { - let pat = self.emit_pat(*pat, body, source_map); - let expr = self.emit_expr(*expr, body, source_map); - self.trap - .emit(generated::LetExpr { - id: TrapId::Star, - pat, - expr, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Block { - id: _, - statements, - tail, - label, - } => { - let statements = statements - .into_iter() - .map(|stmt| self.emit_stmt(stmt, body, source_map)) - .collect(); - let tail = tail.map(|expr_id| self.emit_expr(expr_id, body, source_map)); - let label = label.map(|l| self.emit_label(l, body, source_map)); - self.trap - .emit(generated::BlockExpr { - id: TrapId::Star, - statements, - tail, - label, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Async { - id: _, - statements, - tail, - } => { - let statements = statements - .into_iter() - .map(|stmt| self.emit_stmt(stmt, body, source_map)) - .collect(); - let tail = tail.map(|expr_id| self.emit_expr(expr_id, body, source_map)); - self.trap - .emit(generated::AsyncBlockExpr { - id: TrapId::Star, - statements, - tail, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Const(const_block) => { - let expr_id = self.db.lookup_intern_anonymous_const(*const_block).root; - let expr = self.emit_expr(expr_id, body, source_map); - self.trap - .emit(generated::ConstExpr { - id: TrapId::Star, - expr, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Unsafe { - id: _, - statements, - tail, - } => { - let statements = statements - .into_iter() - .map(|stmt| self.emit_stmt(stmt, body, source_map)) - .collect(); - let tail = tail.map(|expr_id| self.emit_expr(expr_id, body, source_map)); - self.trap - .emit(generated::UnsafeBlockExpr { - id: TrapId::Star, - statements, - tail, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Loop { - body: loop_body, - label, - } => { - let loop_body = self.emit_expr(*loop_body, body, source_map); - let label = label.map(|l| self.emit_label(l, body, source_map)); - self.trap - .emit(generated::LoopExpr { - id: TrapId::Star, - body: loop_body, - label, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Call { - callee, - args, - is_assignee_expr, - } => { - let callee = self.emit_expr(*callee, body, source_map); - let args = args - .into_iter() - .map(|e| self.emit_expr(*e, body, source_map)) - .collect(); - self.trap - .emit(generated::CallExpr { - id: TrapId::Star, - callee, - args, - is_assignee_expr: *is_assignee_expr, - }) - .into() - } - ra_ap_hir_def::hir::Expr::MethodCall { - receiver, - method_name, - args, - generic_args, - } => { - let receiver = self.emit_expr(*receiver, body, source_map); - let args = args - .into_iter() - .map(|e| self.emit_expr(*e, body, source_map)) - .collect(); - let generic_args = generic_args.as_ref().map(|_args| { - self.trap - .emit(generated::GenericArgList { id: TrapId::Star }) - }); - self.trap - .emit(generated::MethodCallExpr { - id: TrapId::Star, - receiver, - method_name: method_name.as_str().into(), - args, - generic_args, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Match { expr, arms } => { - let expr = self.emit_expr(*expr, body, source_map); - let branches = arms - .into_iter() - .map(|e| self.emit_match_arm(e, body, source_map)) - .collect(); - - self.trap - .emit(generated::MatchExpr { - id: TrapId::Star, - expr, - branches, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Continue { label } => { - let label = label.map(|l| self.emit_label(l, body, source_map)); - self.trap - .emit(generated::ContinueExpr { - id: TrapId::Star, - label, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Break { expr, label } => { - let expr = expr.map(|e| self.emit_expr(e, body, source_map)); - let label = label.map(|l| self.emit_label(l, body, source_map)); - self.trap - .emit(generated::BreakExpr { - id: TrapId::Star, - expr, - label, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Return { expr } => { - let expr = expr.map(|e| self.emit_expr(e, body, source_map)); - self.trap - .emit(generated::ReturnExpr { - id: TrapId::Star, - expr, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Become { expr } => { - let expr = self.emit_expr(*expr, body, source_map); - self.trap - .emit(generated::BecomeExpr { - id: TrapId::Star, - expr, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Yield { expr } => { - let expr = expr.map(|e| self.emit_expr(e, body, source_map)); - self.trap - .emit(generated::YieldExpr { - id: TrapId::Star, - expr, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Yeet { expr } => { - let expr = expr.map(|e| self.emit_expr(e, body, source_map)); - self.trap - .emit(generated::YeetExpr { - id: TrapId::Star, - expr, - }) - .into() - } - ra_ap_hir_def::hir::Expr::RecordLit { - path, //TODO - fields, - spread, - ellipsis, - is_assignee_expr, - } => { - let path = path.as_ref().map(|path| self.emit_path(path)); - if let Some(p) = path { - self.emit_location_for_expr(p, expr_id, source_map) - } - - let flds = fields - .into_iter() - .map(|field| self.emit_record_lit_field(field, body, source_map)) - .collect(); - let spread = spread.map(|expr_id| self.emit_expr(expr_id, body, source_map)); - self.trap - .emit(generated::RecordExpr { - id: TrapId::Star, - path, - flds, - spread, - has_ellipsis: *ellipsis, - is_assignee_expr: *is_assignee_expr, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Field { expr, name } => { - let expr = self.emit_expr(*expr, body, source_map); - self.trap - .emit(generated::FieldExpr { - id: TrapId::Star, - expr, - name: name.as_str().into(), - }) - .into() - } - ra_ap_hir_def::hir::Expr::Await { expr } => { - let expr = self.emit_expr(*expr, body, source_map); - self.trap - .emit(generated::AwaitExpr { - id: TrapId::Star, - expr, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Cast { expr, type_ref } => { - let expr = self.emit_expr(*expr, body, source_map); - let type_ = self.emit_type_ref(type_ref.as_ref()); - self.trap - .emit(generated::CastExpr { - id: TrapId::Star, - expr, - type_, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Ref { - expr, - rawness, - mutability, - } => { - let expr = self.emit_expr(*expr, body, source_map); - self.trap - .emit(generated::RefExpr { - id: TrapId::Star, - expr, - is_mut: mutability.is_mut(), - is_raw: rawness.is_raw(), - }) - .into() - } - ra_ap_hir_def::hir::Expr::Box { expr } => { - let expr = self.emit_expr(*expr, body, source_map); - self.trap - .emit(generated::BoxExpr { - id: TrapId::Star, - expr, - }) - .into() - } - ra_ap_hir_def::hir::Expr::UnaryOp { expr, op } => { - let expr = self.emit_expr(*expr, body, source_map); - let op = match op { - ra_ap_syntax::ast::UnaryOp::Deref => "*", - ra_ap_syntax::ast::UnaryOp::Not => "!", - ra_ap_syntax::ast::UnaryOp::Neg => "-", - }; - self.trap - .emit(generated::PrefixExpr { - id: TrapId::Star, - expr, - op: op.into(), - }) - .into() - } - ra_ap_hir_def::hir::Expr::BinaryOp { lhs, rhs, op } => { - let lhs = self.emit_expr(*lhs, body, source_map); - let rhs = self.emit_expr(*rhs, body, source_map); - let op = op.map(|op| format!("{op}")); - self.trap - .emit(generated::BinaryExpr { - id: TrapId::Star, - lhs, - rhs, - op, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Range { - lhs, - rhs, - range_type, - } => { - let lhs = lhs.map(|lhs| self.emit_expr(lhs, body, source_map)); - let rhs = rhs.map(|rhs| self.emit_expr(rhs, body, source_map)); - self.trap - .emit(generated::RangeExpr { - id: TrapId::Star, - lhs, - rhs, - is_inclusive: *range_type == RangeOp::Inclusive, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Index { - base, - index, - is_assignee_expr, - } => { - let base = self.emit_expr(*base, body, source_map); - let index = self.emit_expr(*index, body, source_map); - self.trap - .emit(generated::IndexExpr { - id: TrapId::Star, - base, - index, - is_assignee_expr: *is_assignee_expr, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Closure { - args, - arg_types, - ret_type, - body: expr, - closure_kind, //TODO: - capture_by, - } => { - let expr = self.emit_expr(*expr, body, source_map); - let args = args - .into_iter() - .map(|arg| self.emit_pat(*arg, body, source_map)) - .collect(); - let ret_type = ret_type - .as_ref() - .map(|ret_type| self.emit_type_ref(ret_type)); - let arg_types = arg_types - .into_iter() - .map(|arg_type| { - arg_type - .as_ref() - .map(|arg_type| self.emit_type_ref(arg_type)) - }) - .collect(); - self.trap - .emit(generated::ClosureExpr { - id: TrapId::Star, - args, - arg_types, - body: expr, - ret_type, - closure_kind: format!("{:?}", closure_kind), - is_move: *capture_by == CaptureBy::Value, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Tuple { - exprs, - is_assignee_expr, - } => { - let exprs = exprs - .into_iter() - .map(|expr| self.emit_expr(*expr, body, source_map)) - .collect(); - self.trap - .emit(generated::TupleExpr { - id: TrapId::Star, - exprs, - is_assignee_expr: *is_assignee_expr, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Array(ra_ap_hir_def::hir::Array::ElementList { - elements, - is_assignee_expr, - }) => { - let elements = elements - .into_iter() - .map(|expr| self.emit_expr(*expr, body, source_map)) - .collect(); - self.trap - .emit(generated::ElementListExpr { - id: TrapId::Star, - elements, - is_assignee_expr: *is_assignee_expr, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Array(ra_ap_hir_def::hir::Array::Repeat { - initializer, - repeat, - }) => { - let initializer = self.emit_expr(*initializer, body, source_map); - let repeat = self.emit_expr(*repeat, body, source_map); - - self.trap - .emit(generated::RepeatExpr { - id: TrapId::Star, - initializer, - repeat, - }) - .into() - } - ra_ap_hir_def::hir::Expr::Literal(_literal) => self - .trap - .emit(generated::LiteralExpr { id: TrapId::Star }) - .into(), - ra_ap_hir_def::hir::Expr::Underscore => self - .trap - .emit(generated::UnderscoreExpr { id: TrapId::Star }) - .into(), - ra_ap_hir_def::hir::Expr::OffsetOf(offset) => { - let container = self.emit_type_ref(&offset.container); - let fields = offset.fields.iter().map(|x| x.as_str().into()).collect(); - self.trap - .emit(generated::OffsetOfExpr { - id: TrapId::Star, - container, - fields, - }) - .into() - } - ra_ap_hir_def::hir::Expr::InlineAsm(asm) => { - let expr = self.emit_expr(asm.e, body, source_map); - self.trap - .emit(generated::AsmExpr { - id: TrapId::Star, - expr, - }) - .into() - } - }; - self.emit_location_for_expr(ret, expr_id, source_map); - ret - } - - fn emit_definition( + node: ast::GenericArgList, + ) -> Label { + let generic_args = node + .generic_args() + .map(|x| self.emit_generic_arg(x)) + .collect(); + let label = self.trap.emit(generated::GenericArgList { + id: TrapId::Star, + generic_args, + }); + self.emit_location(label, node); + label + } + + fn emit_generic_param_list( &mut self, - module_label: Label, - id: ModuleDef, - labels: &mut Vec>, - ) { - let label = match id { - ModuleDef::Module(_module) => self - .trap - .emit(generated::UnimplementedDeclaration { id: TrapId::Star }) - .into(), - ModuleDef::Function(function) => { - let def: ra_ap_hir::DefWithBody = function.into(); - - let name = function.name(self.db); - - let (body, source_map) = self.db.body_with_source_map(def.into()); - let txt = body.pretty_print(self.db, def.into(), Edition::Edition2021); - log::trace!("{}", &txt); - let body = self.emit_expr(body.body_expr, &body, &source_map); - - let label = self.trap.emit(generated::Function { - id: trap_key![module_label, name.as_str()], - name: name.as_str().into(), - body, - }); - self.emit_location(label, function); - label.into() - } - ModuleDef::Adt(adt) => { - let label = self - .trap - .emit(generated::UnimplementedDeclaration { id: TrapId::Star }); - self.emit_location(label, adt); - label.into() - } - ModuleDef::Variant(variant) => { - let label = self - .trap - .emit(generated::UnimplementedDeclaration { id: TrapId::Star }); - self.emit_location(label, variant); - label.into() - } - ModuleDef::Const(const_) => { - let label = self - .trap - .emit(generated::UnimplementedDeclaration { id: TrapId::Star }); - self.emit_location(label, const_); - label.into() - } - ModuleDef::Static(static_) => { - let label = self - .trap - .emit(generated::UnimplementedDeclaration { id: TrapId::Star }); - self.emit_location(label, static_); - label.into() - } - ModuleDef::Trait(trait_) => { - let label = self - .trap - .emit(generated::UnimplementedDeclaration { id: TrapId::Star }); - self.emit_location(label, trait_); - label.into() - } - ModuleDef::TraitAlias(alias) => { - let label = self - .trap - .emit(generated::UnimplementedDeclaration { id: TrapId::Star }); - self.emit_location(label, alias); - label.into() - } - ModuleDef::TypeAlias(type_alias) => { - let label = self - .trap - .emit(generated::UnimplementedDeclaration { id: TrapId::Star }); - self.emit_location(label, type_alias); - label.into() - } - ModuleDef::BuiltinType(_builtin_type) => self - .trap - .emit(generated::UnimplementedDeclaration { id: TrapId::Star }) - .into(), - ModuleDef::Macro(macro_) => { - let label = self - .trap - .emit(generated::UnimplementedDeclaration { id: TrapId::Star }); - self.emit_location(label, macro_); - label.into() - } - }; - labels.push(label); - } - - fn emit_module(&mut self, label: Label, module: Module) { - let mut children = Vec::new(); - for id in module.declarations(self.db) { - self.emit_definition(label, id, &mut children); - } - self.trap.emit(generated::Module { - id: label.into(), - declarations: children, - }); - } - - pub fn emit_crate(&mut self) -> std::io::Result<()> { - self.emit_file(self.krate.root_file(self.db)); - let mut map = HashMap::>::new(); - for module in self.krate.modules(self.db) { - let mut key = String::new(); - if let Some(parent) = module.parent(self.db) { - // assumption: parent was already listed - let parent_label = *map.get(&parent).unwrap(); - key.push_str(&parent_label.as_key_part()); - } - let def = module.definition_source(self.db); - if let Some(file) = def.file_id.file_id() { - if let Some(data) = self.emit_file(file.file_id()) { - key.push_str(&data.label.as_key_part()); - } - } - if let Some(name) = module.name(self.db) { - key.push_str(name.as_str()); - } - let label = self.trap.label(TrapId::Key(key)); - map.insert(module, label); - self.emit_module(label, module); - } - self.trap.commit() + node: ast::GenericParamList, + ) -> Label { + let generic_params = node + .generic_params() + .map(|x| self.emit_generic_param(x)) + .collect(); + let label = self.trap.emit(generated::GenericParamList { + id: TrapId::Star, + generic_params, + }); + self.emit_location(label, node); + label + } + + fn emit_ident_pat(&mut self, node: ast::IdentPat) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let name = node.name().map(|x| self.emit_name(x)); + let pat = node.pat().map(|x| self.emit_pat(x)); + let label = self.trap.emit(generated::IdentPat { + id: TrapId::Star, + attrs, + name, + pat, + }); + self.emit_location(label, node); + label + } + + fn emit_if_expr(&mut self, node: ast::IfExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let condition = node.condition().map(|x| self.emit_expr(x)); + let else_ = node.else_branch().map(|x| self.emit_else_branch(x)); + let then = node.then_branch().map(|x| self.emit_block_expr(x)); + let label = self.trap.emit(generated::IfExpr { + id: TrapId::Star, + attrs, + condition, + else_, + then, + }); + self.emit_location(label, node); + label + } + + fn emit_impl(&mut self, node: ast::Impl) -> Label { + let assoc_item_list = node.assoc_item_list().map(|x| self.emit_assoc_item_list(x)); + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let generic_param_list = node + .generic_param_list() + .map(|x| self.emit_generic_param_list(x)); + let self_ty = node.self_ty().map(|x| self.emit_type(x)); + let trait_ = node.trait_().map(|x| self.emit_type(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let where_clause = node.where_clause().map(|x| self.emit_where_clause(x)); + let label = self.trap.emit(generated::Impl { + id: TrapId::Star, + assoc_item_list, + attrs, + generic_param_list, + self_ty, + trait_, + visibility, + where_clause, + }); + self.emit_location(label, node); + label + } + + fn emit_impl_trait_type( + &mut self, + node: ast::ImplTraitType, + ) -> Label { + let type_bound_list = node.type_bound_list().map(|x| self.emit_type_bound_list(x)); + let label = self.trap.emit(generated::ImplTraitType { + id: TrapId::Star, + type_bound_list, + }); + self.emit_location(label, node); + label + } + + fn emit_index_expr(&mut self, node: ast::IndexExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let base = node.base().map(|x| self.emit_expr(x)); + let index = node.index().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::IndexExpr { + id: TrapId::Star, + attrs, + base, + index, + }); + self.emit_location(label, node); + label + } + + fn emit_infer_type(&mut self, node: ast::InferType) -> Label { + let label = self.trap.emit(generated::InferType { id: TrapId::Star }); + self.emit_location(label, node); + label + } + + fn emit_item_list(&mut self, node: ast::ItemList) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let items = node.items().map(|x| self.emit_item(x)).collect(); + let label = self.trap.emit(generated::ItemList { + id: TrapId::Star, + attrs, + items, + }); + self.emit_location(label, node); + label + } + + fn emit_label(&mut self, node: ast::Label) -> Label { + let lifetime = node.lifetime().map(|x| self.emit_lifetime(x)); + let label = self.trap.emit(generated::Label { + id: TrapId::Star, + lifetime, + }); + self.emit_location(label, node); + label + } + + fn emit_let_else(&mut self, node: ast::LetElse) -> Label { + let block_expr = node.block_expr().map(|x| self.emit_block_expr(x)); + let label = self.trap.emit(generated::LetElse { + id: TrapId::Star, + block_expr, + }); + self.emit_location(label, node); + label + } + + fn emit_let_expr(&mut self, node: ast::LetExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let pat = node.pat().map(|x| self.emit_pat(x)); + let label = self.trap.emit(generated::LetExpr { + id: TrapId::Star, + attrs, + expr, + pat, + }); + self.emit_location(label, node); + label + } + + fn emit_let_stmt(&mut self, node: ast::LetStmt) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let initializer = node.initializer().map(|x| self.emit_expr(x)); + let let_else = node.let_else().map(|x| self.emit_let_else(x)); + let pat = node.pat().map(|x| self.emit_pat(x)); + let ty = node.ty().map(|x| self.emit_type(x)); + let label = self.trap.emit(generated::LetStmt { + id: TrapId::Star, + attrs, + initializer, + let_else, + pat, + ty, + }); + self.emit_location(label, node); + label + } + + fn emit_lifetime(&mut self, node: ast::Lifetime) -> Label { + let text = node.try_get_text(); + let label = self.trap.emit(generated::Lifetime { + id: TrapId::Star, + text, + }); + self.emit_location(label, node); + label + } + + fn emit_lifetime_arg(&mut self, node: ast::LifetimeArg) -> Label { + let lifetime = node.lifetime().map(|x| self.emit_lifetime(x)); + let label = self.trap.emit(generated::LifetimeArg { + id: TrapId::Star, + lifetime, + }); + self.emit_location(label, node); + label + } + + fn emit_lifetime_param(&mut self, node: ast::LifetimeParam) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let lifetime = node.lifetime().map(|x| self.emit_lifetime(x)); + let type_bound_list = node.type_bound_list().map(|x| self.emit_type_bound_list(x)); + let label = self.trap.emit(generated::LifetimeParam { + id: TrapId::Star, + attrs, + lifetime, + type_bound_list, + }); + self.emit_location(label, node); + label + } + + fn emit_literal(&mut self, node: ast::Literal) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let text_value = node.try_get_text(); + let label = self.trap.emit(generated::LiteralExpr { + id: TrapId::Star, + attrs, + text_value, + }); + self.emit_location(label, node); + label + } + + fn emit_literal_pat(&mut self, node: ast::LiteralPat) -> Label { + let literal = node.literal().map(|x| self.emit_literal(x)); + let label = self.trap.emit(generated::LiteralPat { + id: TrapId::Star, + literal, + }); + self.emit_location(label, node); + label + } + + fn emit_loop_expr(&mut self, node: ast::LoopExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let label = node.label().map(|x| self.emit_label(x)); + let loop_body = node.loop_body().map(|x| self.emit_block_expr(x)); + let label = self.trap.emit(generated::LoopExpr { + id: TrapId::Star, + attrs, + label, + loop_body, + }); + self.emit_location(label, node); + label + } + + fn emit_macro_call(&mut self, node: ast::MacroCall) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let path = node.path().map(|x| self.emit_path(x)); + let token_tree = node.token_tree().map(|x| self.emit_token_tree(x)); + let label = self.trap.emit(generated::MacroCall { + id: TrapId::Star, + attrs, + path, + token_tree, + }); + self.emit_location(label, node); + label + } + + fn emit_macro_def(&mut self, node: ast::MacroDef) -> Label { + let args = node.args().map(|x| self.emit_token_tree(x)); + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let body = node.body().map(|x| self.emit_token_tree(x)); + let name = node.name().map(|x| self.emit_name(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let label = self.trap.emit(generated::MacroDef { + id: TrapId::Star, + args, + attrs, + body, + name, + visibility, + }); + self.emit_location(label, node); + label + } + + fn emit_macro_expr(&mut self, node: ast::MacroExpr) -> Label { + let macro_call = node.macro_call().map(|x| self.emit_macro_call(x)); + let label = self.trap.emit(generated::MacroExpr { + id: TrapId::Star, + macro_call, + }); + self.emit_location(label, node); + label + } + + fn emit_macro_pat(&mut self, node: ast::MacroPat) -> Label { + let macro_call = node.macro_call().map(|x| self.emit_macro_call(x)); + let label = self.trap.emit(generated::MacroPat { + id: TrapId::Star, + macro_call, + }); + self.emit_location(label, node); + label + } + + fn emit_macro_rules(&mut self, node: ast::MacroRules) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let name = node.name().map(|x| self.emit_name(x)); + let token_tree = node.token_tree().map(|x| self.emit_token_tree(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let label = self.trap.emit(generated::MacroRules { + id: TrapId::Star, + attrs, + name, + token_tree, + visibility, + }); + self.emit_location(label, node); + label + } + + fn emit_macro_type(&mut self, node: ast::MacroType) -> Label { + let macro_call = node.macro_call().map(|x| self.emit_macro_call(x)); + let label = self.trap.emit(generated::MacroType { + id: TrapId::Star, + macro_call, + }); + self.emit_location(label, node); + label + } + + fn emit_match_arm(&mut self, node: ast::MatchArm) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let guard = node.guard().map(|x| self.emit_match_guard(x)); + let pat = node.pat().map(|x| self.emit_pat(x)); + let label = self.trap.emit(generated::MatchArm { + id: TrapId::Star, + attrs, + expr, + guard, + pat, + }); + self.emit_location(label, node); + label + } + + fn emit_match_arm_list(&mut self, node: ast::MatchArmList) -> Label { + let arms = node.arms().map(|x| self.emit_match_arm(x)).collect(); + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let label = self.trap.emit(generated::MatchArmList { + id: TrapId::Star, + arms, + attrs, + }); + self.emit_location(label, node); + label + } + + fn emit_match_expr(&mut self, node: ast::MatchExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let match_arm_list = node.match_arm_list().map(|x| self.emit_match_arm_list(x)); + let label = self.trap.emit(generated::MatchExpr { + id: TrapId::Star, + attrs, + expr, + match_arm_list, + }); + self.emit_location(label, node); + label + } + + fn emit_match_guard(&mut self, node: ast::MatchGuard) -> Label { + let condition = node.condition().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::MatchGuard { + id: TrapId::Star, + condition, + }); + self.emit_location(label, node); + label + } + + fn emit_meta(&mut self, node: ast::Meta) -> Label { + let expr = node.expr().map(|x| self.emit_expr(x)); + let path = node.path().map(|x| self.emit_path(x)); + let token_tree = node.token_tree().map(|x| self.emit_token_tree(x)); + let label = self.trap.emit(generated::Meta { + id: TrapId::Star, + expr, + path, + token_tree, + }); + self.emit_location(label, node); + label + } + + fn emit_method_call_expr( + &mut self, + node: ast::MethodCallExpr, + ) -> Label { + let arg_list = node.arg_list().map(|x| self.emit_arg_list(x)); + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let generic_arg_list = node + .generic_arg_list() + .map(|x| self.emit_generic_arg_list(x)); + let name_ref = node.name_ref().map(|x| self.emit_name_ref(x)); + let receiver = node.receiver().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::MethodCallExpr { + id: TrapId::Star, + arg_list, + attrs, + generic_arg_list, + name_ref, + receiver, + }); + self.emit_location(label, node); + label + } + + fn emit_module(&mut self, node: ast::Module) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let item_list = node.item_list().map(|x| self.emit_item_list(x)); + let name = node.name().map(|x| self.emit_name(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let label = self.trap.emit(generated::Module { + id: TrapId::Star, + attrs, + item_list, + name, + visibility, + }); + self.emit_location(label, node); + label + } + + fn emit_name(&mut self, node: ast::Name) -> Label { + let text = node.try_get_text(); + let label = self.trap.emit(generated::Name { + id: TrapId::Star, + text, + }); + self.emit_location(label, node); + label + } + + fn emit_name_ref(&mut self, node: ast::NameRef) -> Label { + let text = node.try_get_text(); + let label = self.trap.emit(generated::NameRef { + id: TrapId::Star, + text, + }); + self.emit_location(label, node); + label + } + + fn emit_never_type(&mut self, node: ast::NeverType) -> Label { + let label = self.trap.emit(generated::NeverType { id: TrapId::Star }); + self.emit_location(label, node); + label + } + + fn emit_offset_of_expr(&mut self, node: ast::OffsetOfExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let fields = node.fields().map(|x| self.emit_name_ref(x)).collect(); + let ty = node.ty().map(|x| self.emit_type(x)); + let label = self.trap.emit(generated::OffsetOfExpr { + id: TrapId::Star, + attrs, + fields, + ty, + }); + self.emit_location(label, node); + label + } + + fn emit_or_pat(&mut self, node: ast::OrPat) -> Label { + let pats = node.pats().map(|x| self.emit_pat(x)).collect(); + let label = self.trap.emit(generated::OrPat { + id: TrapId::Star, + pats, + }); + self.emit_location(label, node); + label + } + + fn emit_param(&mut self, node: ast::Param) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let pat = node.pat().map(|x| self.emit_pat(x)); + let ty = node.ty().map(|x| self.emit_type(x)); + let label = self.trap.emit(generated::Param { + id: TrapId::Star, + attrs, + pat, + ty, + }); + self.emit_location(label, node); + label + } + + fn emit_param_list(&mut self, node: ast::ParamList) -> Label { + let params = node.params().map(|x| self.emit_param(x)).collect(); + let self_param = node.self_param().map(|x| self.emit_self_param(x)); + let label = self.trap.emit(generated::ParamList { + id: TrapId::Star, + params, + self_param, + }); + self.emit_location(label, node); + label + } + + fn emit_paren_expr(&mut self, node: ast::ParenExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::ParenExpr { + id: TrapId::Star, + attrs, + expr, + }); + self.emit_location(label, node); + label + } + + fn emit_paren_pat(&mut self, node: ast::ParenPat) -> Label { + let pat = node.pat().map(|x| self.emit_pat(x)); + let label = self.trap.emit(generated::ParenPat { + id: TrapId::Star, + pat, + }); + self.emit_location(label, node); + label + } + + fn emit_paren_type(&mut self, node: ast::ParenType) -> Label { + let ty = node.ty().map(|x| self.emit_type(x)); + let label = self.trap.emit(generated::ParenType { + id: TrapId::Star, + ty, + }); + self.emit_location(label, node); + label + } + + fn emit_path(&mut self, node: ast::Path) -> Label { + let qualifier = node.qualifier().map(|x| self.emit_path(x)); + let part = node.segment().map(|x| self.emit_path_segment(x)); + let label = self.trap.emit(generated::Path { + id: TrapId::Star, + qualifier, + part, + }); + self.emit_location(label, node); + label + } + + fn emit_path_expr(&mut self, node: ast::PathExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let path = node.path().map(|x| self.emit_path(x)); + let label = self.trap.emit(generated::PathExpr { + id: TrapId::Star, + attrs, + path, + }); + self.emit_location(label, node); + label + } + + fn emit_path_pat(&mut self, node: ast::PathPat) -> Label { + let path = node.path().map(|x| self.emit_path(x)); + let label = self.trap.emit(generated::PathPat { + id: TrapId::Star, + path, + }); + self.emit_location(label, node); + label + } + + fn emit_path_segment(&mut self, node: ast::PathSegment) -> Label { + let generic_arg_list = node + .generic_arg_list() + .map(|x| self.emit_generic_arg_list(x)); + let name_ref = node.name_ref().map(|x| self.emit_name_ref(x)); + let param_list = node.param_list().map(|x| self.emit_param_list(x)); + let path_type = node.path_type().map(|x| self.emit_path_type(x)); + let ret_type = node.ret_type().map(|x| self.emit_ret_type(x)); + let return_type_syntax = node + .return_type_syntax() + .map(|x| self.emit_return_type_syntax(x)); + let ty = node.ty().map(|x| self.emit_type(x)); + let label = self.trap.emit(generated::PathSegment { + id: TrapId::Star, + generic_arg_list, + name_ref, + param_list, + path_type, + ret_type, + return_type_syntax, + ty, + }); + self.emit_location(label, node); + label + } + + fn emit_path_type(&mut self, node: ast::PathType) -> Label { + let path = node.path().map(|x| self.emit_path(x)); + let label = self.trap.emit(generated::PathType { + id: TrapId::Star, + path, + }); + self.emit_location(label, node); + label + } + + fn emit_prefix_expr(&mut self, node: ast::PrefixExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let operator_name = node.try_get_text(); + let label = self.trap.emit(generated::PrefixExpr { + id: TrapId::Star, + attrs, + expr, + operator_name, + }); + self.emit_location(label, node); + label + } + + fn emit_ptr_type(&mut self, node: ast::PtrType) -> Label { + let ty = node.ty().map(|x| self.emit_type(x)); + let label = self.trap.emit(generated::PtrType { + id: TrapId::Star, + ty, + }); + self.emit_location(label, node); + label + } + + fn emit_range_expr(&mut self, node: ast::RangeExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let end = node.end().map(|x| self.emit_expr(x)); + let operator_name = node.try_get_text(); + let start = node.start().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::RangeExpr { + id: TrapId::Star, + attrs, + end, + operator_name, + start, + }); + self.emit_location(label, node); + label + } + + fn emit_range_pat(&mut self, node: ast::RangePat) -> Label { + let end = node.end().map(|x| self.emit_pat(x)); + let operator_name = node.try_get_text(); + let start = node.start().map(|x| self.emit_pat(x)); + let label = self.trap.emit(generated::RangePat { + id: TrapId::Star, + end, + operator_name, + start, + }); + self.emit_location(label, node); + label + } + + fn emit_record_expr(&mut self, node: ast::RecordExpr) -> Label { + let path = node.path().map(|x| self.emit_path(x)); + let record_expr_field_list = node + .record_expr_field_list() + .map(|x| self.emit_record_expr_field_list(x)); + let label = self.trap.emit(generated::RecordExpr { + id: TrapId::Star, + path, + record_expr_field_list, + }); + self.emit_location(label, node); + label + } + + fn emit_record_expr_field( + &mut self, + node: ast::RecordExprField, + ) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let name_ref = node.name_ref().map(|x| self.emit_name_ref(x)); + let label = self.trap.emit(generated::RecordExprField { + id: TrapId::Star, + attrs, + expr, + name_ref, + }); + self.emit_location(label, node); + label + } + + fn emit_record_expr_field_list( + &mut self, + node: ast::RecordExprFieldList, + ) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let fields = node + .fields() + .map(|x| self.emit_record_expr_field(x)) + .collect(); + let spread = node.spread().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::RecordExprFieldList { + id: TrapId::Star, + attrs, + fields, + spread, + }); + self.emit_location(label, node); + label + } + + fn emit_record_field(&mut self, node: ast::RecordField) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let name = node.name().map(|x| self.emit_name(x)); + let ty = node.ty().map(|x| self.emit_type(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let label = self.trap.emit(generated::RecordField { + id: TrapId::Star, + attrs, + name, + ty, + visibility, + }); + self.emit_location(label, node); + label + } + + fn emit_record_field_list( + &mut self, + node: ast::RecordFieldList, + ) -> Label { + let fields = node.fields().map(|x| self.emit_record_field(x)).collect(); + let label = self.trap.emit(generated::RecordFieldList { + id: TrapId::Star, + fields, + }); + self.emit_location(label, node); + label + } + + fn emit_record_pat(&mut self, node: ast::RecordPat) -> Label { + let path = node.path().map(|x| self.emit_path(x)); + let record_pat_field_list = node + .record_pat_field_list() + .map(|x| self.emit_record_pat_field_list(x)); + let label = self.trap.emit(generated::RecordPat { + id: TrapId::Star, + path, + record_pat_field_list, + }); + self.emit_location(label, node); + label + } + + fn emit_record_pat_field( + &mut self, + node: ast::RecordPatField, + ) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let name_ref = node.name_ref().map(|x| self.emit_name_ref(x)); + let pat = node.pat().map(|x| self.emit_pat(x)); + let label = self.trap.emit(generated::RecordPatField { + id: TrapId::Star, + attrs, + name_ref, + pat, + }); + self.emit_location(label, node); + label + } + + fn emit_record_pat_field_list( + &mut self, + node: ast::RecordPatFieldList, + ) -> Label { + let fields = node + .fields() + .map(|x| self.emit_record_pat_field(x)) + .collect(); + let rest_pat = node.rest_pat().map(|x| self.emit_rest_pat(x)); + let label = self.trap.emit(generated::RecordPatFieldList { + id: TrapId::Star, + fields, + rest_pat, + }); + self.emit_location(label, node); + label + } + + fn emit_ref_expr(&mut self, node: ast::RefExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::RefExpr { + id: TrapId::Star, + attrs, + expr, + }); + self.emit_location(label, node); + label + } + + fn emit_ref_pat(&mut self, node: ast::RefPat) -> Label { + let pat = node.pat().map(|x| self.emit_pat(x)); + let label = self.trap.emit(generated::RefPat { + id: TrapId::Star, + pat, + }); + self.emit_location(label, node); + label + } + + fn emit_ref_type(&mut self, node: ast::RefType) -> Label { + let lifetime = node.lifetime().map(|x| self.emit_lifetime(x)); + let ty = node.ty().map(|x| self.emit_type(x)); + let label = self.trap.emit(generated::RefType { + id: TrapId::Star, + lifetime, + ty, + }); + self.emit_location(label, node); + label + } + + fn emit_rename(&mut self, node: ast::Rename) -> Label { + let name = node.name().map(|x| self.emit_name(x)); + let label = self.trap.emit(generated::Rename { + id: TrapId::Star, + name, + }); + self.emit_location(label, node); + label + } + + fn emit_rest_pat(&mut self, node: ast::RestPat) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let label = self.trap.emit(generated::RestPat { + id: TrapId::Star, + attrs, + }); + self.emit_location(label, node); + label + } + + fn emit_ret_type(&mut self, node: ast::RetType) -> Label { + let ty = node.ty().map(|x| self.emit_type(x)); + let label = self.trap.emit(generated::RetType { + id: TrapId::Star, + ty, + }); + self.emit_location(label, node); + label + } + + fn emit_return_expr(&mut self, node: ast::ReturnExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::ReturnExpr { + id: TrapId::Star, + attrs, + expr, + }); + self.emit_location(label, node); + label + } + + fn emit_return_type_syntax( + &mut self, + node: ast::ReturnTypeSyntax, + ) -> Label { + let label = self + .trap + .emit(generated::ReturnTypeSyntax { id: TrapId::Star }); + self.emit_location(label, node); + label + } + + fn emit_self_param(&mut self, node: ast::SelfParam) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let lifetime = node.lifetime().map(|x| self.emit_lifetime(x)); + let name = node.name().map(|x| self.emit_name(x)); + let ty = node.ty().map(|x| self.emit_type(x)); + let label = self.trap.emit(generated::SelfParam { + id: TrapId::Star, + attrs, + lifetime, + name, + ty, + }); + self.emit_location(label, node); + label + } + + fn emit_slice_pat(&mut self, node: ast::SlicePat) -> Label { + let pats = node.pats().map(|x| self.emit_pat(x)).collect(); + let label = self.trap.emit(generated::SlicePat { + id: TrapId::Star, + pats, + }); + self.emit_location(label, node); + label + } + + fn emit_slice_type(&mut self, node: ast::SliceType) -> Label { + let ty = node.ty().map(|x| self.emit_type(x)); + let label = self.trap.emit(generated::SliceType { + id: TrapId::Star, + ty, + }); + self.emit_location(label, node); + label + } + + fn emit_source_file(&mut self, node: ast::SourceFile) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let items = node.items().map(|x| self.emit_item(x)).collect(); + let label = self.trap.emit(generated::SourceFile { + id: TrapId::Star, + attrs, + items, + }); + self.emit_location(label, node); + label + } + + fn emit_static(&mut self, node: ast::Static) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let body = node.body().map(|x| self.emit_expr(x)); + let name = node.name().map(|x| self.emit_name(x)); + let ty = node.ty().map(|x| self.emit_type(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let label = self.trap.emit(generated::Static { + id: TrapId::Star, + attrs, + body, + name, + ty, + visibility, + }); + self.emit_location(label, node); + label + } + + fn emit_stmt_list(&mut self, node: ast::StmtList) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let statements = node.statements().map(|x| self.emit_stmt(x)).collect(); + let tail_expr = node.tail_expr().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::StmtList { + id: TrapId::Star, + attrs, + statements, + tail_expr, + }); + self.emit_location(label, node); + label + } + + fn emit_struct(&mut self, node: ast::Struct) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let field_list = node.field_list().map(|x| self.emit_field_list(x)); + let generic_param_list = node + .generic_param_list() + .map(|x| self.emit_generic_param_list(x)); + let name = node.name().map(|x| self.emit_name(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let where_clause = node.where_clause().map(|x| self.emit_where_clause(x)); + let label = self.trap.emit(generated::Struct { + id: TrapId::Star, + attrs, + field_list, + generic_param_list, + name, + visibility, + where_clause, + }); + self.emit_location(label, node); + label + } + + fn emit_token_tree(&mut self, node: ast::TokenTree) -> Label { + let label = self.trap.emit(generated::TokenTree { id: TrapId::Star }); + self.emit_location(label, node); + label + } + + fn emit_trait(&mut self, node: ast::Trait) -> Label { + let assoc_item_list = node.assoc_item_list().map(|x| self.emit_assoc_item_list(x)); + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let generic_param_list = node + .generic_param_list() + .map(|x| self.emit_generic_param_list(x)); + let name = node.name().map(|x| self.emit_name(x)); + let type_bound_list = node.type_bound_list().map(|x| self.emit_type_bound_list(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let where_clause = node.where_clause().map(|x| self.emit_where_clause(x)); + let label = self.trap.emit(generated::Trait { + id: TrapId::Star, + assoc_item_list, + attrs, + generic_param_list, + name, + type_bound_list, + visibility, + where_clause, + }); + self.emit_location(label, node); + label + } + + fn emit_trait_alias(&mut self, node: ast::TraitAlias) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let generic_param_list = node + .generic_param_list() + .map(|x| self.emit_generic_param_list(x)); + let name = node.name().map(|x| self.emit_name(x)); + let type_bound_list = node.type_bound_list().map(|x| self.emit_type_bound_list(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let where_clause = node.where_clause().map(|x| self.emit_where_clause(x)); + let label = self.trap.emit(generated::TraitAlias { + id: TrapId::Star, + attrs, + generic_param_list, + name, + type_bound_list, + visibility, + where_clause, + }); + self.emit_location(label, node); + label + } + + fn emit_try_expr(&mut self, node: ast::TryExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::TryExpr { + id: TrapId::Star, + attrs, + expr, + }); + self.emit_location(label, node); + label + } + + fn emit_tuple_expr(&mut self, node: ast::TupleExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let fields = node.fields().map(|x| self.emit_expr(x)).collect(); + let label = self.trap.emit(generated::TupleExpr { + id: TrapId::Star, + attrs, + fields, + }); + self.emit_location(label, node); + label + } + + fn emit_tuple_field(&mut self, node: ast::TupleField) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let ty = node.ty().map(|x| self.emit_type(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let label = self.trap.emit(generated::TupleField { + id: TrapId::Star, + attrs, + ty, + visibility, + }); + self.emit_location(label, node); + label + } + + fn emit_tuple_field_list( + &mut self, + node: ast::TupleFieldList, + ) -> Label { + let fields = node.fields().map(|x| self.emit_tuple_field(x)).collect(); + let label = self.trap.emit(generated::TupleFieldList { + id: TrapId::Star, + fields, + }); + self.emit_location(label, node); + label + } + + fn emit_tuple_pat(&mut self, node: ast::TuplePat) -> Label { + let fields = node.fields().map(|x| self.emit_pat(x)).collect(); + let label = self.trap.emit(generated::TuplePat { + id: TrapId::Star, + fields, + }); + self.emit_location(label, node); + label + } + + fn emit_tuple_struct_pat( + &mut self, + node: ast::TupleStructPat, + ) -> Label { + let fields = node.fields().map(|x| self.emit_pat(x)).collect(); + let path = node.path().map(|x| self.emit_path(x)); + let label = self.trap.emit(generated::TupleStructPat { + id: TrapId::Star, + fields, + path, + }); + self.emit_location(label, node); + label + } + + fn emit_tuple_type(&mut self, node: ast::TupleType) -> Label { + let fields = node.fields().map(|x| self.emit_type(x)).collect(); + let label = self.trap.emit(generated::TupleType { + id: TrapId::Star, + fields, + }); + self.emit_location(label, node); + label + } + + fn emit_type_alias(&mut self, node: ast::TypeAlias) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let generic_param_list = node + .generic_param_list() + .map(|x| self.emit_generic_param_list(x)); + let name = node.name().map(|x| self.emit_name(x)); + let ty = node.ty().map(|x| self.emit_type(x)); + let type_bound_list = node.type_bound_list().map(|x| self.emit_type_bound_list(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let where_clause = node.where_clause().map(|x| self.emit_where_clause(x)); + let label = self.trap.emit(generated::TypeAlias { + id: TrapId::Star, + attrs, + generic_param_list, + name, + ty, + type_bound_list, + visibility, + where_clause, + }); + self.emit_location(label, node); + label + } + + fn emit_type_arg(&mut self, node: ast::TypeArg) -> Label { + let ty = node.ty().map(|x| self.emit_type(x)); + let label = self.trap.emit(generated::TypeArg { + id: TrapId::Star, + ty, + }); + self.emit_location(label, node); + label + } + + fn emit_type_bound(&mut self, node: ast::TypeBound) -> Label { + let generic_param_list = node + .generic_param_list() + .map(|x| self.emit_generic_param_list(x)); + let lifetime = node.lifetime().map(|x| self.emit_lifetime(x)); + let ty = node.ty().map(|x| self.emit_type(x)); + let label = self.trap.emit(generated::TypeBound { + id: TrapId::Star, + generic_param_list, + lifetime, + ty, + }); + self.emit_location(label, node); + label + } + + fn emit_type_bound_list( + &mut self, + node: ast::TypeBoundList, + ) -> Label { + let bounds = node.bounds().map(|x| self.emit_type_bound(x)).collect(); + let label = self.trap.emit(generated::TypeBoundList { + id: TrapId::Star, + bounds, + }); + self.emit_location(label, node); + label + } + + fn emit_type_param(&mut self, node: ast::TypeParam) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let default_type = node.default_type().map(|x| self.emit_type(x)); + let name = node.name().map(|x| self.emit_name(x)); + let type_bound_list = node.type_bound_list().map(|x| self.emit_type_bound_list(x)); + let label = self.trap.emit(generated::TypeParam { + id: TrapId::Star, + attrs, + default_type, + name, + type_bound_list, + }); + self.emit_location(label, node); + label + } + + fn emit_underscore_expr( + &mut self, + node: ast::UnderscoreExpr, + ) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let label = self.trap.emit(generated::UnderscoreExpr { + id: TrapId::Star, + attrs, + }); + self.emit_location(label, node); + label + } + + fn emit_union(&mut self, node: ast::Union) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let generic_param_list = node + .generic_param_list() + .map(|x| self.emit_generic_param_list(x)); + let name = node.name().map(|x| self.emit_name(x)); + let record_field_list = node + .record_field_list() + .map(|x| self.emit_record_field_list(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let where_clause = node.where_clause().map(|x| self.emit_where_clause(x)); + let label = self.trap.emit(generated::Union { + id: TrapId::Star, + attrs, + generic_param_list, + name, + record_field_list, + visibility, + where_clause, + }); + self.emit_location(label, node); + label + } + + fn emit_use(&mut self, node: ast::Use) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let use_tree = node.use_tree().map(|x| self.emit_use_tree(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let label = self.trap.emit(generated::Use { + id: TrapId::Star, + attrs, + use_tree, + visibility, + }); + self.emit_location(label, node); + label + } + + fn emit_use_tree(&mut self, node: ast::UseTree) -> Label { + let path = node.path().map(|x| self.emit_path(x)); + let rename = node.rename().map(|x| self.emit_rename(x)); + let use_tree_list = node.use_tree_list().map(|x| self.emit_use_tree_list(x)); + let label = self.trap.emit(generated::UseTree { + id: TrapId::Star, + path, + rename, + use_tree_list, + }); + self.emit_location(label, node); + label + } + + fn emit_use_tree_list(&mut self, node: ast::UseTreeList) -> Label { + let use_trees = node.use_trees().map(|x| self.emit_use_tree(x)).collect(); + let label = self.trap.emit(generated::UseTreeList { + id: TrapId::Star, + use_trees, + }); + self.emit_location(label, node); + label + } + + fn emit_variant(&mut self, node: ast::Variant) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let field_list = node.field_list().map(|x| self.emit_field_list(x)); + let name = node.name().map(|x| self.emit_name(x)); + let visibility = node.visibility().map(|x| self.emit_visibility(x)); + let label = self.trap.emit(generated::Variant { + id: TrapId::Star, + attrs, + expr, + field_list, + name, + visibility, + }); + self.emit_location(label, node); + label + } + + fn emit_variant_list(&mut self, node: ast::VariantList) -> Label { + let variants = node.variants().map(|x| self.emit_variant(x)).collect(); + let label = self.trap.emit(generated::VariantList { + id: TrapId::Star, + variants, + }); + self.emit_location(label, node); + label + } + + fn emit_visibility(&mut self, node: ast::Visibility) -> Label { + let path = node.path().map(|x| self.emit_path(x)); + let label = self.trap.emit(generated::Visibility { + id: TrapId::Star, + path, + }); + self.emit_location(label, node); + label + } + + fn emit_where_clause(&mut self, node: ast::WhereClause) -> Label { + let predicates = node.predicates().map(|x| self.emit_where_pred(x)).collect(); + let label = self.trap.emit(generated::WhereClause { + id: TrapId::Star, + predicates, + }); + self.emit_location(label, node); + label + } + + fn emit_where_pred(&mut self, node: ast::WherePred) -> Label { + let generic_param_list = node + .generic_param_list() + .map(|x| self.emit_generic_param_list(x)); + let lifetime = node.lifetime().map(|x| self.emit_lifetime(x)); + let ty = node.ty().map(|x| self.emit_type(x)); + let type_bound_list = node.type_bound_list().map(|x| self.emit_type_bound_list(x)); + let label = self.trap.emit(generated::WherePred { + id: TrapId::Star, + generic_param_list, + lifetime, + ty, + type_bound_list, + }); + self.emit_location(label, node); + label + } + + fn emit_while_expr(&mut self, node: ast::WhileExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let condition = node.condition().map(|x| self.emit_expr(x)); + let label = node.label().map(|x| self.emit_label(x)); + let loop_body = node.loop_body().map(|x| self.emit_block_expr(x)); + let label = self.trap.emit(generated::WhileExpr { + id: TrapId::Star, + attrs, + condition, + label, + loop_body, + }); + self.emit_location(label, node); + label + } + + fn emit_wildcard_pat(&mut self, node: ast::WildcardPat) -> Label { + let label = self.trap.emit(generated::WildcardPat { id: TrapId::Star }); + self.emit_location(label, node); + label + } + + fn emit_yeet_expr(&mut self, node: ast::YeetExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::YeetExpr { + id: TrapId::Star, + attrs, + expr, + }); + self.emit_location(label, node); + label + } + + fn emit_yield_expr(&mut self, node: ast::YieldExpr) -> Label { + let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); + let expr = node.expr().map(|x| self.emit_expr(x)); + let label = self.trap.emit(generated::YieldExpr { + id: TrapId::Star, + attrs, + expr, + }); + self.emit_location(label, node); + label } } diff --git a/rust/schema.py b/rust/schema.py index 4739e8ab65e9..ea6ec3a7e69a 100644 --- a/rust/schema.py +++ b/rust/schema.py @@ -19,6 +19,7 @@ class Element: pass + @qltest.skip class Locatable(Element): pass @@ -55,960 +56,812 @@ class Unimplemented(Unextracted): pass -class Declaration(AstNode): - """ - The base class for declarations. - """ +class AssocItem(AstNode): pass -@qltest.skip -class UnimplementedDeclaration(Declaration, Unimplemented): - """ - A declaration that is not yet extracted. - """ +class Expr(AstNode): pass -@rust.doc_test_signature(None) -class Module(Declaration): - """ - A module declaration. For example: - ```rust - mod foo; - ``` - ```rust - mod bar { - pub fn baz() {} - } - ``` - """ - declarations: list[Declaration] | child +class ExternItem(AstNode): + pass -class Expr(AstNode): - """ - The base class for expressions. - """ +class FieldList(AstNode): pass -class Pat(AstNode): - """ - The base class for patterns. - """ +class GenericArg(AstNode): pass -class Label(AstNode): - """ - A label. For example: - ```rust - 'label: loop { - println!("Hello, world (once)!"); - break 'label; - }; - ``` - """ - name: string +class GenericParam(AstNode): + pass -class Stmt(AstNode): - """ - The base class for statements. - """ +class Pat(AstNode): pass -class TypeRef(AstNode, Unimplemented): - """ - The base class for type references. - ```rust - let x: i32; - let y: Vec; - let z: Option; - ``` - """ +class Stmt(AstNode): pass -class Path(AstNode, Unimplemented): - """ - A path. For example: - ```rust - foo::bar; - ``` - """ +class TypeRef(AstNode): pass -class GenericArgList(AstNode, Unimplemented): - """ - The base class for generic arguments. - ```rust - x.foo::(42); - ``` - """ +class Item(Stmt): pass -@rust.doc_test_signature(None) -class Function(Declaration): - """ - A function declaration. For example - ```rust - fn foo(x: u32) -> u64 {(x + 1).into()} - ``` - A function declaration within a trait might not have a body: - ```rust - trait Trait { - fn bar(); - } - ``` - """ - name: string - body: Expr | child +class Abi(AstNode): + abi_string: optional[string] -class MissingExpr(Expr, Missing): - """ - A missing expression, used as a placeholder for incomplete syntax. +class ArgList(AstNode): + args: list["Expr"] | child - ```rust - let x = non_existing_macro!(); - ``` - """ - pass +class ArrayExpr(Expr): + attrs: list["Attr"] | child + exprs: list["Expr"] | child -class PathExpr(Expr): - """ - A path expression. For example: - ```rust - let x = variable; - let x = foo::bar; - let y = ::foo; - let z = ::foo; - ``` - """ - path: Path | child +class ArrayType(TypeRef): + const_arg: optional["ConstArg"] | child + ty: optional["TypeRef"] | child -class IfExpr(Expr): - """ - An `if` expression. For example: - ```rust - if x == 42 { - println!("that's the answer"); - } - ``` - ```rust - let y = if x > 0 { - 1 - } else { - 0 - } - ``` - """ - condition: Expr | child - then: Expr | child - else_: optional[Expr] | child +class AsmExpr(Expr): + attrs: list["Attr"] | child + expr: optional["Expr"] | child -@rust.doc_test_signature("(maybe_some: Option) -> ()") -class LetExpr(Expr): - """ - A `let` expression. For example: - ```rust - if let Some(x) = maybe_some { - println!("{}", x); - } - ``` - """ - pat: Pat | child - expr: Expr | child +class AssocItemList(AstNode): + assoc_items: list["AssocItem"] | child + attrs: list["Attr"] | child -class BlockExprBase(Expr): - statements: list[Stmt] | child - tail: optional[Expr] | child +class AssocTypeArg(GenericArg): + const_arg: optional["ConstArg"] | child + generic_arg_list: optional["GenericArgList"] | child + name_ref: optional["NameRef"] | child + param_list: optional["ParamList"] | child + ret_type: optional["RetType"] | child + return_type_syntax: optional["ReturnTypeSyntax"] | child + ty: optional["TypeRef"] | child + type_bound_list: optional["TypeBoundList"] | child -class BlockExpr(BlockExprBase): - """ - A block expression. For example: - ```rust - { - let x = 42; - } - ``` - ```rust - 'label: { - let x = 42; - x - } - ``` - """ - label: optional[Label] | child +class Attr(AstNode): + meta: optional["Meta"] | child -@rust.doc_test_signature("() -> i32") -class AsyncBlockExpr(BlockExprBase): - """ - An async block expression. For example: - ```rust - async { - let x = 42; - x - }.await - ``` - """ - pass +class AwaitExpr(Expr): + attrs: list["Attr"] | child + expr: optional["Expr"] | child -@rust.doc_test_signature("() -> bool") -class ConstExpr(Expr): - """ - A `const` block expression. For example: - ```rust - if const { SRC::IS_ZST || DEST::IS_ZST || mem::align_of::() != mem::align_of::() } { - return false; - } - ``` - """ - expr: Expr | child +class BecomeExpr(Expr): + attrs: list["Attr"] | child + expr: optional["Expr"] | child -class UnsafeBlockExpr(BlockExprBase): - """ - An unsafe block expression. For example: - ```rust - let layout = unsafe { - let x = 42; - Layout::from_size_align_unchecked(size, align) - }; - ``` - """ - pass +class BinaryExpr(Expr): + attrs: list["Attr"] | child + lhs: optional["Expr"] | child + operator_name: optional[string] + rhs: optional["Expr"] | child -class LoopExpr(Expr): - """ - A loop expression. For example: - ```rust - loop { - println!("Hello, world (again)!"); - }; - ``` - ```rust - 'label: loop { - println!("Hello, world (once)!"); - break 'label; - }; - ``` - ```rust - let mut x = 0; - loop { - if x < 10 { - x += 1; - } else { - break; - } - }; - ``` - """ - body: Expr | child - label: optional[Label] | child + +class BlockExpr(Expr): + attrs: list["Attr"] | child + label: optional["Label"] | child + stmt_list: optional["StmtList"] | child + + +class BoxPat(Pat): + pat: optional["Pat"] | child + + +class BreakExpr(Expr): + attrs: list["Attr"] | child + expr: optional["Expr"] | child + lifetime: optional["Lifetime"] | child class CallExpr(Expr): - """ - A function call expression. For example: - ```rust - foo(42); - foo::(42); - foo[0](42); - foo(1) = 4; - ``` - """ - callee: Expr | child - args: list[Expr] | child - is_assignee_expr: predicate + arg_list: optional["ArgList"] | child + attrs: list["Attr"] | child + expr: optional["Expr"] | child -class MethodCallExpr(Expr): - """ - A method call expression. For example: - ```rust - x.foo(42); - x.foo::(42); - ``` - """ - receiver: Expr | child - method_name: string - args: list[Expr] | child - generic_args: optional[GenericArgList] | child +class CastExpr(Expr): + attrs: list["Attr"] | child + expr: optional["Expr"] | child + ty: optional["TypeRef"] | child -@rust.doc_test_signature("(x: i32) -> i32") -class MatchArm(AstNode): - """ - A match arm. For example: - ```rust - match x { - Option::Some(y) => y, - Option::None => 0, - }; - ``` - ```rust - match x { - Some(y) if y != 0 => 1 / y, - _ => 0, - }; - ``` - """ - pat: Pat | child - guard: optional[Expr] | child - expr: Expr | child +class ClosureBinder(AstNode): + generic_param_list: optional["GenericParamList"] | child -@rust.doc_test_signature("(x: i32) -> i32") -class MatchExpr(Expr): - """ - A match expression. For example: - ```rust - match x { - Option::Some(y) => y, - Option::None => 0, - } - ``` - ```rust - match x { - Some(y) if y != 0 => 1 / y, - _ => 0, - } - ``` - """ - expr: Expr | child - branches: list[MatchArm] | child +class ClosureExpr(Expr): + attrs: list["Attr"] | child + body: optional["Expr"] | child + closure_binder: optional["ClosureBinder"] | child + param_list: optional["ParamList"] | child + ret_type: optional["RetType"] | child + + +class Const(AssocItem, Item): + attrs: list["Attr"] | child + body: optional["Expr"] | child + name: optional["Name"] | child + ty: optional["TypeRef"] | child + visibility: optional["Visibility"] | child + + +class ConstArg(GenericArg): + expr: optional["Expr"] | child + + +class ConstBlockPat(Pat): + block_expr: optional["BlockExpr"] | child + + +class ConstParam(GenericParam): + attrs: list["Attr"] | child + default_val: optional["ConstArg"] | child + name: optional["Name"] | child + ty: optional["TypeRef"] | child class ContinueExpr(Expr): - """ - A continue expression. For example: - ```rust - loop { - if not_ready() { - continue; - } - } - ``` - ```rust - 'label: loop { - if not_ready() { - continue 'label; - } - } - ``` - """ - label: optional[Label] | child + attrs: list["Attr"] | child + lifetime: optional["Lifetime"] | child -class BreakExpr(Expr): - """ - A break expression. For example: - ```rust - loop { - if not_ready() { - break; - } - } - ``` - ```rust - let x = 'label: loop { - if done() { - break 'label 42; - } - }; - ``` - """ - expr: optional[Expr] | child - label: optional[Label] | child - - -@rust.doc_test_signature(None) -class ReturnExpr(Expr): - """ - A return expression. For example: - ```rust - fn some_value() -> i32 { - return 42; - } - ``` - ```rust - fn no_value() -> () { - return; - } - ``` - """ - expr: optional[Expr] | child +class DynTraitType(TypeRef): + type_bound_list: optional["TypeBoundList"] | child -@rust.doc_test_signature(None) -class BecomeExpr(Expr): - """ - A `become` expression. For example: - ```rust - fn fact_a(n: i32, a: i32) -> i32 { - if n == 0 { - a - } else { - become fact_a(n - 1, n * a) - } - } - ``` - """ - expr: Expr | child +class Enum(Item): + attrs: list["Attr"] | child + generic_param_list: optional["GenericParamList"] | child + name: optional["Name"] | child + variant_list: optional["VariantList"] | child + visibility: optional["Visibility"] | child + where_clause: optional["WhereClause"] | child -class YieldExpr(Expr): - """ - A `yield` expression. For example: - ```rust - let one = #[coroutine] - || { - yield 1; - }; - ``` - """ - expr: optional[Expr] | child +class ExprStmt(Stmt): + expr: optional["Expr"] | child -class YeetExpr(Expr): - """ - A `yeet` expression. For example: - ```rust - if x < size { - do yeet "index out of bounds"; - } - ``` - """ - expr: optional[Expr] | child +class ExternBlock(Item): + abi: optional["Abi"] | child + attrs: list["Attr"] | child + extern_item_list: optional["ExternItemList"] | child -class RecordExprField(AstNode): - """ - A field in a record expression. For example `a: 1` in: - ```rust - Foo { a: 1, b: 2 }; - ``` - """ - name: string - expr: Expr | child +class ExternCrate(Item): + attrs: list["Attr"] | child + name_ref: optional["NameRef"] | child + rename: optional["Rename"] | child + visibility: optional["Visibility"] | child -class RecordExpr(Expr): - """ - A record expression. For example: - ```rust - let first = Foo { a: 1, b: 2 }; - let second = Foo { a: 2, ..first }; - Foo { a: 1, b: 2 }[2] = 10; - Foo { .. } = second; - ``` - """ - path: optional[Path] | child - flds: list[RecordExprField] | child - spread: optional[Expr] | child - has_ellipsis: predicate - is_assignee_expr: predicate +class ExternItemList(AstNode): + attrs: list["Attr"] | child + extern_items: list["ExternItem"] | child class FieldExpr(Expr): - """ - A field access expression. For example: - ```rust - x.foo - ``` - """ - expr: Expr | child - name: string + attrs: list["Attr"] | child + expr: optional["Expr"] | child + name_ref: optional["NameRef"] | child -class AwaitExpr(Expr): - """ - An `await` expression. For example: - ```rust - async { - let x = foo().await; - x - } - ``` - """ - expr: Expr | child +class Function(AssocItem, ExternItem, Item): + abi: optional["Abi"] | child + attrs: list["Attr"] | child + body: optional["BlockExpr"] | child + generic_param_list: optional["GenericParamList"] | child + name: optional["Name"] | child + param_list: optional["ParamList"] | child + ret_type: optional["RetType"] | child + visibility: optional["Visibility"] | child + where_clause: optional["WhereClause"] | child -class CastExpr(Expr): - """ - A cast expression. For example: - ```rust - value as u64; - ``` - """ - expr: Expr | child - type: TypeRef | child +class FnPtrType(TypeRef): + abi: optional["Abi"] | child + param_list: optional["ParamList"] | child + ret_type: optional["RetType"] | child -class RefExpr(Expr): - """ - A reference expression. For example: - ```rust - let ref_const = &foo; - let ref_mut = &mut foo; - let raw_const: &mut i32 = &raw const foo; - let raw_mut: &mut i32 = &raw mut foo; - ``` - """ - expr: Expr | child - is_raw: predicate - is_mut: predicate +class ForExpr(Expr): + attrs: list["Attr"] | child + iterable: optional["Expr"] | child + label: optional["Label"] | child + loop_body: optional["BlockExpr"] | child + pat: optional["Pat"] | child -class BoxExpr(Expr): - """ - A box expression. For example: - ```rust - let x = #[rustc_box] Box::new(42); - ``` - """ - expr: Expr | child +class ForType(TypeRef): + generic_param_list: optional["GenericParamList"] | child + ty: optional["TypeRef"] | child -class PrefixExpr(Expr): - """ - A unary operation expression. For example: - ```rust - let x = -42 - let y = !true - let z = *ptr - ``` - """ - expr: Expr | child - op: string +class FormatArgsArg(AstNode): + expr: optional["Expr"] | child + name: optional["Name"] | child -class BinaryExpr(Expr): - """ - A binary operation expression. For example: - ```rust - x + y; - x && y; - x <= y; - x = y; - x += y; - ``` - """ - lhs: Expr | child - rhs: Expr | child - op: optional[string] +class FormatArgsExpr(Expr): + args: list["FormatArgsArg"] | child + attrs: list["Attr"] | child + template: optional["Expr"] | child -class RangeExpr(Expr): - """ - A range expression. For example: - ```rust - let x = 1..=10; - let x = 1..10; - let x = 10..; - let x = ..10; - let x = ..=10; - let x = ..; - ``` - """ - lhs: optional[Expr] | child - rhs: optional[Expr] | child - is_inclusive: predicate +class GenericArgList(AstNode): + generic_args: list["GenericArg"] | child -class IndexExpr(Expr): - """ - An index expression. For example: - ```rust - list[42]; - list[42] = 1; - ``` - """ - base: Expr | child - index: Expr | child - is_assignee_expr: predicate +class GenericParamList(AstNode): + generic_params: list["GenericParam"] | child -class ClosureExpr(Expr): - """ - A closure expression. For example: - ```rust - |x| x + 1; - move |x: i32| -> i32 { x + 1 }; - async |x: i32, y| x + y; - #[coroutine] - |x| yield x; - #[coroutine] - static |x| yield x; - ``` - """ - args: list[Pat] | child - arg_types: list[optional[TypeRef]] | child - ret_type: optional[TypeRef] | child - body: Expr | child - closure_kind: string - is_move: predicate +class IdentPat(Pat): + attrs: list["Attr"] | child + name: optional["Name"] | child + pat: optional["Pat"] | child -class TupleExpr(Expr): - """ - A tuple expression. For example: - ```rust - (1, "one"); - (2, "two")[0] = 3; - ``` - """ - exprs: list[Expr] | child - is_assignee_expr: predicate +class IfExpr(Expr): + attrs: list["Attr"] | child + condition: optional["Expr"] | child + else_: optional["Expr"] | child + then: optional["BlockExpr"] | child -class ArrayExpr(Expr): - """ - An array expression. For example: - ```rust - [1, 2, 3]; - [1; 10]; - ``` - """ - pass +class Impl(Item): + assoc_item_list: optional["AssocItemList"] | child + attrs: list["Attr"] | child + generic_param_list: optional["GenericParamList"] | child + self_ty: optional["TypeRef"] | child + trait_: optional["TypeRef"] | child + visibility: optional["Visibility"] | child + where_clause: optional["WhereClause"] | child -class ElementListExpr(ArrayExpr): - """ - An element list expression. For example: - ```rust - [1, 2, 3, 4, 5]; - [1, 2, 3, 4, 5][0] = 6; - ``` - """ - elements: list[Expr] | child - is_assignee_expr: predicate +class ImplTraitType(TypeRef): + type_bound_list: optional["TypeBoundList"] | child -class RepeatExpr(ArrayExpr): - """ - A repeat expression. For example: - ```rust - [1; 10]; - ``` - """ - initializer: Expr | child - repeat: Expr | child +class IndexExpr(Expr): + attrs: list["Attr"] | child + base: optional["Expr"] | child + index: optional["Expr"] | child -class LiteralExpr(Expr): - """ - A literal expression. For example: - ```rust - 42; - 42.0; - "Hello, world!"; - b"Hello, world!"; - 'x'; - b'x'; - r"Hello, world!"; - true; - ``` - """ +class InferType(TypeRef): pass -class UnderscoreExpr(Expr): - """ - An underscore expression. For example: - ```rust - _ = 42; - ``` - """ - pass +class ItemList(AstNode): + attrs: list["Attr"] | child + items: list["Item"] | child -class OffsetOfExpr(Expr): - """ - An `offset_of` expression. For example: - ```rust - builtin # offset_of(Struct, field); - ``` - """ - container: TypeRef | child - fields: list[string] +class Label(AstNode): + lifetime: optional["Lifetime"] | child -class AsmExpr(Expr): - """ - An inline assembly expression. For example: - ```rust - unsafe { - builtin # asm(_); - } - ``` - """ - expr: Expr | child +class LetElse(AstNode): + block_expr: optional["BlockExpr"] | child + + +class LetExpr(Expr): + attrs: list["Attr"] | child + expr: optional["Expr"] | child + pat: optional["Pat"] | child class LetStmt(Stmt): - """ - A let statement. For example: - ```rust - let x = 42; - let x: i32 = 42; - let x: i32; - let x; - let (x, y) = (1, 2); - let Some(x) = std::env::var("FOO") else { - return; - }; - ``` - """ - pat: Pat | child - type: optional[TypeRef] | child - initializer: optional[Expr] | child - else_: optional[Expr] | child + attrs: list["Attr"] | child + initializer: optional["Expr"] | child + let_else: optional["LetElse"] | child + pat: optional["Pat"] | child + ty: optional["TypeRef"] | child -class ExprStmt(Stmt): - """ - An expression statement. For example: - ```rust - start(); - finish() - use std::env; - ``` - """ - expr: Expr | child - has_semicolon: predicate +class Lifetime(AstNode): + text: optional[string] -# At the HIR-level, we don't have items, only some markers without location indicating where they used to be. -@qltest.skip -class ItemStmt(Stmt): - """ - An item statement. For example: - ```rust - fn print_hello() { - println!("Hello, world!"); - } - print_hello(); - ``` - """ - pass +class LifetimeArg(GenericArg): + lifetime: optional["Lifetime"] | child -class MissingPat(Pat, Missing): - """ - A missing pattern, used as a place holder for incomplete syntax. - ```rust - match Some(42) { - .. => "bad use of .. syntax", - }; - ``` - """ - pass +class LifetimeParam(GenericParam): + attrs: list["Attr"] | child + lifetime: optional["Lifetime"] | child + type_bound_list: optional["TypeBoundList"] | child -class WildcardPat(Pat): - """ - A wildcard pattern. For example: - ```rust - let _ = 42; - ``` - """ +class LiteralExpr(Expr): + attrs: list["Attr"] | child + text_value: optional[string] + + +class LiteralPat(Pat): + literal: optional["LiteralExpr"] | child + + +class LoopExpr(Expr): + attrs: list["Attr"] | child + label: optional["Label"] | child + loop_body: optional["BlockExpr"] | child + + +class MacroCall(AssocItem, ExternItem, Item): + attrs: list["Attr"] | child + path: optional["Path"] | child + token_tree: optional["TokenTree"] | child + + +class MacroDef(Item): + args: optional["TokenTree"] | child + attrs: list["Attr"] | child + body: optional["TokenTree"] | child + name: optional["Name"] | child + visibility: optional["Visibility"] | child + + +class MacroExpr(Expr): + macro_call: optional["MacroCall"] | child + + +class MacroPat(Pat): + macro_call: optional["MacroCall"] | child + + +class MacroRules(Item): + attrs: list["Attr"] | child + name: optional["Name"] | child + token_tree: optional["TokenTree"] | child + visibility: optional["Visibility"] | child + + +class MacroType(TypeRef): + macro_call: optional["MacroCall"] | child + + +class MatchArm(AstNode): + attrs: list["Attr"] | child + expr: optional["Expr"] | child + guard: optional["MatchGuard"] | child + pat: optional["Pat"] | child + + +class MatchArmList(AstNode): + arms: list["MatchArm"] | child + attrs: list["Attr"] | child + + +class MatchExpr(Expr): + attrs: list["Attr"] | child + expr: optional["Expr"] | child + match_arm_list: optional["MatchArmList"] | child + + +class MatchGuard(AstNode): + condition: optional["Expr"] | child + + +class Meta(AstNode): + expr: optional["Expr"] | child + path: optional["Path"] | child + token_tree: optional["TokenTree"] | child + + +class MethodCallExpr(Expr): + arg_list: optional["ArgList"] | child + attrs: list["Attr"] | child + generic_arg_list: optional["GenericArgList"] | child + name_ref: optional["NameRef"] | child + receiver: optional["Expr"] | child + + +class Module(Item): + attrs: list["Attr"] | child + item_list: optional["ItemList"] | child + name: optional["Name"] | child + visibility: optional["Visibility"] | child + + +class Name(AstNode): + text: optional[string] + + +class NameRef(AstNode): + text: optional[string] + + +class NeverType(TypeRef): pass -class TuplePat(Pat): - """ - A tuple pattern. For example: - ```rust - let (x, y) = (1, 2); - let (a, b, .., z) = (1, 2, 3, 4, 5); - ``` - """ - args: list[Pat] | child - ellipsis_index: optional[int] +class OffsetOfExpr(Expr): + attrs: list["Attr"] | child + fields: list["NameRef"] | child + ty: optional["TypeRef"] | child class OrPat(Pat): - """ - An or pattern. For example: - ```rust - match x { - Option::Some(y) | Option::None => 0, - } - ``` - """ - args: list[Pat] | child + pats: list["Pat"] | child -class RecordPatField(AstNode): - """ - A field in a record pattern. For example `a: 1` in: - ```rust - let Foo { a: 1, b: 2 } = foo; - ``` - """ - name: string - pat: Pat | child +class Param(AstNode): + attrs: list["Attr"] | child + pat: optional["Pat"] | child + ty: optional["TypeRef"] | child -class RecordPat(Pat): - """ - A record pattern. For example: - ```rust - match x { - Foo { a: 1, b: 2 } => "ok", - Foo { .. } => "fail", - } - ``` - """ +class ParamList(AstNode): + params: list["Param"] | child + self_param: optional["SelfParam"] | child + + +class ParenExpr(Expr): + attrs: list["Attr"] | child + expr: optional["Expr"] | child + + +class ParenPat(Pat): + pat: optional["Pat"] | child + - path: optional[Path] | child - flds: list[RecordPatField] | child - has_ellipsis: predicate +class ParenType(TypeRef): + ty: optional["TypeRef"] | child + + +class Path(AstNode): + qualifier: optional["Path"] | child + part: optional["PathSegment"] | child + + +class PathExpr(Expr): + attrs: list["Attr"] | child + path: optional["Path"] | child + + +class PathPat(Pat): + path: optional["Path"] | child + + +class PathSegment(AstNode): + generic_arg_list: optional["GenericArgList"] | child + name_ref: optional["NameRef"] | child + param_list: optional["ParamList"] | child + path_type: optional["PathType"] | child + ret_type: optional["RetType"] | child + return_type_syntax: optional["ReturnTypeSyntax"] | child + ty: optional["TypeRef"] | child + + +class PathType(TypeRef): + path: optional["Path"] | child + + +class PrefixExpr(Expr): + attrs: list["Attr"] | child + expr: optional["Expr"] | child + operator_name: optional[string] + + +class PtrType(TypeRef): + ty: optional["TypeRef"] | child + + +class RangeExpr(Expr): + attrs: list["Attr"] | child + end: optional["Expr"] | child + operator_name: optional[string] + start: optional["Expr"] | child class RangePat(Pat): - """ - A range pattern. For example: - ```rust - match x { - ..15 => "too cold", - 16..=25 => "just right", - 26.. => "too hot", - } - ``` - """ - start: optional[Pat] | child - end: optional[Pat] | child + end: optional["Pat"] | child + operator_name: optional[string] + start: optional["Pat"] | child + + +class RecordExpr(Expr): + path: optional["Path"] | child + record_expr_field_list: optional["RecordExprFieldList"] | child + + +class RecordExprField(AstNode): + attrs: list["Attr"] | child + expr: optional["Expr"] | child + name_ref: optional["NameRef"] | child + + +class RecordExprFieldList(AstNode): + attrs: list["Attr"] | child + fields: list["RecordExprField"] | child + spread: optional["Expr"] | child + + +class RecordField(AstNode): + attrs: list["Attr"] | child + name: optional["Name"] | child + ty: optional["TypeRef"] | child + visibility: optional["Visibility"] | child + + +class RecordFieldList(FieldList): + fields: list["RecordField"] | child + + +class RecordPat(Pat): + path: optional["Path"] | child + record_pat_field_list: optional["RecordPatFieldList"] | child + + +class RecordPatField(AstNode): + attrs: list["Attr"] | child + name_ref: optional["NameRef"] | child + pat: optional["Pat"] | child + + +class RecordPatFieldList(AstNode): + fields: list["RecordPatField"] | child + rest_pat: optional["RestPat"] | child + + +class RefExpr(Expr): + attrs: list["Attr"] | child + expr: optional["Expr"] | child + + +class RefPat(Pat): + pat: optional["Pat"] | child + + +class RefType(TypeRef): + lifetime: optional["Lifetime"] | child + ty: optional["TypeRef"] | child + + +class Rename(AstNode): + name: optional["Name"] | child + + +class RestPat(Pat): + attrs: list["Attr"] | child + + +class RetType(AstNode): + ty: optional["TypeRef"] | child + + +class ReturnExpr(Expr): + attrs: list["Attr"] | child + expr: optional["Expr"] | child + + +class ReturnTypeSyntax(AstNode): + pass + + +class SelfParam(AstNode): + attrs: list["Attr"] | child + lifetime: optional["Lifetime"] | child + name: optional["Name"] | child + ty: optional["TypeRef"] | child class SlicePat(Pat): - """ - A slice pattern. For example: - ```rust - match x { - [1, 2, 3, 4, 5] => "ok", - [1, 2, ..] => "fail", - [x, y, .., z, 7] => "fail", - } - ``` - """ - prefix: list[Pat] | child - slice: optional[Pat] | child - suffix: list[Pat] | child + pats: list["Pat"] | child -class PathPat(Pat): - """ - A path pattern. For example: - ```rust - match x { - Foo::Bar => "ok", - _ => "fail", - } - ``` - """ - path: Path | child +class SliceType(TypeRef): + ty: optional["TypeRef"] | child -class LiteralPat(Pat): - """ - A literal pattern. For example: - ```rust - match x { - 42 => "ok", - _ => "fail", - } - ``` - """ - expr: Expr | child +class SourceFile(AstNode): + attrs: list["Attr"] | child + items: list["Item"] | child -class IdentPat(Pat): - """ - A binding pattern. For example: - ```rust - match x { - Option::Some(y) => y, - Option::None => 0, - }; - ``` - ```rust - match x { - y@Option::Some(_) => y, - Option::None => 0, - }; - ``` - """ - binding_id: string - subpat: optional[Pat] | child +class Static(ExternItem, Item): + attrs: list["Attr"] | child + body: optional["Expr"] | child + name: optional["Name"] | child + ty: optional["TypeRef"] | child + visibility: optional["Visibility"] | child + + +class StmtList(AstNode): + attrs: list["Attr"] | child + statements: list["Stmt"] | child + tail_expr: optional["Expr"] | child + + +class Struct(Item): + attrs: list["Attr"] | child + field_list: optional["FieldList"] | child + generic_param_list: optional["GenericParamList"] | child + name: optional["Name"] | child + visibility: optional["Visibility"] | child + where_clause: optional["WhereClause"] | child + + +class TokenTree(AstNode): + pass + + +class Trait(Item): + assoc_item_list: optional["AssocItemList"] | child + attrs: list["Attr"] | child + generic_param_list: optional["GenericParamList"] | child + name: optional["Name"] | child + type_bound_list: optional["TypeBoundList"] | child + visibility: optional["Visibility"] | child + where_clause: optional["WhereClause"] | child + + +class TraitAlias(Item): + attrs: list["Attr"] | child + generic_param_list: optional["GenericParamList"] | child + name: optional["Name"] | child + type_bound_list: optional["TypeBoundList"] | child + visibility: optional["Visibility"] | child + where_clause: optional["WhereClause"] | child + + +class TryExpr(Expr): + attrs: list["Attr"] | child + expr: optional["Expr"] | child + + +class TupleExpr(Expr): + attrs: list["Attr"] | child + fields: list["Expr"] | child + + +class TupleField(AstNode): + attrs: list["Attr"] | child + ty: optional["TypeRef"] | child + visibility: optional["Visibility"] | child + + +class TupleFieldList(FieldList): + fields: list["TupleField"] | child + + +class TuplePat(Pat): + fields: list["Pat"] | child class TupleStructPat(Pat): - """ - A tuple struct pattern. For example: - ```rust - match x { - Tuple("a", 1, 2, 3) => "great", - Tuple(.., 3) => "fine", - Tuple(..) => "fail", - }; - ``` - """ - path: optional[Path] | child - args: list[Pat] | child - ellipsis_index: optional[int] + fields: list["Pat"] | child + path: optional["Path"] | child -class RefPat(Pat): - """ - A reference pattern. For example: - ```rust - match x { - &mut Option::Some(y) => y, - &Option::None => 0, - }; - ``` - """ - pat: Pat | child - is_mut: predicate +class TupleType(TypeRef): + fields: list["TypeRef"] | child -class BoxPat(Pat): - """ - A box pattern. For example: - ```rust - match x { - box Option::Some(y) => y, - box Option::None => 0, - }; - ``` - """ - inner: Pat | child +class TypeAlias(AssocItem, ExternItem, Item): + attrs: list["Attr"] | child + generic_param_list: optional["GenericParamList"] | child + name: optional["Name"] | child + ty: optional["TypeRef"] | child + type_bound_list: optional["TypeBoundList"] | child + visibility: optional["Visibility"] | child + where_clause: optional["WhereClause"] | child -class ConstBlockPat(Pat): - """ - A const block pattern. For example: - ```rust - match x { - const { 1 + 2 + 3 } => "ok", - _ => "fail", - }; - ``` - """ - expr: Expr | child +class TypeArg(GenericArg): + ty: optional["TypeRef"] | child + + +class TypeBound(AstNode): + generic_param_list: optional["GenericParamList"] | child + lifetime: optional["Lifetime"] | child + ty: optional["TypeRef"] | child + + +class TypeBoundList(AstNode): + bounds: list["TypeBound"] | child + + +class TypeParam(GenericParam): + attrs: list["Attr"] | child + default_type: optional["TypeRef"] | child + name: optional["Name"] | child + type_bound_list: optional["TypeBoundList"] | child + + +class UnderscoreExpr(Expr): + attrs: list["Attr"] | child + + +class Union(Item): + attrs: list["Attr"] | child + generic_param_list: optional["GenericParamList"] | child + name: optional["Name"] | child + record_field_list: optional["RecordFieldList"] | child + visibility: optional["Visibility"] | child + where_clause: optional["WhereClause"] | child + + +class Use(Item): + attrs: list["Attr"] | child + use_tree: optional["UseTree"] | child + visibility: optional["Visibility"] | child + + +class UseTree(AstNode): + path: optional["Path"] | child + rename: optional["Rename"] | child + use_tree_list: optional["UseTreeList"] | child + + +class UseTreeList(AstNode): + use_trees: list["UseTree"] | child + + +class Variant(AstNode): + attrs: list["Attr"] | child + expr: optional["Expr"] | child + field_list: optional["FieldList"] | child + name: optional["Name"] | child + visibility: optional["Visibility"] | child + + +class VariantList(AstNode): + variants: list["Variant"] | child + + +class Visibility(AstNode): + path: optional["Path"] | child + + +class WhereClause(AstNode): + predicates: list["WherePred"] | child + + +class WherePred(AstNode): + generic_param_list: optional["GenericParamList"] | child + lifetime: optional["Lifetime"] | child + ty: optional["TypeRef"] | child + type_bound_list: optional["TypeBoundList"] | child + + +class WhileExpr(Expr): + attrs: list["Attr"] | child + condition: optional["Expr"] | child + label: optional["Label"] | child + loop_body: optional["BlockExpr"] | child + + +class WildcardPat(Pat): + pass + + +class YeetExpr(Expr): + attrs: list["Attr"] | child + expr: optional["Expr"] | child + + +class YieldExpr(Expr): + attrs: list["Attr"] | child + expr: optional["Expr"] | child From 80d32a2333251570c9e6b720b5f3616332512379 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Mon, 16 Sep 2024 19:00:12 +0200 Subject: [PATCH 07/12] Rust: re-generate code --- rust/extractor/src/generated/.generated.list | 2 +- rust/extractor/src/generated/top.rs | 8329 +++++++++++++---- rust/ql/.generated.list | 1016 +- rust/ql/.gitattributes | 662 +- rust/ql/lib/codeql/rust/elements.qll | 104 +- rust/ql/lib/codeql/rust/elements/Abi.qll | 9 + rust/ql/lib/codeql/rust/elements/ArgList.qll | 10 + .../ql/lib/codeql/rust/elements/ArrayExpr.qll | 8 +- .../ql/lib/codeql/rust/elements/ArrayType.qll | 10 + rust/ql/lib/codeql/rust/elements/AsmExpr.qll | 9 +- .../ql/lib/codeql/rust/elements/AssocItem.qll | 9 + .../codeql/rust/elements/AssocItemList.qll | 11 + .../lib/codeql/rust/elements/AssocTypeArg.qll | 17 + .../codeql/rust/elements/AsyncBlockExpr.qll | 18 - rust/ql/lib/codeql/rust/elements/Attr.qll | 10 + .../ql/lib/codeql/rust/elements/AwaitExpr.qll | 10 +- .../lib/codeql/rust/elements/BecomeExpr.qll | 13 +- .../lib/codeql/rust/elements/BinaryExpr.qll | 11 +- .../ql/lib/codeql/rust/elements/BlockExpr.qll | 18 +- .../codeql/rust/elements/BlockExprBase.qll | 10 - rust/ql/lib/codeql/rust/elements/BoxExpr.qll | 15 - rust/ql/lib/codeql/rust/elements/BoxPat.qll | 9 - .../ql/lib/codeql/rust/elements/BreakExpr.qll | 20 +- rust/ql/lib/codeql/rust/elements/CallExpr.qll | 11 +- rust/ql/lib/codeql/rust/elements/CastExpr.qll | 7 +- .../codeql/rust/elements/ClosureBinder.qll | 10 + .../lib/codeql/rust/elements/ClosureExpr.qll | 18 +- rust/ql/lib/codeql/rust/elements/Const.qll | 15 + rust/ql/lib/codeql/rust/elements/ConstArg.qll | 10 + .../codeql/rust/elements/ConstBlockPat.qll | 11 +- .../ql/lib/codeql/rust/elements/ConstExpr.qll | 17 - .../lib/codeql/rust/elements/ConstParam.qll | 13 + .../lib/codeql/rust/elements/ContinueExpr.qll | 20 +- .../lib/codeql/rust/elements/Declaration.qll | 12 - .../lib/codeql/rust/elements/DynTraitType.qll | 10 + .../codeql/rust/elements/ElementListExpr.qll | 17 - rust/ql/lib/codeql/rust/elements/Enum.qll | 15 + rust/ql/lib/codeql/rust/elements/Expr.qll | 3 - rust/ql/lib/codeql/rust/elements/ExprStmt.qll | 8 - .../lib/codeql/rust/elements/ExternBlock.qll | 12 + .../lib/codeql/rust/elements/ExternCrate.qll | 13 + .../lib/codeql/rust/elements/ExternItem.qll | 9 + .../codeql/rust/elements/ExternItemList.qll | 11 + .../ql/lib/codeql/rust/elements/FieldExpr.qll | 8 +- .../ql/lib/codeql/rust/elements/FieldList.qll | 9 + .../ql/lib/codeql/rust/elements/FnPtrType.qll | 12 + rust/ql/lib/codeql/rust/elements/ForExpr.qll | 13 + rust/ql/lib/codeql/rust/elements/ForType.qll | 10 + .../codeql/rust/elements/FormatArgsArg.qll | 11 + .../codeql/rust/elements/FormatArgsExpr.qll | 11 + rust/ql/lib/codeql/rust/elements/Function.qll | 26 +- .../lib/codeql/rust/elements/GenericArg.qll | 9 + .../codeql/rust/elements/GenericArgList.qll | 8 +- .../lib/codeql/rust/elements/GenericParam.qll | 9 + .../codeql/rust/elements/GenericParamList.qll | 10 + rust/ql/lib/codeql/rust/elements/IdentPat.qll | 17 +- rust/ql/lib/codeql/rust/elements/IfExpr.qll | 17 +- rust/ql/lib/codeql/rust/elements/Impl.qll | 15 + .../codeql/rust/elements/ImplTraitType.qll | 10 + .../ql/lib/codeql/rust/elements/IndexExpr.qll | 8 +- .../ql/lib/codeql/rust/elements/InferType.qll | 9 + rust/ql/lib/codeql/rust/elements/Item.qll | 9 + rust/ql/lib/codeql/rust/elements/ItemList.qll | 11 + rust/ql/lib/codeql/rust/elements/ItemStmt.qll | 18 - rust/ql/lib/codeql/rust/elements/Label.qll | 10 +- rust/ql/lib/codeql/rust/elements/LetElse.qll | 10 + rust/ql/lib/codeql/rust/elements/LetExpr.qll | 9 +- rust/ql/lib/codeql/rust/elements/LetStmt.qll | 15 +- rust/ql/lib/codeql/rust/elements/Lifetime.qll | 9 + .../lib/codeql/rust/elements/LifetimeArg.qll | 10 + .../codeql/rust/elements/LifetimeParam.qll | 12 + .../lib/codeql/rust/elements/LiteralExpr.qll | 14 +- .../lib/codeql/rust/elements/LiteralPat.qll | 11 +- rust/ql/lib/codeql/rust/elements/LoopExpr.qll | 26 +- .../ql/lib/codeql/rust/elements/MacroCall.qll | 14 + rust/ql/lib/codeql/rust/elements/MacroDef.qll | 13 + .../ql/lib/codeql/rust/elements/MacroExpr.qll | 10 + rust/ql/lib/codeql/rust/elements/MacroPat.qll | 10 + .../lib/codeql/rust/elements/MacroRules.qll | 13 + .../ql/lib/codeql/rust/elements/MacroType.qll | 10 + rust/ql/lib/codeql/rust/elements/MatchArm.qll | 17 +- .../lib/codeql/rust/elements/MatchArmList.qll | 11 + .../ql/lib/codeql/rust/elements/MatchExpr.qll | 18 +- .../lib/codeql/rust/elements/MatchGuard.qll | 10 + rust/ql/lib/codeql/rust/elements/Meta.qll | 12 + .../codeql/rust/elements/MethodCallExpr.qll | 10 +- .../lib/codeql/rust/elements/MissingExpr.qll | 17 - .../lib/codeql/rust/elements/MissingPat.qll | 18 - rust/ql/lib/codeql/rust/elements/Module.qll | 17 +- rust/ql/lib/codeql/rust/elements/Name.qll | 9 + rust/ql/lib/codeql/rust/elements/NameRef.qll | 9 + .../ql/lib/codeql/rust/elements/NeverType.qll | 9 + .../lib/codeql/rust/elements/OffsetOfExpr.qll | 8 +- rust/ql/lib/codeql/rust/elements/OrPat.qll | 8 - rust/ql/lib/codeql/rust/elements/Param.qll | 12 + .../ql/lib/codeql/rust/elements/ParamList.qll | 11 + .../ql/lib/codeql/rust/elements/ParenExpr.qll | 10 + rust/ql/lib/codeql/rust/elements/ParenPat.qll | 9 + .../ql/lib/codeql/rust/elements/ParenType.qll | 9 + rust/ql/lib/codeql/rust/elements/Pat.qll | 3 - rust/ql/lib/codeql/rust/elements/Path.qll | 8 +- rust/ql/lib/codeql/rust/elements/PathExpr.qll | 10 +- rust/ql/lib/codeql/rust/elements/PathPat.qll | 9 - .../lib/codeql/rust/elements/PathSegment.qll | 16 + rust/ql/lib/codeql/rust/elements/PathType.qll | 10 + .../lib/codeql/rust/elements/PrefixExpr.qll | 9 +- rust/ql/lib/codeql/rust/elements/PtrType.qll | 9 + .../ql/lib/codeql/rust/elements/RangeExpr.qll | 12 +- rust/ql/lib/codeql/rust/elements/RangePat.qll | 10 - .../lib/codeql/rust/elements/RecordExpr.qll | 11 +- .../codeql/rust/elements/RecordExprField.qll | 8 +- .../rust/elements/RecordExprFieldList.qll | 12 + .../lib/codeql/rust/elements/RecordField.qll | 13 + .../codeql/rust/elements/RecordFieldList.qll | 10 + .../ql/lib/codeql/rust/elements/RecordPat.qll | 11 +- .../codeql/rust/elements/RecordPatField.qll | 8 +- .../rust/elements/RecordPatFieldList.qll | 11 + rust/ql/lib/codeql/rust/elements/RefExpr.qll | 10 +- rust/ql/lib/codeql/rust/elements/RefPat.qll | 9 - rust/ql/lib/codeql/rust/elements/RefType.qll | 10 + rust/ql/lib/codeql/rust/elements/Rename.qll | 10 + .../lib/codeql/rust/elements/RepeatExpr.qll | 16 - rust/ql/lib/codeql/rust/elements/RestPat.qll | 10 + rust/ql/lib/codeql/rust/elements/RetType.qll | 10 + .../lib/codeql/rust/elements/ReturnExpr.qll | 14 +- .../codeql/rust/elements/ReturnTypeSyntax.qll | 9 + .../ql/lib/codeql/rust/elements/SelfParam.qll | 13 + rust/ql/lib/codeql/rust/elements/SlicePat.qll | 10 - .../ql/lib/codeql/rust/elements/SliceType.qll | 9 + .../lib/codeql/rust/elements/SourceFile.qll | 11 + rust/ql/lib/codeql/rust/elements/Static.qll | 15 + rust/ql/lib/codeql/rust/elements/Stmt.qll | 3 - rust/ql/lib/codeql/rust/elements/StmtList.qll | 12 + rust/ql/lib/codeql/rust/elements/Struct.qll | 15 + .../ql/lib/codeql/rust/elements/TokenTree.qll | 9 + rust/ql/lib/codeql/rust/elements/Trait.qll | 16 + .../lib/codeql/rust/elements/TraitAlias.qll | 15 + rust/ql/lib/codeql/rust/elements/TryExpr.qll | 10 + .../ql/lib/codeql/rust/elements/TupleExpr.qll | 8 +- .../lib/codeql/rust/elements/TupleField.qll | 12 + .../codeql/rust/elements/TupleFieldList.qll | 10 + rust/ql/lib/codeql/rust/elements/TuplePat.qll | 7 - .../codeql/rust/elements/TupleStructPat.qll | 10 - .../ql/lib/codeql/rust/elements/TupleType.qll | 9 + .../ql/lib/codeql/rust/elements/TypeAlias.qll | 18 + rust/ql/lib/codeql/rust/elements/TypeArg.qll | 10 + .../ql/lib/codeql/rust/elements/TypeBound.qll | 12 + .../codeql/rust/elements/TypeBoundList.qll | 10 + .../ql/lib/codeql/rust/elements/TypeParam.qll | 13 + rust/ql/lib/codeql/rust/elements/TypeRef.qll | 9 - .../codeql/rust/elements/UnderscoreExpr.qll | 7 +- .../elements/UnimplementedDeclaration.qll | 13 - rust/ql/lib/codeql/rust/elements/Union.qll | 15 + .../codeql/rust/elements/UnsafeBlockExpr.qll | 18 - rust/ql/lib/codeql/rust/elements/Use.qll | 12 + rust/ql/lib/codeql/rust/elements/UseTree.qll | 12 + .../lib/codeql/rust/elements/UseTreeList.qll | 10 + rust/ql/lib/codeql/rust/elements/Variant.qll | 14 + .../lib/codeql/rust/elements/VariantList.qll | 10 + .../lib/codeql/rust/elements/Visibility.qll | 10 + .../lib/codeql/rust/elements/WhereClause.qll | 10 + .../ql/lib/codeql/rust/elements/WherePred.qll | 13 + .../ql/lib/codeql/rust/elements/WhileExpr.qll | 12 + .../lib/codeql/rust/elements/WildcardPat.qll | 6 - rust/ql/lib/codeql/rust/elements/YeetExpr.qll | 9 +- .../ql/lib/codeql/rust/elements/YieldExpr.qll | 10 +- .../rust/elements/internal/AbiConstructor.qll | 14 + .../{BlockExprBaseImpl.qll => AbiImpl.qll} | 8 +- ...Constructor.qll => ArgListConstructor.qll} | 6 +- .../{DeclarationImpl.qll => ArgListImpl.qll} | 11 +- ...nstructor.qll => ArrayExprConstructor.qll} | 6 +- .../rust/elements/internal/ArrayExprImpl.qll | 7 - .../internal/ArrayTypeConstructor.qll | 14 + .../{RepeatExprImpl.qll => ArrayTypeImpl.qll} | 14 +- .../rust/elements/internal/AsmExprImpl.qll | 8 - .../{BoxExprImpl.qll => AssocItemImpl.qll} | 14 +- .../internal/AssocItemListConstructor.qll | 14 + .../elements/internal/AssocItemListImpl.qll | 16 + .../internal/AssocTypeArgConstructor.qll | 14 + .../elements/internal/AssocTypeArgImpl.qll | 16 + .../elements/internal/AsyncBlockExprImpl.qll | 25 - .../elements/internal/AttrConstructor.qll | 14 + .../rust/elements/internal/AttrImpl.qll | 16 + .../rust/elements/internal/AwaitExprImpl.qll | 9 - .../rust/elements/internal/BecomeExprImpl.qll | 12 - .../rust/elements/internal/BinaryExprImpl.qll | 10 - .../rust/elements/internal/BlockExprImpl.qll | 14 - .../rust/elements/internal/BoxPatImpl.qll | 9 - .../rust/elements/internal/BreakExprImpl.qll | 17 - .../rust/elements/internal/CallExprImpl.qll | 9 - .../rust/elements/internal/CastExprImpl.qll | 6 - .../internal/ClosureBinderConstructor.qll | 14 + .../elements/internal/ClosureBinderImpl.qll | 16 + .../elements/internal/ClosureExprImpl.qll | 12 - ...onstructor.qll => ConstArgConstructor.qll} | 6 +- .../rust/elements/internal/ConstArgImpl.qll | 16 + .../elements/internal/ConstBlockPatImpl.qll | 9 - .../elements/internal/ConstConstructor.qll | 14 + .../rust/elements/internal/ConstExprImpl.qll | 24 - .../rust/elements/internal/ConstImpl.qll | 16 + ...structor.qll => ConstParamConstructor.qll} | 6 +- .../rust/elements/internal/ConstParamImpl.qll | 16 + .../elements/internal/ContinueExprImpl.qll | 17 - .../internal/DynTraitTypeConstructor.qll | 14 + .../elements/internal/DynTraitTypeImpl.qll | 16 + .../elements/internal/ElementListExprImpl.qll | 23 - .../elements/internal/EnumConstructor.qll | 14 + .../rust/elements/internal/EnumImpl.qll | 16 + .../rust/elements/internal/ExprImpl.qll | 3 - .../rust/elements/internal/ExprStmtImpl.qll | 8 - ...tructor.qll => ExternBlockConstructor.qll} | 6 +- .../elements/internal/ExternBlockImpl.qll | 16 + .../internal/ExternCrateConstructor.qll | 14 + .../elements/internal/ExternCrateImpl.qll | 16 + .../rust/elements/internal/ExternItemImpl.qll | 16 + ...ctor.qll => ExternItemListConstructor.qll} | 6 +- .../elements/internal/ExternItemListImpl.qll | 16 + .../rust/elements/internal/FieldExprImpl.qll | 6 - .../rust/elements/internal/FieldListImpl.qll | 16 + .../internal/FnPtrTypeConstructor.qll | 14 + .../rust/elements/internal/FnPtrTypeImpl.qll | 16 + ...Constructor.qll => ForExprConstructor.qll} | 6 +- .../rust/elements/internal/ForExprImpl.qll | 16 + .../elements/internal/ForTypeConstructor.qll | 14 + .../rust/elements/internal/ForTypeImpl.qll | 16 + .../internal/FormatArgsArgConstructor.qll | 14 + .../elements/internal/FormatArgsArgImpl.qll | 16 + .../internal/FormatArgsExprConstructor.qll | 14 + .../elements/internal/FormatArgsExprImpl.qll | 16 + .../rust/elements/internal/GenericArgImpl.qll | 16 + .../elements/internal/GenericArgListImpl.qll | 6 - .../elements/internal/GenericParamImpl.qll | 16 + ...or.qll => GenericParamListConstructor.qll} | 6 +- .../internal/GenericParamListImpl.qll | 16 + .../rust/elements/internal/IdentPatImpl.qll | 15 - .../rust/elements/internal/IfExprImpl.qll | 15 - .../elements/internal/ImplConstructor.qll | 14 + .../rust/elements/internal/ImplImpl.qll | 16 + .../internal/ImplTraitTypeConstructor.qll | 14 + .../elements/internal/ImplTraitTypeImpl.qll | 16 + .../rust/elements/internal/IndexExprImpl.qll | 7 - .../internal/InferTypeConstructor.qll | 14 + .../rust/elements/internal/InferTypeImpl.qll | 16 + .../rust/elements/internal/ItemImpl.qll | 16 + .../elements/internal/ItemListConstructor.qll | 14 + .../rust/elements/internal/ItemListImpl.qll | 16 + .../rust/elements/internal/ItemStmtImpl.qll | 25 - .../rust/elements/internal/LabelImpl.qll | 9 - .../elements/internal/LetElseConstructor.qll | 14 + .../rust/elements/internal/LetElseImpl.qll | 16 + .../rust/elements/internal/LetExprImpl.qll | 8 - .../rust/elements/internal/LetStmtImpl.qll | 13 - .../internal/LifetimeArgConstructor.qll | 14 + .../elements/internal/LifetimeArgImpl.qll | 16 + .../elements/internal/LifetimeConstructor.qll | 14 + .../rust/elements/internal/LifetimeImpl.qll | 16 + .../internal/LifetimeParamConstructor.qll | 14 + .../elements/internal/LifetimeParamImpl.qll | 16 + .../elements/internal/LiteralExprImpl.qll | 13 - .../rust/elements/internal/LiteralPatImpl.qll | 9 - .../rust/elements/internal/LoopExprImpl.qll | 24 - .../internal/MacroCallConstructor.qll | 14 + .../rust/elements/internal/MacroCallImpl.qll | 16 + .../elements/internal/MacroDefConstructor.qll | 14 + .../rust/elements/internal/MacroDefImpl.qll | 16 + .../internal/MacroExprConstructor.qll | 14 + .../rust/elements/internal/MacroExprImpl.qll | 16 + .../elements/internal/MacroPatConstructor.qll | 14 + .../rust/elements/internal/MacroPatImpl.qll | 16 + ...structor.qll => MacroRulesConstructor.qll} | 6 +- .../rust/elements/internal/MacroRulesImpl.qll | 16 + .../internal/MacroTypeConstructor.qll | 14 + .../rust/elements/internal/MacroTypeImpl.qll | 16 + .../rust/elements/internal/MatchArmImpl.qll | 15 - .../internal/MatchArmListConstructor.qll | 14 + .../elements/internal/MatchArmListImpl.qll | 16 + .../rust/elements/internal/MatchExprImpl.qll | 15 - .../internal/MatchGuardConstructor.qll | 14 + .../rust/elements/internal/MatchGuardImpl.qll | 16 + .../elements/internal/MetaConstructor.qll | 14 + .../rust/elements/internal/MetaImpl.qll | 16 + .../elements/internal/MethodCallExprImpl.qll | 7 - .../elements/internal/MissingConstructor.qll | 14 + .../elements/internal/MissingExprImpl.qll | 23 - .../rust/elements/internal/MissingPatImpl.qll | 24 - .../rust/elements/internal/ModuleImpl.qll | 11 - .../elements/internal/NameConstructor.qll | 14 + .../rust/elements/internal/NameImpl.qll | 16 + .../elements/internal/NameRefConstructor.qll | 14 + .../rust/elements/internal/NameRefImpl.qll | 16 + .../internal/NeverTypeConstructor.qll | 14 + .../rust/elements/internal/NeverTypeImpl.qll | 16 + .../elements/internal/OffsetOfExprImpl.qll | 6 - .../rust/elements/internal/OrPatImpl.qll | 8 - .../elements/internal/ParamConstructor.qll | 14 + .../rust/elements/internal/ParamImpl.qll | 16 + .../internal/ParamListConstructor.qll | 14 + .../rust/elements/internal/ParamListImpl.qll | 16 + .../internal/ParenExprConstructor.qll | 14 + .../rust/elements/internal/ParenExprImpl.qll | 16 + .../elements/internal/ParenPatConstructor.qll | 14 + .../rust/elements/internal/ParenPatImpl.qll | 16 + .../internal/ParenTypeConstructor.qll | 14 + .../rust/elements/internal/ParenTypeImpl.qll | 16 + .../codeql/rust/elements/internal/PatImpl.qll | 3 - .../rust/elements/internal/PathExprImpl.qll | 9 - .../rust/elements/internal/PathImpl.qll | 6 - .../rust/elements/internal/PathPatImpl.qll | 9 - .../internal/PathSegmentConstructor.qll | 14 + .../elements/internal/PathSegmentImpl.qll | 16 + .../elements/internal/PathTypeConstructor.qll | 14 + .../rust/elements/internal/PathTypeImpl.qll | 16 + .../rust/elements/internal/PrefixExprImpl.qll | 8 - .../elements/internal/PtrTypeConstructor.qll | 14 + .../rust/elements/internal/PtrTypeImpl.qll | 16 + .../rust/elements/internal/RangeExprImpl.qll | 11 - .../rust/elements/internal/RangePatImpl.qll | 10 - .../elements/internal/RecordExprFieldImpl.qll | 6 - .../RecordExprFieldListConstructor.qll | 14 + .../internal/RecordExprFieldListImpl.qll | 16 + .../rust/elements/internal/RecordExprImpl.qll | 9 - .../internal/RecordFieldConstructor.qll | 14 + .../elements/internal/RecordFieldImpl.qll | 16 + ...tor.qll => RecordFieldListConstructor.qll} | 6 +- .../elements/internal/RecordFieldListImpl.qll | 16 + .../elements/internal/RecordPatFieldImpl.qll | 6 - .../RecordPatFieldListConstructor.qll | 14 + .../internal/RecordPatFieldListImpl.qll | 16 + .../rust/elements/internal/RecordPatImpl.qll | 9 - .../rust/elements/internal/RefExprImpl.qll | 9 - .../rust/elements/internal/RefPatImpl.qll | 9 - .../elements/internal/RefTypeConstructor.qll | 14 + .../rust/elements/internal/RefTypeImpl.qll | 16 + .../elements/internal/RenameConstructor.qll | 14 + .../rust/elements/internal/RenameImpl.qll | 16 + .../elements/internal/RestPatConstructor.qll | 14 + .../rust/elements/internal/RestPatImpl.qll | 16 + .../elements/internal/RetTypeConstructor.qll | 14 + .../rust/elements/internal/RetTypeImpl.qll | 16 + .../rust/elements/internal/ReturnExprImpl.qll | 13 - .../internal/ReturnTypeSyntaxConstructor.qll | 14 + .../internal/ReturnTypeSyntaxImpl.qll | 16 + .../internal/SelfParamConstructor.qll | 14 + .../rust/elements/internal/SelfParamImpl.qll | 16 + .../rust/elements/internal/SlicePatImpl.qll | 10 - .../internal/SliceTypeConstructor.qll | 14 + .../rust/elements/internal/SliceTypeImpl.qll | 16 + .../internal/SourceFileConstructor.qll | 14 + .../rust/elements/internal/SourceFileImpl.qll | 16 + .../elements/internal/StaticConstructor.qll | 14 + .../rust/elements/internal/StaticImpl.qll | 16 + .../rust/elements/internal/StmtImpl.qll | 3 - .../elements/internal/StmtListConstructor.qll | 14 + .../rust/elements/internal/StmtListImpl.qll | 16 + .../elements/internal/StructConstructor.qll | 14 + .../rust/elements/internal/StructImpl.qll | 16 + .../internal/TokenTreeConstructor.qll | 14 + .../rust/elements/internal/TokenTreeImpl.qll | 16 + .../internal/TraitAliasConstructor.qll | 14 + .../rust/elements/internal/TraitAliasImpl.qll | 16 + .../elements/internal/TraitConstructor.qll | 14 + .../rust/elements/internal/TraitImpl.qll | 16 + .../elements/internal/TryExprConstructor.qll | 14 + .../rust/elements/internal/TryExprImpl.qll | 16 + .../rust/elements/internal/TupleExprImpl.qll | 7 - .../internal/TupleFieldConstructor.qll | 14 + .../rust/elements/internal/TupleFieldImpl.qll | 16 + .../internal/TupleFieldListConstructor.qll | 14 + .../elements/internal/TupleFieldListImpl.qll | 16 + .../rust/elements/internal/TuplePatImpl.qll | 7 - .../elements/internal/TupleStructPatImpl.qll | 10 - .../internal/TupleTypeConstructor.qll | 14 + .../rust/elements/internal/TupleTypeImpl.qll | 16 + .../internal/TypeAliasConstructor.qll | 14 + .../rust/elements/internal/TypeAliasImpl.qll | 16 + .../elements/internal/TypeArgConstructor.qll | 14 + .../rust/elements/internal/TypeArgImpl.qll | 16 + .../internal/TypeBoundConstructor.qll | 14 + .../rust/elements/internal/TypeBoundImpl.qll | 16 + .../internal/TypeBoundListConstructor.qll | 14 + .../elements/internal/TypeBoundListImpl.qll | 16 + .../internal/TypeParamConstructor.qll | 14 + .../rust/elements/internal/TypeParamImpl.qll | 16 + .../rust/elements/internal/TypeRefImpl.qll | 8 - .../elements/internal/UnderscoreExprImpl.qll | 6 - .../internal/UnimplementedConstructor.qll | 14 + .../UnimplementedDeclarationConstructor.qll | 14 - .../internal/UnimplementedDeclarationImpl.qll | 19 - .../elements/internal/UnionConstructor.qll | 14 + .../rust/elements/internal/UnionImpl.qll | 16 + .../elements/internal/UnsafeBlockExprImpl.qll | 25 - .../rust/elements/internal/UseConstructor.qll | 14 + .../codeql/rust/elements/internal/UseImpl.qll | 16 + .../elements/internal/UseTreeConstructor.qll | 14 + .../rust/elements/internal/UseTreeImpl.qll | 16 + .../internal/UseTreeListConstructor.qll | 14 + .../elements/internal/UseTreeListImpl.qll | 16 + .../elements/internal/VariantConstructor.qll | 14 + .../rust/elements/internal/VariantImpl.qll | 16 + .../internal/VariantListConstructor.qll | 14 + .../elements/internal/VariantListImpl.qll | 16 + .../internal/VisibilityConstructor.qll | 14 + .../rust/elements/internal/VisibilityImpl.qll | 16 + .../internal/WhereClauseConstructor.qll | 14 + .../elements/internal/WhereClauseImpl.qll | 16 + .../internal/WherePredConstructor.qll | 14 + .../rust/elements/internal/WherePredImpl.qll | 16 + .../internal/WhileExprConstructor.qll | 14 + .../rust/elements/internal/WhileExprImpl.qll | 16 + .../elements/internal/WildcardPatImpl.qll | 6 - .../rust/elements/internal/YeetExprImpl.qll | 8 - .../rust/elements/internal/YieldExprImpl.qll | 9 - .../rust/elements/internal/generated/Abi.qll | 33 + .../elements/internal/generated/ArgList.qll | 42 + .../elements/internal/generated/ArrayExpr.qll | 47 +- .../elements/internal/generated/ArrayType.qll | 53 + .../elements/internal/generated/AsmExpr.qll | 32 +- .../{Declaration.qll => AssocItem.qll} | 11 +- .../internal/generated/AssocItemList.qll | 65 + .../internal/generated/AssocTypeArg.qll | 151 + .../internal/generated/AsyncBlockExpr.qll | 30 - .../rust/elements/internal/generated/Attr.qll | 36 + .../elements/internal/generated/AwaitExpr.qll | 33 +- .../internal/generated/BecomeExpr.qll | 38 +- .../internal/generated/BinaryExpr.qll | 59 +- .../elements/internal/generated/BlockExpr.qll | 51 +- .../internal/generated/BlockExprBase.qll | 58 - .../elements/internal/generated/BoxExpr.qll | 35 - .../elements/internal/generated/BoxPat.qll | 18 +- .../elements/internal/generated/BreakExpr.qll | 48 +- .../elements/internal/generated/CallExpr.qll | 46 +- .../elements/internal/generated/CastExpr.qll | 41 +- .../internal/generated/ClosureBinder.qll | 39 + .../internal/generated/ClosureExpr.qll | 87 +- .../elements/internal/generated/Const.qll | 95 + .../elements/internal/generated/ConstArg.qll | 37 + .../internal/generated/ConstBlockPat.qll | 22 +- .../elements/internal/generated/ConstExpr.qll | 38 - .../internal/generated/ConstParam.qll | 88 + .../internal/generated/ContinueExpr.qll | 50 +- .../internal/generated/DynTraitType.qll | 39 + .../internal/generated/ElementListExpr.qll | 56 - .../rust/elements/internal/generated/Enum.qll | 112 + .../rust/elements/internal/generated/Expr.qll | 1 - .../elements/internal/generated/ExprStmt.qll | 12 +- .../internal/generated/ExternBlock.qll | 74 + .../internal/generated/ExternCrate.qll | 92 + .../internal/generated/ExternItem.qll | 21 + .../internal/generated/ExternItemList.qll | 65 + .../elements/internal/generated/FieldExpr.qll | 45 +- .../elements/internal/generated/FieldList.qll | 21 + .../elements/internal/generated/FnPtrType.qll | 69 + .../elements/internal/generated/ForExpr.qll | 97 + .../elements/internal/generated/ForType.qll | 52 + .../internal/generated/FormatArgsArg.qll | 55 + .../internal/generated/FormatArgsExpr.qll | 81 + .../elements/internal/generated/Function.qll | 154 +- .../internal/generated/GenericArg.qll | 21 + .../internal/generated/GenericArgList.qll | 30 +- .../internal/generated/GenericParam.qll | 21 + .../internal/generated/GenericParamList.qll | 44 + .../elements/internal/generated/IdentPat.qll | 54 +- .../elements/internal/generated/IfExpr.qll | 54 +- .../rust/elements/internal/generated/Impl.qll | 126 + .../internal/generated/ImplTraitType.qll | 39 + .../elements/internal/generated/IndexExpr.qll | 39 +- .../elements/internal/generated/InferType.qll | 23 + .../rust/elements/internal/generated/Item.qll | 21 + .../elements/internal/generated/ItemList.qll | 61 + .../elements/internal/generated/ItemStmt.qll | 30 - .../elements/internal/generated/Label.qll | 20 +- .../elements/internal/generated/LetElse.qll | 39 + .../elements/internal/generated/LetExpr.qll | 43 +- .../elements/internal/generated/LetStmt.qll | 66 +- .../elements/internal/generated/Lifetime.qll | 33 + .../internal/generated/LifetimeArg.qll | 39 + .../internal/generated/LifetimeParam.qll | 76 + .../internal/generated/LiteralExpr.qll | 44 +- .../internal/generated/LiteralPat.qll | 22 +- .../elements/internal/generated/LoopExpr.qll | 56 +- .../elements/internal/generated/MacroCall.qll | 76 + .../elements/internal/generated/MacroDef.qll | 99 + .../elements/internal/generated/MacroExpr.qll | 39 + .../elements/internal/generated/MacroPat.qll | 39 + .../internal/generated/MacroRules.qll | 90 + .../elements/internal/generated/MacroType.qll | 39 + .../elements/internal/generated/MatchArm.qll | 61 +- .../internal/generated/MatchArmList.qll | 65 + .../elements/internal/generated/MatchExpr.qll | 58 +- .../internal/generated/MatchGuard.qll | 39 + .../rust/elements/internal/generated/Meta.qll | 63 + .../internal/generated/MethodCallExpr.qll | 78 +- .../elements/internal/generated/Missing.qll | 4 +- .../internal/generated/MissingExpr.qll | 29 - .../internal/generated/MissingPat.qll | 30 - .../elements/internal/generated/Module.qll | 74 +- .../rust/elements/internal/generated/Name.qll | 33 + .../elements/internal/generated/NameRef.qll | 33 + .../elements/internal/generated/NeverType.qll | 23 + .../internal/generated/OffsetOfExpr.qll | 48 +- .../elements/internal/generated/OrPat.qll | 20 +- .../elements/internal/generated/Param.qll | 67 + .../elements/internal/generated/ParamList.qll | 60 + .../elements/internal/generated/ParenExpr.qll | 56 + .../elements/internal/generated/ParenPat.qll | 36 + .../elements/internal/generated/ParenType.qll | 37 + .../internal/generated/ParentChild.qll | 3307 +++++-- .../rust/elements/internal/generated/Pat.qll | 1 - .../rust/elements/internal/generated/Path.qll | 33 +- .../elements/internal/generated/PathExpr.qll | 33 +- .../elements/internal/generated/PathPat.qll | 14 +- .../internal/generated/PathSegment.qll | 133 + .../elements/internal/generated/PathType.qll | 37 + .../internal/generated/PrefixExpr.qll | 45 +- .../elements/internal/generated/PtrType.qll | 36 + .../elements/internal/generated/RangeExpr.qll | 59 +- .../elements/internal/generated/RangePat.qll | 42 +- .../rust/elements/internal/generated/Raw.qll | 3085 ++++-- .../internal/generated/RecordExpr.qll | 52 +- .../internal/generated/RecordExprField.qll | 47 +- .../generated/RecordExprFieldList.qll | 81 + .../internal/generated/RecordField.qll | 88 + .../internal/generated/RecordFieldList.qll | 44 + .../elements/internal/generated/RecordPat.qll | 31 +- .../internal/generated/RecordPatField.qll | 47 +- .../internal/generated/RecordPatFieldList.qll | 60 + .../elements/internal/generated/RefExpr.qll | 35 +- .../elements/internal/generated/RefPat.qll | 13 +- .../elements/internal/generated/RefType.qll | 50 + .../elements/internal/generated/Rename.qll | 36 + .../internal/generated/RepeatExpr.qll | 46 - .../elements/internal/generated/RestPat.qll | 42 + .../elements/internal/generated/RetType.qll | 36 + .../internal/generated/ReturnExpr.qll | 32 +- .../internal/generated/ReturnTypeSyntax.qll | 23 + .../elements/internal/generated/SelfParam.qll | 86 + .../elements/internal/generated/SlicePat.qll | 53 +- .../elements/internal/generated/SliceType.qll | 37 + .../internal/generated/SourceFile.qll | 65 + .../elements/internal/generated/Static.qll | 98 + .../rust/elements/internal/generated/Stmt.qll | 1 - .../elements/internal/generated/StmtList.qll | 77 + .../elements/internal/generated/Struct.qll | 117 + .../elements/internal/generated/Synth.qll | 2763 +++++- .../internal/generated/SynthConstructors.qll | 100 +- .../elements/internal/generated/TokenTree.qll | 23 + .../elements/internal/generated/Trait.qll | 132 + .../internal/generated/TraitAlias.qll | 122 + .../elements/internal/generated/TryExpr.qll | 55 + .../elements/internal/generated/TupleExpr.qll | 39 +- .../internal/generated/TupleField.qll | 74 + .../internal/generated/TupleFieldList.qll | 44 + .../elements/internal/generated/TuplePat.qll | 31 +- .../internal/generated/TupleStructPat.qll | 50 +- .../elements/internal/generated/TupleType.qll | 44 + .../elements/internal/generated/TypeAlias.qll | 138 + .../elements/internal/generated/TypeArg.qll | 36 + .../elements/internal/generated/TypeBound.qll | 69 + .../internal/generated/TypeBoundList.qll | 44 + .../elements/internal/generated/TypeParam.qll | 88 + .../elements/internal/generated/TypeRef.qll | 11 +- .../internal/generated/UnderscoreExpr.qll | 25 +- .../internal/generated/Unimplemented.qll | 4 +- .../generated/UnimplementedDeclaration.qll | 27 - .../elements/internal/generated/Union.qll | 116 + .../internal/generated/UnsafeBlockExpr.qll | 30 - .../rust/elements/internal/generated/Use.qll | 68 + .../elements/internal/generated/UseTree.qll | 66 + .../internal/generated/UseTreeList.qll | 44 + .../elements/internal/generated/Variant.qll | 100 + .../internal/generated/VariantList.qll | 44 + .../internal/generated/Visibility.qll | 37 + .../internal/generated/WhereClause.qll | 44 + .../elements/internal/generated/WherePred.qll | 85 + .../elements/internal/generated/WhileExpr.qll | 86 + .../internal/generated/WildcardPat.qll | 4 - .../elements/internal/generated/YeetExpr.qll | 25 +- .../elements/internal/generated/YieldExpr.qll | 26 +- rust/ql/lib/rust.dbscheme | 2983 +++++- .../generated/.generated_tests.list | 61 - .../extractor-tests/generated/.gitattributes | 61 - .../generated/Abi/MISSING_SOURCE.txt | 4 + .../generated/ArgList/MISSING_SOURCE.txt | 4 + .../generated/ArrayExpr/MISSING_SOURCE.txt | 4 + .../generated/ArrayType/MISSING_SOURCE.txt | 4 + .../generated/AsmExpr/AsmExpr.expected | 1 - .../generated/AsmExpr/AsmExpr.ql | 10 - .../generated/AsmExpr/MISSING_SOURCE.txt | 4 + .../generated/AsmExpr/gen_asm_expr.rs | 8 - .../AssocItemList/MISSING_SOURCE.txt | 4 + .../generated/AssocTypeArg/MISSING_SOURCE.txt | 4 + .../AsyncBlockExpr/AsyncBlockExpr.expected | 1 - .../AsyncBlockExpr/AsyncBlockExpr.ql | 11 - .../AsyncBlockExpr_getStatement.expected | 1 - .../AsyncBlockExpr_getStatement.ql | 7 - .../AsyncBlockExpr_getTail.expected | 1 - .../AsyncBlockExpr/AsyncBlockExpr_getTail.ql | 7 - .../AsyncBlockExpr/gen_async_block_expr.rs | 9 - .../generated/Attr/MISSING_SOURCE.txt | 4 + .../generated/AwaitExpr/AwaitExpr.expected | 1 - .../generated/AwaitExpr/AwaitExpr.ql | 10 - .../generated/AwaitExpr/MISSING_SOURCE.txt | 4 + .../generated/AwaitExpr/gen_await_expr.rs | 9 - .../generated/BecomeExpr/BecomeExpr.expected | 1 - .../generated/BecomeExpr/BecomeExpr.ql | 10 - .../generated/BecomeExpr/MISSING_SOURCE.txt | 4 + .../generated/BecomeExpr/gen_become_expr.rs | 10 - .../generated/BinaryExpr/BinaryExpr.expected | 5 - .../generated/BinaryExpr/BinaryExpr.ql | 12 - .../BinaryExpr/BinaryExpr_getOp.expected | 5 - .../generated/BinaryExpr/BinaryExpr_getOp.ql | 7 - .../generated/BinaryExpr/MISSING_SOURCE.txt | 4 + .../generated/BinaryExpr/gen_binary_expr.rs | 10 - .../generated/BlockExpr/BlockExpr.expected | 3 - .../generated/BlockExpr/BlockExpr.ql | 13 - .../BlockExpr/BlockExpr_getLabel.expected | 1 - .../generated/BlockExpr/BlockExpr_getLabel.ql | 7 - .../BlockExpr/BlockExpr_getStatement.expected | 3 - .../BlockExpr/BlockExpr_getStatement.ql | 7 - .../BlockExpr/BlockExpr_getTail.expected | 2 - .../generated/BlockExpr/BlockExpr_getTail.ql | 7 - .../generated/BlockExpr/MISSING_SOURCE.txt | 4 + .../generated/BlockExpr/gen_block_expr.rs | 12 - .../generated/BoxExpr/BoxExpr.expected | 1 - .../generated/BoxExpr/BoxExpr.ql | 10 - .../generated/BoxExpr/gen_box_expr.rs | 6 - .../generated/BoxPat/BoxPat.expected | 2 - .../generated/BoxPat/BoxPat.ql | 10 - .../generated/BoxPat/MISSING_SOURCE.txt | 4 + .../generated/BoxPat/gen_box_pat.rs | 9 - .../generated/BreakExpr/BreakExpr.expected | 2 - .../generated/BreakExpr/BreakExpr.ql | 11 - .../BreakExpr/BreakExpr_getExpr.expected | 1 - .../generated/BreakExpr/BreakExpr_getExpr.ql | 7 - .../BreakExpr/BreakExpr_getLabel.expected | 1 - .../generated/BreakExpr/BreakExpr_getLabel.ql | 7 - .../generated/BreakExpr/MISSING_SOURCE.txt | 4 + .../generated/BreakExpr/gen_break_expr.rs | 15 - .../generated/CallExpr/CallExpr.expected | 4 - .../generated/CallExpr/CallExpr.ql | 13 - .../CallExpr/CallExpr_getArg.expected | 4 - .../generated/CallExpr/CallExpr_getArg.ql | 7 - .../generated/CallExpr/MISSING_SOURCE.txt | 4 + .../generated/CallExpr/gen_call_expr.rs | 9 - .../generated/CastExpr/CastExpr.expected | 1 - .../generated/CastExpr/CastExpr.ql | 11 - .../generated/CastExpr/MISSING_SOURCE.txt | 4 + .../generated/CastExpr/gen_cast_expr.rs | 6 - .../ClosureBinder/MISSING_SOURCE.txt | 4 + .../ClosureExpr/ClosureExpr.expected | 5 - .../generated/ClosureExpr/ClosureExpr.ql | 17 - .../ClosureExpr/ClosureExpr_getArg.expected | 6 - .../ClosureExpr/ClosureExpr_getArg.ql | 7 - .../ClosureExpr_getArgType.expected | 2 - .../ClosureExpr/ClosureExpr_getArgType.ql | 7 - .../ClosureExpr_getRetType.expected | 1 - .../ClosureExpr/ClosureExpr_getRetType.ql | 7 - .../generated/ClosureExpr/MISSING_SOURCE.txt | 4 + .../generated/ClosureExpr/gen_closure_expr.rs | 12 - .../generated/Const/MISSING_SOURCE.txt | 4 + .../generated/ConstArg/MISSING_SOURCE.txt | 4 + .../ConstBlockPat/ConstBlockPat.expected | 1 - .../generated/ConstBlockPat/ConstBlockPat.ql | 10 - .../ConstBlockPat/MISSING_SOURCE.txt | 4 + .../ConstBlockPat/gen_const_block_pat.rs | 9 - .../generated/ConstExpr/ConstExpr.expected | 1 - .../generated/ConstExpr/ConstExpr.ql | 10 - .../generated/ConstExpr/gen_const_expr.rs | 8 - .../generated/ConstParam/MISSING_SOURCE.txt | 4 + .../ContinueExpr/ContinueExpr.expected | 2 - .../generated/ContinueExpr/ContinueExpr.ql | 10 - .../ContinueExpr_getLabel.expected | 1 - .../ContinueExpr/ContinueExpr_getLabel.ql | 7 - .../generated/ContinueExpr/MISSING_SOURCE.txt | 4 + .../ContinueExpr/gen_continue_expr.rs | 15 - .../generated/DynTraitType/MISSING_SOURCE.txt | 4 + .../ElementListExpr/ElementListExpr.expected | 2 - .../ElementListExpr/ElementListExpr.ql | 11 - .../ElementListExpr_getElement.expected | 10 - .../ElementListExpr_getElement.ql | 7 - .../ElementListExpr/gen_element_list_expr.rs | 7 - .../generated/Enum/MISSING_SOURCE.txt | 4 + .../generated/ExprStmt/ExprStmt.expected | 2 - .../generated/ExprStmt/ExprStmt.ql | 11 - .../generated/ExprStmt/MISSING_SOURCE.txt | 4 + .../generated/ExprStmt/gen_expr_stmt.rs | 8 - .../generated/ExternBlock/MISSING_SOURCE.txt | 4 + .../generated/ExternCrate/MISSING_SOURCE.txt | 4 + .../ExternItemList/MISSING_SOURCE.txt | 4 + .../generated/FieldExpr/FieldExpr.expected | 1 - .../generated/FieldExpr/FieldExpr.ql | 11 - .../generated/FieldExpr/MISSING_SOURCE.txt | 4 + .../generated/FieldExpr/gen_field_expr.rs | 6 - .../generated/FnPtrType/MISSING_SOURCE.txt | 4 + .../generated/ForExpr/MISSING_SOURCE.txt | 4 + .../generated/ForType/MISSING_SOURCE.txt | 4 + .../FormatArgsArg/MISSING_SOURCE.txt | 4 + .../FormatArgsExpr/MISSING_SOURCE.txt | 4 + .../generated/Function/Function.expected | 1 - .../generated/Function/Function.ql | 11 - .../generated/Function/MISSING_SOURCE.txt | 4 + .../generated/Function/gen_function.rs | 8 - .../GenericArgList/GenericArgList.expected | 1 - .../GenericArgList/GenericArgList.ql | 7 - .../GenericArgList/MISSING_SOURCE.txt | 4 + .../GenericArgList/gen_generic_arg_list.rs | 6 - .../GenericParamList/MISSING_SOURCE.txt | 4 + .../generated/IdentPat/IdentPat.expected | 2 - .../generated/IdentPat/IdentPat.ql | 11 - .../IdentPat/IdentPat_getSubpat.expected | 1 - .../generated/IdentPat/IdentPat_getSubpat.ql | 7 - .../generated/IdentPat/MISSING_SOURCE.txt | 4 + .../generated/IdentPat/gen_ident_pat.rs | 13 - .../generated/IfExpr/IfExpr.expected | 2 - .../generated/IfExpr/IfExpr.ql | 12 - .../generated/IfExpr/IfExpr_getElse.expected | 1 - .../generated/IfExpr/IfExpr_getElse.ql | 7 - .../generated/IfExpr/MISSING_SOURCE.txt | 4 + .../generated/IfExpr/gen_if_expr.rs | 13 - .../generated/Impl/MISSING_SOURCE.txt | 4 + .../ImplTraitType/MISSING_SOURCE.txt | 4 + .../generated/IndexExpr/IndexExpr.expected | 2 - .../generated/IndexExpr/IndexExpr.ql | 12 - .../generated/IndexExpr/MISSING_SOURCE.txt | 4 + .../generated/IndexExpr/gen_index_expr.rs | 7 - .../generated/InferType/MISSING_SOURCE.txt | 4 + .../generated/ItemList/MISSING_SOURCE.txt | 4 + .../generated/Label/Label.expected | 2 - .../extractor-tests/generated/Label/Label.ql | 10 - .../generated/Label/MISSING_SOURCE.txt | 4 + .../generated/Label/gen_label.rs | 9 - .../generated/LetElse/MISSING_SOURCE.txt | 4 + .../generated/LetExpr/LetExpr.expected | 1 - .../generated/LetExpr/LetExpr.ql | 11 - .../generated/LetExpr/MISSING_SOURCE.txt | 4 + .../generated/LetExpr/gen_let_expr.rs | 8 - .../generated/LetStmt/LetStmt.expected | 6 - .../generated/LetStmt/LetStmt.ql | 14 - .../LetStmt/LetStmt_getElse.expected | 1 - .../generated/LetStmt/LetStmt_getElse.ql | 7 - .../LetStmt/LetStmt_getInitializer.expected | 4 - .../LetStmt/LetStmt_getInitializer.ql | 7 - .../LetStmt/LetStmt_getType.expected | 2 - .../generated/LetStmt/LetStmt_getType.ql | 7 - .../generated/LetStmt/MISSING_SOURCE.txt | 4 + .../generated/LetStmt/gen_let_stmt.rs | 13 - .../generated/Lifetime/MISSING_SOURCE.txt | 4 + .../generated/LifetimeArg/MISSING_SOURCE.txt | 4 + .../LifetimeParam/MISSING_SOURCE.txt | 4 + .../LiteralExpr/LiteralExpr.expected | 8 - .../generated/LiteralExpr/LiteralExpr.ql | 7 - .../generated/LiteralExpr/MISSING_SOURCE.txt | 4 + .../generated/LiteralExpr/gen_literal_expr.rs | 13 - .../generated/LiteralPat/LiteralPat.expected | 1 - .../generated/LiteralPat/LiteralPat.ql | 10 - .../generated/LiteralPat/MISSING_SOURCE.txt | 4 + .../generated/LiteralPat/gen_literal_pat.rs | 9 - .../generated/LoopExpr/LoopExpr.expected | 3 - .../generated/LoopExpr/LoopExpr.ql | 11 - .../LoopExpr/LoopExpr_getLabel.expected | 1 - .../generated/LoopExpr/LoopExpr_getLabel.ql | 7 - .../generated/LoopExpr/MISSING_SOURCE.txt | 4 + .../generated/LoopExpr/gen_loop_expr.rs | 20 - .../generated/MacroCall/MISSING_SOURCE.txt | 4 + .../generated/MacroDef/MISSING_SOURCE.txt | 4 + .../generated/MacroExpr/MISSING_SOURCE.txt | 4 + .../generated/MacroPat/MISSING_SOURCE.txt | 4 + .../generated/MacroRules/MISSING_SOURCE.txt | 4 + .../generated/MacroType/MISSING_SOURCE.txt | 4 + .../generated/MatchArm/MISSING_SOURCE.txt | 4 + .../generated/MatchArm/MatchArm.expected | 4 - .../generated/MatchArm/MatchArm.ql | 12 - .../MatchArm/MatchArm_getGuard.expected | 1 - .../generated/MatchArm/MatchArm_getGuard.ql | 7 - .../generated/MatchArm/gen_match_arm.rs | 13 - .../generated/MatchArmList/MISSING_SOURCE.txt | 4 + .../generated/MatchExpr/MISSING_SOURCE.txt | 4 + .../generated/MatchExpr/MatchExpr.expected | 2 - .../generated/MatchExpr/MatchExpr.ql | 11 - .../MatchExpr/MatchExpr_getBranch.expected | 4 - .../MatchExpr/MatchExpr_getBranch.ql | 7 - .../generated/MatchExpr/gen_match_expr.rs | 13 - .../generated/MatchGuard/MISSING_SOURCE.txt | 4 + .../generated/Meta/MISSING_SOURCE.txt | 4 + .../MethodCallExpr/MISSING_SOURCE.txt | 4 + .../MethodCallExpr/MethodCallExpr.expected | 2 - .../MethodCallExpr/MethodCallExpr.ql | 16 - .../MethodCallExpr_getArg.expected | 2 - .../MethodCallExpr/MethodCallExpr_getArg.ql | 7 - .../MethodCallExpr_getGenericArgs.expected | 1 - .../MethodCallExpr_getGenericArgs.ql | 7 - .../MethodCallExpr/gen_method_call_expr.rs | 7 - .../MissingExpr/MissingExpr.expected | 1 - .../generated/MissingExpr/MissingExpr.ql | 7 - .../generated/MissingExpr/gen_missing_expr.rs | 7 - .../generated/MissingPat/MissingPat.expected | 1 - .../generated/MissingPat/MissingPat.ql | 7 - .../generated/MissingPat/gen_missing_pat.rs | 8 - .../generated/Module/MISSING_SOURCE.txt | 4 + .../generated/Module/Module.expected | 7 - .../generated/Module/Module.ql | 10 - .../Module/Module_getDeclaration.expected | 7 - .../generated/Module/Module_getDeclaration.ql | 7 - .../generated/Module/gen_module.rs | 7 - .../generated/Name/MISSING_SOURCE.txt | 4 + .../generated/NameRef/MISSING_SOURCE.txt | 4 + .../generated/NeverType/MISSING_SOURCE.txt | 4 + .../generated/OffsetOfExpr/MISSING_SOURCE.txt | 4 + .../OffsetOfExpr/OffsetOfExpr.expected | 1 - .../generated/OffsetOfExpr/OffsetOfExpr.ql | 11 - .../OffsetOfExpr_getField.expected | 1 - .../OffsetOfExpr/OffsetOfExpr_getField.ql | 7 - .../OffsetOfExpr/gen_offset_of_expr.rs | 6 - .../generated/OrPat/MISSING_SOURCE.txt | 4 + .../generated/OrPat/OrPat.expected | 1 - .../extractor-tests/generated/OrPat/OrPat.ql | 10 - .../generated/OrPat/OrPat_getArg.expected | 2 - .../generated/OrPat/OrPat_getArg.ql | 7 - .../generated/OrPat/gen_or_pat.rs | 8 - .../generated/Param/MISSING_SOURCE.txt | 4 + .../generated/ParamList/MISSING_SOURCE.txt | 4 + .../generated/ParenExpr/MISSING_SOURCE.txt | 4 + .../generated/ParenPat/MISSING_SOURCE.txt | 4 + .../generated/ParenType/MISSING_SOURCE.txt | 4 + .../generated/Path/MISSING_SOURCE.txt | 4 + .../generated/Path/Path.expected | 1 - .../extractor-tests/generated/Path/Path.ql | 7 - .../generated/Path/gen_path.rs | 6 - .../generated/PathExpr/MISSING_SOURCE.txt | 4 + .../generated/PathExpr/PathExpr.expected | 4 - .../generated/PathExpr/PathExpr.ql | 10 - .../generated/PathExpr/gen_path_expr.rs | 9 - .../generated/PathPat/MISSING_SOURCE.txt | 4 + .../generated/PathPat/PathPat.expected | 1 - .../generated/PathPat/PathPat.ql | 10 - .../generated/PathPat/gen_path_pat.rs | 9 - .../generated/PathSegment/MISSING_SOURCE.txt | 4 + .../generated/PathType/MISSING_SOURCE.txt | 4 + .../generated/PrefixExpr/MISSING_SOURCE.txt | 4 + .../generated/PrefixExpr/PrefixExpr.expected | 3 - .../generated/PrefixExpr/PrefixExpr.ql | 11 - .../generated/PrefixExpr/gen_prefix_expr.rs | 8 - .../generated/PtrType/MISSING_SOURCE.txt | 4 + .../generated/RangeExpr/MISSING_SOURCE.txt | 4 + .../generated/RangeExpr/RangeExpr.expected | 6 - .../generated/RangeExpr/RangeExpr.ql | 12 - .../RangeExpr/RangeExpr_getLhs.expected | 3 - .../generated/RangeExpr/RangeExpr_getLhs.ql | 7 - .../RangeExpr/RangeExpr_getRhs.expected | 4 - .../generated/RangeExpr/RangeExpr_getRhs.ql | 7 - .../generated/RangeExpr/gen_range_expr.rs | 11 - .../generated/RangePat/MISSING_SOURCE.txt | 4 + .../generated/RangePat/RangePat.expected | 3 - .../generated/RangePat/RangePat.ql | 11 - .../RangePat/RangePat_getEnd.expected | 2 - .../generated/RangePat/RangePat_getEnd.ql | 7 - .../RangePat/RangePat_getStart.expected | 2 - .../generated/RangePat/RangePat_getStart.ql | 7 - .../generated/RangePat/gen_range_pat.rs | 10 - .../generated/RecordExpr/MISSING_SOURCE.txt | 4 + .../generated/RecordExpr/RecordExpr.expected | 4 - .../generated/RecordExpr/RecordExpr.ql | 17 - .../RecordExpr/RecordExpr_getFld.expected | 5 - .../generated/RecordExpr/RecordExpr_getFld.ql | 7 - .../RecordExpr/RecordExpr_getPath.expected | 4 - .../RecordExpr/RecordExpr_getPath.ql | 7 - .../RecordExpr/RecordExpr_getSpread.expected | 1 - .../RecordExpr/RecordExpr_getSpread.ql | 7 - .../generated/RecordExpr/gen_record_expr.rs | 9 - .../RecordExprField/MISSING_SOURCE.txt | 4 + .../RecordExprField/RecordExprField.expected | 2 - .../RecordExprField/RecordExprField.ql | 11 - .../RecordExprField/gen_record_expr_field.rs | 6 - .../RecordExprFieldList/MISSING_SOURCE.txt | 4 + .../generated/RecordField/MISSING_SOURCE.txt | 4 + .../RecordFieldList/MISSING_SOURCE.txt | 4 + .../generated/RecordPat/MISSING_SOURCE.txt | 4 + .../generated/RecordPat/RecordPat.expected | 2 - .../generated/RecordPat/RecordPat.ql | 12 - .../RecordPat/RecordPat_getFld.expected | 2 - .../generated/RecordPat/RecordPat_getFld.ql | 7 - .../RecordPat/RecordPat_getPath.expected | 2 - .../generated/RecordPat/RecordPat_getPath.ql | 7 - .../generated/RecordPat/gen_record_pat.rs | 9 - .../RecordPatField/MISSING_SOURCE.txt | 4 + .../RecordPatField/RecordPatField.expected | 2 - .../RecordPatField/RecordPatField.ql | 11 - .../RecordPatField/gen_record_pat_field.rs | 6 - .../RecordPatFieldList/MISSING_SOURCE.txt | 4 + .../generated/RefExpr/MISSING_SOURCE.txt | 4 + .../generated/RefExpr/RefExpr.expected | 4 - .../generated/RefExpr/RefExpr.ql | 12 - .../generated/RefExpr/gen_ref_expr.rs | 9 - .../generated/RefPat/MISSING_SOURCE.txt | 4 + .../generated/RefPat/RefPat.expected | 2 - .../generated/RefPat/RefPat.ql | 11 - .../generated/RefPat/gen_ref_pat.rs | 9 - .../generated/RefType/MISSING_SOURCE.txt | 4 + .../generated/Rename/MISSING_SOURCE.txt | 4 + .../generated/RepeatExpr/RepeatExpr.expected | 1 - .../generated/RepeatExpr/RepeatExpr.ql | 11 - .../generated/RepeatExpr/gen_repeat_expr.rs | 6 - .../generated/RestPat/MISSING_SOURCE.txt | 4 + .../generated/RetType/MISSING_SOURCE.txt | 4 + .../generated/ReturnExpr/MISSING_SOURCE.txt | 4 + .../generated/ReturnExpr/ReturnExpr.expected | 2 - .../generated/ReturnExpr/ReturnExpr.ql | 10 - .../ReturnExpr/ReturnExpr_getExpr.expected | 1 - .../ReturnExpr/ReturnExpr_getExpr.ql | 7 - .../generated/ReturnExpr/gen_return_expr.rs | 9 - .../ReturnTypeSyntax/MISSING_SOURCE.txt | 4 + .../generated/SelfParam/MISSING_SOURCE.txt | 4 + .../generated/SlicePat/MISSING_SOURCE.txt | 4 + .../generated/SlicePat/SlicePat.expected | 3 - .../generated/SlicePat/SlicePat.ql | 13 - .../SlicePat/SlicePat_getPrefix.expected | 9 - .../generated/SlicePat/SlicePat_getPrefix.ql | 7 - .../SlicePat/SlicePat_getSlice.expected | 2 - .../generated/SlicePat/SlicePat_getSlice.ql | 7 - .../SlicePat/SlicePat_getSuffix.expected | 2 - .../generated/SlicePat/SlicePat_getSuffix.ql | 7 - .../generated/SlicePat/gen_slice_pat.rs | 10 - .../generated/SliceType/MISSING_SOURCE.txt | 4 + .../generated/SourceFile/MISSING_SOURCE.txt | 4 + .../generated/Static/MISSING_SOURCE.txt | 4 + .../generated/StmtList/MISSING_SOURCE.txt | 4 + .../generated/Struct/MISSING_SOURCE.txt | 4 + .../generated/TokenTree/MISSING_SOURCE.txt | 4 + .../generated/Trait/MISSING_SOURCE.txt | 4 + .../generated/TraitAlias/MISSING_SOURCE.txt | 4 + .../generated/TryExpr/MISSING_SOURCE.txt | 4 + .../generated/TupleExpr/MISSING_SOURCE.txt | 4 + .../generated/TupleExpr/TupleExpr.expected | 2 - .../generated/TupleExpr/TupleExpr.ql | 11 - .../TupleExpr/TupleExpr_getExpr.expected | 4 - .../generated/TupleExpr/TupleExpr_getExpr.ql | 7 - .../generated/TupleExpr/gen_tuple_expr.rs | 7 - .../generated/TupleField/MISSING_SOURCE.txt | 4 + .../TupleFieldList/MISSING_SOURCE.txt | 4 + .../generated/TuplePat/MISSING_SOURCE.txt | 4 + .../generated/TuplePat/TuplePat.expected | 2 - .../generated/TuplePat/TuplePat.ql | 11 - .../TuplePat/TuplePat_getArg.expected | 5 - .../generated/TuplePat/TuplePat_getArg.ql | 7 - .../TuplePat_getEllipsisIndex.expected | 1 - .../TuplePat/TuplePat_getEllipsisIndex.ql | 7 - .../generated/TuplePat/gen_tuple_pat.rs | 7 - .../TupleStructPat/MISSING_SOURCE.txt | 4 + .../TupleStructPat/TupleStructPat.expected | 3 - .../TupleStructPat/TupleStructPat.ql | 13 - .../TupleStructPat_getArg.expected | 5 - .../TupleStructPat/TupleStructPat_getArg.ql | 7 - .../TupleStructPat_getEllipsisIndex.expected | 2 - .../TupleStructPat_getEllipsisIndex.ql | 7 - .../TupleStructPat_getPath.expected | 3 - .../TupleStructPat/TupleStructPat_getPath.ql | 7 - .../TupleStructPat/gen_tuple_struct_pat.rs | 10 - .../generated/TupleType/MISSING_SOURCE.txt | 4 + .../generated/TypeAlias/MISSING_SOURCE.txt | 4 + .../generated/TypeArg/MISSING_SOURCE.txt | 4 + .../generated/TypeBound/MISSING_SOURCE.txt | 4 + .../TypeBoundList/MISSING_SOURCE.txt | 4 + .../generated/TypeParam/MISSING_SOURCE.txt | 4 + .../generated/TypeRef/TypeRef.expected | 3 - .../generated/TypeRef/TypeRef.ql | 7 - .../generated/TypeRef/gen_type_ref.rs | 8 - .../UnderscoreExpr/MISSING_SOURCE.txt | 4 + .../UnderscoreExpr/UnderscoreExpr.expected | 1 - .../UnderscoreExpr/UnderscoreExpr.ql | 7 - .../UnderscoreExpr/gen_underscore_expr.rs | 6 - .../generated/Union/MISSING_SOURCE.txt | 4 + .../UnsafeBlockExpr/UnsafeBlockExpr.expected | 1 - .../UnsafeBlockExpr/UnsafeBlockExpr.ql | 11 - .../UnsafeBlockExpr_getStatement.expected | 1 - .../UnsafeBlockExpr_getStatement.ql | 7 - .../UnsafeBlockExpr_getTail.expected | 1 - .../UnsafeBlockExpr_getTail.ql | 7 - .../UnsafeBlockExpr/gen_unsafe_block_expr.rs | 9 - .../generated/Use/MISSING_SOURCE.txt | 4 + .../generated/UseTree/MISSING_SOURCE.txt | 4 + .../generated/UseTreeList/MISSING_SOURCE.txt | 4 + .../generated/Variant/MISSING_SOURCE.txt | 4 + .../generated/VariantList/MISSING_SOURCE.txt | 4 + .../generated/Visibility/MISSING_SOURCE.txt | 4 + .../generated/WhereClause/MISSING_SOURCE.txt | 4 + .../generated/WherePred/MISSING_SOURCE.txt | 4 + .../generated/WhileExpr/MISSING_SOURCE.txt | 4 + .../generated/WildcardPat/MISSING_SOURCE.txt | 4 + .../WildcardPat/WildcardPat.expected | 1 - .../generated/WildcardPat/WildcardPat.ql | 7 - .../generated/WildcardPat/gen_wildcard_pat.rs | 6 - .../generated/YeetExpr/MISSING_SOURCE.txt | 4 + .../generated/YeetExpr/YeetExpr.expected | 1 - .../generated/YeetExpr/YeetExpr.ql | 10 - .../YeetExpr/YeetExpr_getExpr.expected | 1 - .../generated/YeetExpr/YeetExpr_getExpr.ql | 7 - .../generated/YeetExpr/gen_yeet_expr.rs | 8 - .../generated/YieldExpr/MISSING_SOURCE.txt | 4 + .../generated/YieldExpr/YieldExpr.expected | 1 - .../generated/YieldExpr/YieldExpr.ql | 10 - .../YieldExpr/YieldExpr_getExpr.expected | 1 - .../generated/YieldExpr/YieldExpr_getExpr.ql | 7 - .../generated/YieldExpr/gen_yield_expr.rs | 9 - 1003 files changed, 29168 insertions(+), 9181 deletions(-) create mode 100644 rust/ql/lib/codeql/rust/elements/Abi.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ArgList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ArrayType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/AssocItem.qll create mode 100644 rust/ql/lib/codeql/rust/elements/AssocItemList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/AssocTypeArg.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/AsyncBlockExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Attr.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/BlockExprBase.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/BoxExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ClosureBinder.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Const.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ConstArg.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/ConstExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ConstParam.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/Declaration.qll create mode 100644 rust/ql/lib/codeql/rust/elements/DynTraitType.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/ElementListExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Enum.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ExternBlock.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ExternCrate.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ExternItem.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ExternItemList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/FieldList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/FnPtrType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ForExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ForType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/FormatArgsArg.qll create mode 100644 rust/ql/lib/codeql/rust/elements/FormatArgsExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/GenericArg.qll create mode 100644 rust/ql/lib/codeql/rust/elements/GenericParam.qll create mode 100644 rust/ql/lib/codeql/rust/elements/GenericParamList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Impl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ImplTraitType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/InferType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Item.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ItemList.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/ItemStmt.qll create mode 100644 rust/ql/lib/codeql/rust/elements/LetElse.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Lifetime.qll create mode 100644 rust/ql/lib/codeql/rust/elements/LifetimeArg.qll create mode 100644 rust/ql/lib/codeql/rust/elements/LifetimeParam.qll create mode 100644 rust/ql/lib/codeql/rust/elements/MacroCall.qll create mode 100644 rust/ql/lib/codeql/rust/elements/MacroDef.qll create mode 100644 rust/ql/lib/codeql/rust/elements/MacroExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/MacroPat.qll create mode 100644 rust/ql/lib/codeql/rust/elements/MacroRules.qll create mode 100644 rust/ql/lib/codeql/rust/elements/MacroType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/MatchArmList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/MatchGuard.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Meta.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/MissingExpr.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/MissingPat.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Name.qll create mode 100644 rust/ql/lib/codeql/rust/elements/NameRef.qll create mode 100644 rust/ql/lib/codeql/rust/elements/NeverType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Param.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ParamList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ParenExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ParenPat.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ParenType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/PathSegment.qll create mode 100644 rust/ql/lib/codeql/rust/elements/PathType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/PtrType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/RecordExprFieldList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/RecordField.qll create mode 100644 rust/ql/lib/codeql/rust/elements/RecordFieldList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/RecordPatFieldList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/RefType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Rename.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/RepeatExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/RestPat.qll create mode 100644 rust/ql/lib/codeql/rust/elements/RetType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ReturnTypeSyntax.qll create mode 100644 rust/ql/lib/codeql/rust/elements/SelfParam.qll create mode 100644 rust/ql/lib/codeql/rust/elements/SliceType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/SourceFile.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Static.qll create mode 100644 rust/ql/lib/codeql/rust/elements/StmtList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Struct.qll create mode 100644 rust/ql/lib/codeql/rust/elements/TokenTree.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Trait.qll create mode 100644 rust/ql/lib/codeql/rust/elements/TraitAlias.qll create mode 100644 rust/ql/lib/codeql/rust/elements/TryExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/TupleField.qll create mode 100644 rust/ql/lib/codeql/rust/elements/TupleFieldList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/TupleType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/TypeAlias.qll create mode 100644 rust/ql/lib/codeql/rust/elements/TypeArg.qll create mode 100644 rust/ql/lib/codeql/rust/elements/TypeBound.qll create mode 100644 rust/ql/lib/codeql/rust/elements/TypeBoundList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/TypeParam.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/UnimplementedDeclaration.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Union.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/UnsafeBlockExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Use.qll create mode 100644 rust/ql/lib/codeql/rust/elements/UseTree.qll create mode 100644 rust/ql/lib/codeql/rust/elements/UseTreeList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Variant.qll create mode 100644 rust/ql/lib/codeql/rust/elements/VariantList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/Visibility.qll create mode 100644 rust/ql/lib/codeql/rust/elements/WhereClause.qll create mode 100644 rust/ql/lib/codeql/rust/elements/WherePred.qll create mode 100644 rust/ql/lib/codeql/rust/elements/WhileExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/AbiConstructor.qll rename rust/ql/lib/codeql/rust/elements/internal/{BlockExprBaseImpl.qll => AbiImpl.qll} (60%) rename rust/ql/lib/codeql/rust/elements/internal/{TypeRefConstructor.qll => ArgListConstructor.qll} (65%) rename rust/ql/lib/codeql/rust/elements/internal/{DeclarationImpl.qll => ArgListImpl.qll} (55%) rename rust/ql/lib/codeql/rust/elements/internal/{ConstExprConstructor.qll => ArrayExprConstructor.qll} (65%) create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ArrayTypeConstructor.qll rename rust/ql/lib/codeql/rust/elements/internal/{RepeatExprImpl.qll => ArrayTypeImpl.qll} (52%) rename rust/ql/lib/codeql/rust/elements/internal/{BoxExprImpl.qll => AssocItemImpl.qll} (51%) create mode 100644 rust/ql/lib/codeql/rust/elements/internal/AssocItemListConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/AssocItemListImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/AssocTypeArgConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/AssocTypeArgImpl.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/AsyncBlockExprImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/AttrConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/AttrImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ClosureBinderConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ClosureBinderImpl.qll rename rust/ql/lib/codeql/rust/elements/internal/{ItemStmtConstructor.qll => ConstArgConstructor.qll} (65%) create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ConstArgImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ConstConstructor.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/ConstExprImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ConstImpl.qll rename rust/ql/lib/codeql/rust/elements/internal/{MissingPatConstructor.qll => ConstParamConstructor.qll} (64%) create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ConstParamImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/DynTraitTypeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/DynTraitTypeImpl.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/ElementListExprImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/EnumConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/EnumImpl.qll rename rust/ql/lib/codeql/rust/elements/internal/{MissingExprConstructor.qll => ExternBlockConstructor.qll} (64%) create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ExternBlockImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ExternCrateConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ExternCrateImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ExternItemImpl.qll rename rust/ql/lib/codeql/rust/elements/internal/{AsyncBlockExprConstructor.qll => ExternItemListConstructor.qll} (64%) create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ExternItemListImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/FieldListImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/FnPtrTypeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/FnPtrTypeImpl.qll rename rust/ql/lib/codeql/rust/elements/internal/{BoxExprConstructor.qll => ForExprConstructor.qll} (65%) create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ForExprImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ForTypeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ForTypeImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/FormatArgsArgConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/FormatArgsArgImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/FormatArgsExprConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/FormatArgsExprImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/GenericArgImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/GenericParamImpl.qll rename rust/ql/lib/codeql/rust/elements/internal/{ElementListExprConstructor.qll => GenericParamListConstructor.qll} (60%) create mode 100644 rust/ql/lib/codeql/rust/elements/internal/GenericParamListImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ImplConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ImplImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ImplTraitTypeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ImplTraitTypeImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/InferTypeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/InferTypeImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ItemImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ItemListConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ItemListImpl.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/ItemStmtImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/LetElseConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/LetElseImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/LifetimeArgConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/LifetimeArgImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/LifetimeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/LifetimeImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/LifetimeParamConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/LifetimeParamImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MacroCallConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MacroDefConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MacroDefImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MacroExprConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MacroExprImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MacroPatConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MacroPatImpl.qll rename rust/ql/lib/codeql/rust/elements/internal/{RepeatExprConstructor.qll => MacroRulesConstructor.qll} (64%) create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MacroRulesImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MacroTypeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MacroTypeImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MatchArmListConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MatchArmListImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MatchGuardConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MatchGuardImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MetaConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MetaImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/MissingConstructor.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/MissingExprImpl.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/MissingPatImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/NameConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/NameImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/NameRefConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/NameRefImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/NeverTypeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/NeverTypeImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ParamConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ParamImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ParamListConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ParamListImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ParenExprConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ParenExprImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ParenPatConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ParenPatImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ParenTypeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ParenTypeImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/PathSegmentConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/PathSegmentImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/PathTypeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/PathTypeImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/PtrTypeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/PtrTypeImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/RecordExprFieldListConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/RecordExprFieldListImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/RecordFieldConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/RecordFieldImpl.qll rename rust/ql/lib/codeql/rust/elements/internal/{UnsafeBlockExprConstructor.qll => RecordFieldListConstructor.qll} (64%) create mode 100644 rust/ql/lib/codeql/rust/elements/internal/RecordFieldListImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/RecordPatFieldListConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/RecordPatFieldListImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/RefTypeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/RefTypeImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/RenameConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/RenameImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/RestPatConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/RestPatImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/RetTypeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/RetTypeImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ReturnTypeSyntaxConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ReturnTypeSyntaxImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/SelfParamConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/SelfParamImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/SliceTypeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/SliceTypeImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/SourceFileConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/SourceFileImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/StaticConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/StaticImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/StmtListConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/StmtListImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/StructConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/StructImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TokenTreeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TokenTreeImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TraitAliasConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TraitAliasImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TraitConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TraitImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TryExprConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TryExprImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TupleFieldConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TupleFieldImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TupleFieldListConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TupleFieldListImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TupleTypeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TupleTypeImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TypeAliasConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TypeAliasImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TypeArgConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TypeArgImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TypeBoundConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TypeBoundImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TypeBoundListConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TypeBoundListImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TypeParamConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/TypeParamImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/UnimplementedConstructor.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/UnimplementedDeclarationConstructor.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/UnimplementedDeclarationImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/UnionConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/UnionImpl.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/UnsafeBlockExprImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/UseConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/UseImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/UseTreeConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/UseTreeImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/UseTreeListConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/UseTreeListImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/VariantConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/VariantImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/VariantListConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/VariantListImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/VisibilityConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/VisibilityImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/WhereClauseConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/WhereClauseImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/WherePredConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/WherePredImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/WhileExprConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/WhileExprImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Abi.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ArgList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ArrayType.qll rename rust/ql/lib/codeql/rust/elements/internal/generated/{Declaration.qll => AssocItem.qll} (52%) create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/AssocItemList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/AssocTypeArg.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/AsyncBlockExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Attr.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/BlockExprBase.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/BoxExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ClosureBinder.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Const.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ConstArg.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ConstExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ConstParam.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/DynTraitType.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ElementListExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Enum.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ExternBlock.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ExternCrate.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ExternItem.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ExternItemList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/FieldList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/FnPtrType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ForExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ForType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/FormatArgsArg.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/FormatArgsExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/GenericArg.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/GenericParam.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/GenericParamList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Impl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ImplTraitType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/InferType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Item.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ItemList.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ItemStmt.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/LetElse.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Lifetime.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/LifetimeArg.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/LifetimeParam.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/MacroCall.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/MacroDef.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/MacroExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/MacroPat.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/MacroRules.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/MacroType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/MatchArmList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/MatchGuard.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Meta.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/MissingExpr.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/MissingPat.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Name.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/NameRef.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/NeverType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Param.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ParamList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ParenExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ParenPat.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ParenType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/PathSegment.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/PathType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/PtrType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/RecordExprFieldList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/RecordField.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/RecordFieldList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/RecordPatFieldList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/RefType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Rename.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/RepeatExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/RestPat.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/RetType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ReturnTypeSyntax.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/SelfParam.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/SliceType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/SourceFile.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Static.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/StmtList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Struct.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/TokenTree.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Trait.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/TraitAlias.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/TryExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/TupleField.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/TupleFieldList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/TupleType.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/TypeAlias.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/TypeArg.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/TypeBound.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/TypeBoundList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/TypeParam.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/UnimplementedDeclaration.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Union.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/UnsafeBlockExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Use.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/UseTree.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/UseTreeList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Variant.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/VariantList.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/Visibility.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/WhereClause.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/WherePred.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/WhileExpr.qll create mode 100644 rust/ql/test/extractor-tests/generated/Abi/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/ArgList/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/ArrayExpr/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/ArrayType/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/AsmExpr/AsmExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/AsmExpr/AsmExpr.ql create mode 100644 rust/ql/test/extractor-tests/generated/AsmExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/AsmExpr/gen_asm_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/AssocItemList/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/AssocTypeArg/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/AsyncBlockExpr/AsyncBlockExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/AsyncBlockExpr/AsyncBlockExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/AsyncBlockExpr/AsyncBlockExpr_getStatement.expected delete mode 100644 rust/ql/test/extractor-tests/generated/AsyncBlockExpr/AsyncBlockExpr_getStatement.ql delete mode 100644 rust/ql/test/extractor-tests/generated/AsyncBlockExpr/AsyncBlockExpr_getTail.expected delete mode 100644 rust/ql/test/extractor-tests/generated/AsyncBlockExpr/AsyncBlockExpr_getTail.ql delete mode 100644 rust/ql/test/extractor-tests/generated/AsyncBlockExpr/gen_async_block_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/Attr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/AwaitExpr/AwaitExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/AwaitExpr/AwaitExpr.ql create mode 100644 rust/ql/test/extractor-tests/generated/AwaitExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/AwaitExpr/gen_await_expr.rs delete mode 100644 rust/ql/test/extractor-tests/generated/BecomeExpr/BecomeExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/BecomeExpr/BecomeExpr.ql create mode 100644 rust/ql/test/extractor-tests/generated/BecomeExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/BecomeExpr/gen_become_expr.rs delete mode 100644 rust/ql/test/extractor-tests/generated/BinaryExpr/BinaryExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/BinaryExpr/BinaryExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/BinaryExpr/BinaryExpr_getOp.expected delete mode 100644 rust/ql/test/extractor-tests/generated/BinaryExpr/BinaryExpr_getOp.ql create mode 100644 rust/ql/test/extractor-tests/generated/BinaryExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/BinaryExpr/gen_binary_expr.rs delete mode 100644 rust/ql/test/extractor-tests/generated/BlockExpr/BlockExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/BlockExpr/BlockExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/BlockExpr/BlockExpr_getLabel.expected delete mode 100644 rust/ql/test/extractor-tests/generated/BlockExpr/BlockExpr_getLabel.ql delete mode 100644 rust/ql/test/extractor-tests/generated/BlockExpr/BlockExpr_getStatement.expected delete mode 100644 rust/ql/test/extractor-tests/generated/BlockExpr/BlockExpr_getStatement.ql delete mode 100644 rust/ql/test/extractor-tests/generated/BlockExpr/BlockExpr_getTail.expected delete mode 100644 rust/ql/test/extractor-tests/generated/BlockExpr/BlockExpr_getTail.ql create mode 100644 rust/ql/test/extractor-tests/generated/BlockExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/BlockExpr/gen_block_expr.rs delete mode 100644 rust/ql/test/extractor-tests/generated/BoxExpr/BoxExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/BoxExpr/BoxExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/BoxExpr/gen_box_expr.rs delete mode 100644 rust/ql/test/extractor-tests/generated/BoxPat/BoxPat.expected delete mode 100644 rust/ql/test/extractor-tests/generated/BoxPat/BoxPat.ql create mode 100644 rust/ql/test/extractor-tests/generated/BoxPat/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/BoxPat/gen_box_pat.rs delete mode 100644 rust/ql/test/extractor-tests/generated/BreakExpr/BreakExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/BreakExpr/BreakExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/BreakExpr/BreakExpr_getExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/BreakExpr/BreakExpr_getExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/BreakExpr/BreakExpr_getLabel.expected delete mode 100644 rust/ql/test/extractor-tests/generated/BreakExpr/BreakExpr_getLabel.ql create mode 100644 rust/ql/test/extractor-tests/generated/BreakExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/BreakExpr/gen_break_expr.rs delete mode 100644 rust/ql/test/extractor-tests/generated/CallExpr/CallExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/CallExpr/CallExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/CallExpr/CallExpr_getArg.expected delete mode 100644 rust/ql/test/extractor-tests/generated/CallExpr/CallExpr_getArg.ql create mode 100644 rust/ql/test/extractor-tests/generated/CallExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/CallExpr/gen_call_expr.rs delete mode 100644 rust/ql/test/extractor-tests/generated/CastExpr/CastExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/CastExpr/CastExpr.ql create mode 100644 rust/ql/test/extractor-tests/generated/CastExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/CastExpr/gen_cast_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/ClosureBinder/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/ClosureExpr/ClosureExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/ClosureExpr/ClosureExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/ClosureExpr/ClosureExpr_getArg.expected delete mode 100644 rust/ql/test/extractor-tests/generated/ClosureExpr/ClosureExpr_getArg.ql delete mode 100644 rust/ql/test/extractor-tests/generated/ClosureExpr/ClosureExpr_getArgType.expected delete mode 100644 rust/ql/test/extractor-tests/generated/ClosureExpr/ClosureExpr_getArgType.ql delete mode 100644 rust/ql/test/extractor-tests/generated/ClosureExpr/ClosureExpr_getRetType.expected delete mode 100644 rust/ql/test/extractor-tests/generated/ClosureExpr/ClosureExpr_getRetType.ql create mode 100644 rust/ql/test/extractor-tests/generated/ClosureExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/ClosureExpr/gen_closure_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/Const/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/ConstArg/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/ConstBlockPat/ConstBlockPat.expected delete mode 100644 rust/ql/test/extractor-tests/generated/ConstBlockPat/ConstBlockPat.ql create mode 100644 rust/ql/test/extractor-tests/generated/ConstBlockPat/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/ConstBlockPat/gen_const_block_pat.rs delete mode 100644 rust/ql/test/extractor-tests/generated/ConstExpr/ConstExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/ConstExpr/ConstExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/ConstExpr/gen_const_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/ConstParam/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/ContinueExpr/ContinueExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/ContinueExpr/ContinueExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/ContinueExpr/ContinueExpr_getLabel.expected delete mode 100644 rust/ql/test/extractor-tests/generated/ContinueExpr/ContinueExpr_getLabel.ql create mode 100644 rust/ql/test/extractor-tests/generated/ContinueExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/ContinueExpr/gen_continue_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/DynTraitType/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/ElementListExpr/ElementListExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/ElementListExpr/ElementListExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/ElementListExpr/ElementListExpr_getElement.expected delete mode 100644 rust/ql/test/extractor-tests/generated/ElementListExpr/ElementListExpr_getElement.ql delete mode 100644 rust/ql/test/extractor-tests/generated/ElementListExpr/gen_element_list_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/Enum/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/ExprStmt/ExprStmt.expected delete mode 100644 rust/ql/test/extractor-tests/generated/ExprStmt/ExprStmt.ql create mode 100644 rust/ql/test/extractor-tests/generated/ExprStmt/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/ExprStmt/gen_expr_stmt.rs create mode 100644 rust/ql/test/extractor-tests/generated/ExternBlock/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/ExternCrate/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/ExternItemList/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/FieldExpr/FieldExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/FieldExpr/FieldExpr.ql create mode 100644 rust/ql/test/extractor-tests/generated/FieldExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/FieldExpr/gen_field_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/FnPtrType/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/ForExpr/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/ForType/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/FormatArgsArg/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/FormatArgsExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/Function/Function.expected delete mode 100644 rust/ql/test/extractor-tests/generated/Function/Function.ql create mode 100644 rust/ql/test/extractor-tests/generated/Function/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/Function/gen_function.rs delete mode 100644 rust/ql/test/extractor-tests/generated/GenericArgList/GenericArgList.expected delete mode 100644 rust/ql/test/extractor-tests/generated/GenericArgList/GenericArgList.ql create mode 100644 rust/ql/test/extractor-tests/generated/GenericArgList/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/GenericArgList/gen_generic_arg_list.rs create mode 100644 rust/ql/test/extractor-tests/generated/GenericParamList/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/IdentPat/IdentPat.expected delete mode 100644 rust/ql/test/extractor-tests/generated/IdentPat/IdentPat.ql delete mode 100644 rust/ql/test/extractor-tests/generated/IdentPat/IdentPat_getSubpat.expected delete mode 100644 rust/ql/test/extractor-tests/generated/IdentPat/IdentPat_getSubpat.ql create mode 100644 rust/ql/test/extractor-tests/generated/IdentPat/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/IdentPat/gen_ident_pat.rs delete mode 100644 rust/ql/test/extractor-tests/generated/IfExpr/IfExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/IfExpr/IfExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/IfExpr/IfExpr_getElse.expected delete mode 100644 rust/ql/test/extractor-tests/generated/IfExpr/IfExpr_getElse.ql create mode 100644 rust/ql/test/extractor-tests/generated/IfExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/IfExpr/gen_if_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/Impl/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/ImplTraitType/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/IndexExpr/IndexExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/IndexExpr/IndexExpr.ql create mode 100644 rust/ql/test/extractor-tests/generated/IndexExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/IndexExpr/gen_index_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/InferType/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/ItemList/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/Label/Label.expected delete mode 100644 rust/ql/test/extractor-tests/generated/Label/Label.ql create mode 100644 rust/ql/test/extractor-tests/generated/Label/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/Label/gen_label.rs create mode 100644 rust/ql/test/extractor-tests/generated/LetElse/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/LetExpr/LetExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/LetExpr/LetExpr.ql create mode 100644 rust/ql/test/extractor-tests/generated/LetExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/LetExpr/gen_let_expr.rs delete mode 100644 rust/ql/test/extractor-tests/generated/LetStmt/LetStmt.expected delete mode 100644 rust/ql/test/extractor-tests/generated/LetStmt/LetStmt.ql delete mode 100644 rust/ql/test/extractor-tests/generated/LetStmt/LetStmt_getElse.expected delete mode 100644 rust/ql/test/extractor-tests/generated/LetStmt/LetStmt_getElse.ql delete mode 100644 rust/ql/test/extractor-tests/generated/LetStmt/LetStmt_getInitializer.expected delete mode 100644 rust/ql/test/extractor-tests/generated/LetStmt/LetStmt_getInitializer.ql delete mode 100644 rust/ql/test/extractor-tests/generated/LetStmt/LetStmt_getType.expected delete mode 100644 rust/ql/test/extractor-tests/generated/LetStmt/LetStmt_getType.ql create mode 100644 rust/ql/test/extractor-tests/generated/LetStmt/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/LetStmt/gen_let_stmt.rs create mode 100644 rust/ql/test/extractor-tests/generated/Lifetime/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/LifetimeArg/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/LifetimeParam/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/LiteralExpr/LiteralExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/LiteralExpr/LiteralExpr.ql create mode 100644 rust/ql/test/extractor-tests/generated/LiteralExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/LiteralExpr/gen_literal_expr.rs delete mode 100644 rust/ql/test/extractor-tests/generated/LiteralPat/LiteralPat.expected delete mode 100644 rust/ql/test/extractor-tests/generated/LiteralPat/LiteralPat.ql create mode 100644 rust/ql/test/extractor-tests/generated/LiteralPat/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/LiteralPat/gen_literal_pat.rs delete mode 100644 rust/ql/test/extractor-tests/generated/LoopExpr/LoopExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/LoopExpr/LoopExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/LoopExpr/LoopExpr_getLabel.expected delete mode 100644 rust/ql/test/extractor-tests/generated/LoopExpr/LoopExpr_getLabel.ql create mode 100644 rust/ql/test/extractor-tests/generated/LoopExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/LoopExpr/gen_loop_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/MacroCall/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/MacroDef/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/MacroExpr/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/MacroPat/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/MacroRules/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/MacroType/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/MatchArm/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/MatchArm/MatchArm.expected delete mode 100644 rust/ql/test/extractor-tests/generated/MatchArm/MatchArm.ql delete mode 100644 rust/ql/test/extractor-tests/generated/MatchArm/MatchArm_getGuard.expected delete mode 100644 rust/ql/test/extractor-tests/generated/MatchArm/MatchArm_getGuard.ql delete mode 100644 rust/ql/test/extractor-tests/generated/MatchArm/gen_match_arm.rs create mode 100644 rust/ql/test/extractor-tests/generated/MatchArmList/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/MatchExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getBranch.expected delete mode 100644 rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getBranch.ql delete mode 100644 rust/ql/test/extractor-tests/generated/MatchExpr/gen_match_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/MatchGuard/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/Meta/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/MethodCallExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getArg.expected delete mode 100644 rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getArg.ql delete mode 100644 rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getGenericArgs.expected delete mode 100644 rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr_getGenericArgs.ql delete mode 100644 rust/ql/test/extractor-tests/generated/MethodCallExpr/gen_method_call_expr.rs delete mode 100644 rust/ql/test/extractor-tests/generated/MissingExpr/MissingExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/MissingExpr/MissingExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/MissingExpr/gen_missing_expr.rs delete mode 100644 rust/ql/test/extractor-tests/generated/MissingPat/MissingPat.expected delete mode 100644 rust/ql/test/extractor-tests/generated/MissingPat/MissingPat.ql delete mode 100644 rust/ql/test/extractor-tests/generated/MissingPat/gen_missing_pat.rs create mode 100644 rust/ql/test/extractor-tests/generated/Module/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/Module/Module.expected delete mode 100644 rust/ql/test/extractor-tests/generated/Module/Module.ql delete mode 100644 rust/ql/test/extractor-tests/generated/Module/Module_getDeclaration.expected delete mode 100644 rust/ql/test/extractor-tests/generated/Module/Module_getDeclaration.ql delete mode 100644 rust/ql/test/extractor-tests/generated/Module/gen_module.rs create mode 100644 rust/ql/test/extractor-tests/generated/Name/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/NameRef/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/NeverType/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/OffsetOfExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/OffsetOfExpr/OffsetOfExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/OffsetOfExpr/OffsetOfExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/OffsetOfExpr/OffsetOfExpr_getField.expected delete mode 100644 rust/ql/test/extractor-tests/generated/OffsetOfExpr/OffsetOfExpr_getField.ql delete mode 100644 rust/ql/test/extractor-tests/generated/OffsetOfExpr/gen_offset_of_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/OrPat/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/OrPat/OrPat.expected delete mode 100644 rust/ql/test/extractor-tests/generated/OrPat/OrPat.ql delete mode 100644 rust/ql/test/extractor-tests/generated/OrPat/OrPat_getArg.expected delete mode 100644 rust/ql/test/extractor-tests/generated/OrPat/OrPat_getArg.ql delete mode 100644 rust/ql/test/extractor-tests/generated/OrPat/gen_or_pat.rs create mode 100644 rust/ql/test/extractor-tests/generated/Param/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/ParamList/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/ParenExpr/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/ParenPat/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/ParenType/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/Path/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/Path/Path.expected delete mode 100644 rust/ql/test/extractor-tests/generated/Path/Path.ql delete mode 100644 rust/ql/test/extractor-tests/generated/Path/gen_path.rs create mode 100644 rust/ql/test/extractor-tests/generated/PathExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/PathExpr/PathExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/PathExpr/PathExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/PathExpr/gen_path_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/PathPat/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/PathPat/PathPat.expected delete mode 100644 rust/ql/test/extractor-tests/generated/PathPat/PathPat.ql delete mode 100644 rust/ql/test/extractor-tests/generated/PathPat/gen_path_pat.rs create mode 100644 rust/ql/test/extractor-tests/generated/PathSegment/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/PathType/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/PrefixExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/PrefixExpr/PrefixExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/PrefixExpr/PrefixExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/PrefixExpr/gen_prefix_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/PtrType/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/RangeExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/RangeExpr/RangeExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RangeExpr/RangeExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RangeExpr/RangeExpr_getLhs.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RangeExpr/RangeExpr_getLhs.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RangeExpr/RangeExpr_getRhs.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RangeExpr/RangeExpr_getRhs.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RangeExpr/gen_range_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/RangePat/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/RangePat/RangePat.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RangePat/RangePat.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RangePat/RangePat_getEnd.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RangePat/RangePat_getEnd.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RangePat/RangePat_getStart.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RangePat/RangePat_getStart.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RangePat/gen_range_pat.rs create mode 100644 rust/ql/test/extractor-tests/generated/RecordExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/RecordExpr/RecordExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RecordExpr/RecordExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RecordExpr/RecordExpr_getFld.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RecordExpr/RecordExpr_getFld.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RecordExpr/RecordExpr_getPath.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RecordExpr/RecordExpr_getPath.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RecordExpr/RecordExpr_getSpread.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RecordExpr/RecordExpr_getSpread.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RecordExpr/gen_record_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/RecordExprField/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/RecordExprField/RecordExprField.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RecordExprField/RecordExprField.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RecordExprField/gen_record_expr_field.rs create mode 100644 rust/ql/test/extractor-tests/generated/RecordExprFieldList/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/RecordField/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/RecordFieldList/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/RecordPat/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/RecordPat/RecordPat.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RecordPat/RecordPat.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RecordPat/RecordPat_getFld.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RecordPat/RecordPat_getFld.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RecordPat/RecordPat_getPath.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RecordPat/RecordPat_getPath.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RecordPat/gen_record_pat.rs create mode 100644 rust/ql/test/extractor-tests/generated/RecordPatField/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/RecordPatField/RecordPatField.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RecordPatField/RecordPatField.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RecordPatField/gen_record_pat_field.rs create mode 100644 rust/ql/test/extractor-tests/generated/RecordPatFieldList/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/RefExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/RefExpr/RefExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RefExpr/RefExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RefExpr/gen_ref_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/RefPat/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/RefPat/RefPat.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RefPat/RefPat.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RefPat/gen_ref_pat.rs create mode 100644 rust/ql/test/extractor-tests/generated/RefType/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/Rename/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/RepeatExpr/RepeatExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/RepeatExpr/RepeatExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/RepeatExpr/gen_repeat_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/RestPat/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/RetType/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/ReturnExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/ReturnExpr/ReturnExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/ReturnExpr/ReturnExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/ReturnExpr/ReturnExpr_getExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/ReturnExpr/ReturnExpr_getExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/ReturnExpr/gen_return_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/ReturnTypeSyntax/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/SelfParam/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/SlicePat/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/SlicePat/SlicePat.expected delete mode 100644 rust/ql/test/extractor-tests/generated/SlicePat/SlicePat.ql delete mode 100644 rust/ql/test/extractor-tests/generated/SlicePat/SlicePat_getPrefix.expected delete mode 100644 rust/ql/test/extractor-tests/generated/SlicePat/SlicePat_getPrefix.ql delete mode 100644 rust/ql/test/extractor-tests/generated/SlicePat/SlicePat_getSlice.expected delete mode 100644 rust/ql/test/extractor-tests/generated/SlicePat/SlicePat_getSlice.ql delete mode 100644 rust/ql/test/extractor-tests/generated/SlicePat/SlicePat_getSuffix.expected delete mode 100644 rust/ql/test/extractor-tests/generated/SlicePat/SlicePat_getSuffix.ql delete mode 100644 rust/ql/test/extractor-tests/generated/SlicePat/gen_slice_pat.rs create mode 100644 rust/ql/test/extractor-tests/generated/SliceType/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/SourceFile/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/Static/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/StmtList/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/Struct/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/TokenTree/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/Trait/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/TraitAlias/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/TryExpr/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/TupleExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/TupleExpr/TupleExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/TupleExpr/TupleExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/TupleExpr/TupleExpr_getExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/TupleExpr/TupleExpr_getExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/TupleExpr/gen_tuple_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/TupleField/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/TupleFieldList/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/TuplePat/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/TuplePat/TuplePat.expected delete mode 100644 rust/ql/test/extractor-tests/generated/TuplePat/TuplePat.ql delete mode 100644 rust/ql/test/extractor-tests/generated/TuplePat/TuplePat_getArg.expected delete mode 100644 rust/ql/test/extractor-tests/generated/TuplePat/TuplePat_getArg.ql delete mode 100644 rust/ql/test/extractor-tests/generated/TuplePat/TuplePat_getEllipsisIndex.expected delete mode 100644 rust/ql/test/extractor-tests/generated/TuplePat/TuplePat_getEllipsisIndex.ql delete mode 100644 rust/ql/test/extractor-tests/generated/TuplePat/gen_tuple_pat.rs create mode 100644 rust/ql/test/extractor-tests/generated/TupleStructPat/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/TupleStructPat/TupleStructPat.expected delete mode 100644 rust/ql/test/extractor-tests/generated/TupleStructPat/TupleStructPat.ql delete mode 100644 rust/ql/test/extractor-tests/generated/TupleStructPat/TupleStructPat_getArg.expected delete mode 100644 rust/ql/test/extractor-tests/generated/TupleStructPat/TupleStructPat_getArg.ql delete mode 100644 rust/ql/test/extractor-tests/generated/TupleStructPat/TupleStructPat_getEllipsisIndex.expected delete mode 100644 rust/ql/test/extractor-tests/generated/TupleStructPat/TupleStructPat_getEllipsisIndex.ql delete mode 100644 rust/ql/test/extractor-tests/generated/TupleStructPat/TupleStructPat_getPath.expected delete mode 100644 rust/ql/test/extractor-tests/generated/TupleStructPat/TupleStructPat_getPath.ql delete mode 100644 rust/ql/test/extractor-tests/generated/TupleStructPat/gen_tuple_struct_pat.rs create mode 100644 rust/ql/test/extractor-tests/generated/TupleType/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/TypeAlias/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/TypeArg/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/TypeBound/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/TypeBoundList/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/TypeParam/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/TypeRef/TypeRef.expected delete mode 100644 rust/ql/test/extractor-tests/generated/TypeRef/TypeRef.ql delete mode 100644 rust/ql/test/extractor-tests/generated/TypeRef/gen_type_ref.rs create mode 100644 rust/ql/test/extractor-tests/generated/UnderscoreExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/UnderscoreExpr/UnderscoreExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/UnderscoreExpr/UnderscoreExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/UnderscoreExpr/gen_underscore_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/Union/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/UnsafeBlockExpr/UnsafeBlockExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/UnsafeBlockExpr/UnsafeBlockExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/UnsafeBlockExpr/UnsafeBlockExpr_getStatement.expected delete mode 100644 rust/ql/test/extractor-tests/generated/UnsafeBlockExpr/UnsafeBlockExpr_getStatement.ql delete mode 100644 rust/ql/test/extractor-tests/generated/UnsafeBlockExpr/UnsafeBlockExpr_getTail.expected delete mode 100644 rust/ql/test/extractor-tests/generated/UnsafeBlockExpr/UnsafeBlockExpr_getTail.ql delete mode 100644 rust/ql/test/extractor-tests/generated/UnsafeBlockExpr/gen_unsafe_block_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/Use/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/UseTree/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/UseTreeList/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/Variant/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/VariantList/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/Visibility/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/WhereClause/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/WherePred/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/WhileExpr/MISSING_SOURCE.txt create mode 100644 rust/ql/test/extractor-tests/generated/WildcardPat/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/WildcardPat/WildcardPat.expected delete mode 100644 rust/ql/test/extractor-tests/generated/WildcardPat/WildcardPat.ql delete mode 100644 rust/ql/test/extractor-tests/generated/WildcardPat/gen_wildcard_pat.rs create mode 100644 rust/ql/test/extractor-tests/generated/YeetExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/YeetExpr/YeetExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/YeetExpr/YeetExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/YeetExpr/YeetExpr_getExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/YeetExpr/YeetExpr_getExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/YeetExpr/gen_yeet_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/YieldExpr/MISSING_SOURCE.txt delete mode 100644 rust/ql/test/extractor-tests/generated/YieldExpr/YieldExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/YieldExpr/YieldExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/YieldExpr/YieldExpr_getExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/YieldExpr/YieldExpr_getExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/YieldExpr/gen_yield_expr.rs diff --git a/rust/extractor/src/generated/.generated.list b/rust/extractor/src/generated/.generated.list index 795e5d0a5506..c69acb7a2493 100644 --- a/rust/extractor/src/generated/.generated.list +++ b/rust/extractor/src/generated/.generated.list @@ -1,2 +1,2 @@ mod.rs 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 -top.rs ec9ec5e218af9a6b449b40f716e00bbe23c2777941d105b9ed68071aa2468ca2 ec9ec5e218af9a6b449b40f716e00bbe23c2777941d105b9ed68071aa2468ca2 +top.rs 90a8dbfc1e4689d3310f40a3377ef0542f1886cd8c84782362d3047f0b27b3ff 90a8dbfc1e4689d3310f40a3377ef0542f1886cd8c84782362d3047f0b27b3ff diff --git a/rust/extractor/src/generated/top.rs b/rust/extractor/src/generated/top.rs index 397120818723..353041d7fc43 100644 --- a/rust/extractor/src/generated/top.rs +++ b/rust/extractor/src/generated/top.rs @@ -78,7 +78,17 @@ impl From> for trap::Label { #[derive(Debug)] pub struct Missing { - _unused: () + pub id: trap::TrapId, +} + +impl trap::TrapEntry for Missing { + fn extract_id(&mut self) -> trap::TrapId { + std::mem::replace(&mut self.id, trap::TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("missings", vec![id.into()]); + } } impl trap::TrapClass for Missing { @@ -105,7 +115,17 @@ impl From> for trap::Label { #[derive(Debug)] pub struct Unimplemented { - _unused: () + pub id: trap::TrapId, +} + +impl trap::TrapEntry for Unimplemented { + fn extract_id(&mut self) -> trap::TrapId { + std::mem::replace(&mut self.id, trap::TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("unimplementeds", vec![id.into()]); + } } impl trap::TrapClass for Unimplemented { @@ -131,35 +151,49 @@ impl From> for trap::Label { } #[derive(Debug)] -pub struct Declaration { - _unused: () +pub struct Abi { + pub id: trap::TrapId, + pub abi_string: Option, +} + +impl trap::TrapEntry for Abi { + fn extract_id(&mut self) -> trap::TrapId { + std::mem::replace(&mut self.id, trap::TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("abis", vec![id.into()]); + if let Some(v) = self.abi_string { + out.add_tuple("abi_abi_strings", vec![id.into(), v.into()]); + } + } } -impl trap::TrapClass for Declaration { - fn class_name() -> &'static str { "Declaration" } +impl trap::TrapClass for Abi { + fn class_name() -> &'static str { "Abi" } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme Declaration is a subclass of AstNode +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Abi is a subclass of AstNode unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme Declaration is a subclass of Element +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Abi is a subclass of Element unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme Declaration is a subclass of Locatable +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme Abi is a subclass of Locatable unsafe { Self::from_untyped(value.as_untyped()) } @@ -167,35 +201,49 @@ impl From> for trap::Label { } #[derive(Debug)] -pub struct Expr { - _unused: () +pub struct ArgList { + pub id: trap::TrapId, + pub args: Vec>, } -impl trap::TrapClass for Expr { - fn class_name() -> &'static str { "Expr" } +impl trap::TrapEntry for ArgList { + fn extract_id(&mut self) -> trap::TrapId { + std::mem::replace(&mut self.id, trap::TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("arg_lists", vec![id.into()]); + for (i, v) in self.args.into_iter().enumerate() { + out.add_tuple("arg_list_args", vec![id.into(), i.into(), v.into()]); + } + } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme Expr is a subclass of AstNode +impl trap::TrapClass for ArgList { + fn class_name() -> &'static str { "ArgList" } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme ArgList is a subclass of AstNode unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme Expr is a subclass of Element +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme ArgList is a subclass of Element unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme Expr is a subclass of Locatable +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme ArgList is a subclass of Locatable unsafe { Self::from_untyped(value.as_untyped()) } @@ -203,63 +251,89 @@ impl From> for trap::Label { } #[derive(Debug)] -pub struct GenericArgList { - pub id: trap::TrapId, +pub struct AssocItem { + _unused: () } -impl trap::TrapEntry for GenericArgList { - fn extract_id(&mut self) -> trap::TrapId { - std::mem::replace(&mut self.id, trap::TrapId::Star) - } - - fn emit(self, id: trap::Label, out: &mut trap::Writer) { - out.add_tuple("generic_arg_lists", vec![id.into()]); - } +impl trap::TrapClass for AssocItem { + fn class_name() -> &'static str { "AssocItem" } } -impl trap::TrapClass for GenericArgList { - fn class_name() -> &'static str { "GenericArgList" } +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme AssocItem is a subclass of AstNode + unsafe { + Self::from_untyped(value.as_untyped()) + } + } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme GenericArgList is a subclass of AstNode +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme AssocItem is a subclass of Element unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme GenericArgList is a subclass of Element +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme AssocItem is a subclass of Locatable unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme GenericArgList is a subclass of Locatable +#[derive(Debug)] +pub struct AssocItemList { + pub id: trap::TrapId, + pub assoc_items: Vec>, + pub attrs: Vec>, +} + +impl trap::TrapEntry for AssocItemList { + fn extract_id(&mut self) -> trap::TrapId { + std::mem::replace(&mut self.id, trap::TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("assoc_item_lists", vec![id.into()]); + for (i, v) in self.assoc_items.into_iter().enumerate() { + out.add_tuple("assoc_item_list_assoc_items", vec![id.into(), i.into(), v.into()]); + } + for (i, v) in self.attrs.into_iter().enumerate() { + out.add_tuple("assoc_item_list_attrs", vec![id.into(), i.into(), v.into()]); + } + } +} + +impl trap::TrapClass for AssocItemList { + fn class_name() -> &'static str { "AssocItemList" } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme AssocItemList is a subclass of AstNode unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme GenericArgList is a subclass of Unextracted +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme AssocItemList is a subclass of Element unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme GenericArgList is a subclass of Unimplemented +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme AssocItemList is a subclass of Locatable unsafe { Self::from_untyped(value.as_untyped()) } @@ -267,46 +341,49 @@ impl From> for trap::Label { } #[derive(Debug)] -pub struct Label { - pub id: trap::TrapId