Rust: Add Callable.getBody()

This commit is contained in:
Tom Hvitved
2025-10-21 11:41:53 +02:00
parent 7d0509b6af
commit 944ebc5267
25 changed files with 135 additions and 105 deletions

View File

@@ -44,6 +44,8 @@ fn property_name(type_name: &str, field_name: &str) -> String {
("StructField", "expr") => "default",
("UseTree", "is_star") => "is_glob",
(_, "ty") => "type_repr",
("Function", "body") => "function_body",
("ClosureExpr", "body") => "closure_body",
_ if field_name.contains("record") => &field_name.replacen("record", "struct", 1),
_ => field_name,
};

View File

@@ -1,2 +1,2 @@
mod.rs 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7
top.rs ef1e4ee1ec10669092c216f95bc34a1740e1fadfc4f3ad91ef14dccc5f2a7490 ef1e4ee1ec10669092c216f95bc34a1740e1fadfc4f3ad91ef14dccc5f2a7490
top.rs 460e827738766301a137f1750be7cd3016e6b7e4e487c6c95972bd3e1d21b814 460e827738766301a137f1750be7cd3016e6b7e4e487c6c95972bd3e1d21b814

View File

@@ -4431,7 +4431,7 @@ pub struct ClosureExpr {
pub id: trap::TrapId<ClosureExpr>,
pub param_list: Option<trap::Label<ParamList>>,
pub attrs: Vec<trap::Label<Attr>>,
pub body: Option<trap::Label<Expr>>,
pub closure_body: Option<trap::Label<Expr>>,
pub for_binder: Option<trap::Label<ForBinder>>,
pub is_async: bool,
pub is_const: bool,
@@ -4454,8 +4454,8 @@ impl trap::TrapEntry for ClosureExpr {
for (i, v) in self.attrs.into_iter().enumerate() {
out.add_tuple("callable_attrs", vec![id.into(), i.into(), v.into()]);
}
if let Some(v) = self.body {
out.add_tuple("closure_expr_bodies", vec![id.into(), v.into()]);
if let Some(v) = self.closure_body {
out.add_tuple("closure_expr_closure_bodies", vec![id.into(), v.into()]);
}
if let Some(v) = self.for_binder {
out.add_tuple("closure_expr_for_binders", vec![id.into(), v.into()]);
@@ -10783,7 +10783,7 @@ pub struct Function {
pub param_list: Option<trap::Label<ParamList>>,
pub attrs: Vec<trap::Label<Attr>>,
pub abi: Option<trap::Label<Abi>>,
pub body: Option<trap::Label<BlockExpr>>,
pub function_body: Option<trap::Label<BlockExpr>>,
pub generic_param_list: Option<trap::Label<GenericParamList>>,
pub is_async: bool,
pub is_const: bool,
@@ -10812,8 +10812,8 @@ impl trap::TrapEntry for Function {
if let Some(v) = self.abi {
out.add_tuple("function_abis", vec![id.into(), v.into()]);
}
if let Some(v) = self.body {
out.add_tuple("function_bodies", vec![id.into(), v.into()]);
if let Some(v) = self.function_body {
out.add_tuple("function_function_bodies", vec![id.into(), v.into()]);
}
if let Some(v) = self.generic_param_list {
out.add_tuple("function_generic_param_lists", vec![id.into(), v.into()]);

View File

@@ -696,7 +696,7 @@ impl Translator<'_> {
return None;
}
let attrs = node.attrs().filter_map(|x| self.emit_attr(&x)).collect();
let body = node.body().and_then(|x| self.emit_expr(&x));
let closure_body = node.body().and_then(|x| self.emit_expr(&x));
let for_binder = node.for_binder().and_then(|x| self.emit_for_binder(&x));
let is_async = node.async_token().is_some();
let is_const = node.const_token().is_some();
@@ -708,7 +708,7 @@ impl Translator<'_> {
let label = self.trap.emit(generated::ClosureExpr {
id: TrapId::Star,
attrs,
body,
closure_body,
for_binder,
is_async,
is_const,
@@ -984,7 +984,7 @@ impl Translator<'_> {
}
let abi = node.abi().and_then(|x| self.emit_abi(&x));
let attrs = node.attrs().filter_map(|x| self.emit_attr(&x)).collect();
let body = if self.should_skip_bodies() {
let function_body = if self.should_skip_bodies() {
None
} else {
node.body().and_then(|x| self.emit_block_expr(&x))
@@ -1006,7 +1006,7 @@ impl Translator<'_> {
id: TrapId::Star,
abi,
attrs,
body,
function_body,
generic_param_list,
is_async,
is_const,

View File

@@ -34,7 +34,7 @@ lib/codeql/rust/elements/BoxPat.qll 1b2c3fff171aa6aa238c9460b122f26c79e04577cea6
lib/codeql/rust/elements/BreakExpr.qll 7ca3807a20e9a9a988d1fd7abebf240325ed422fcb45c719ba46272f031f94db dffb7379d3f3ba220acfbd05eb7bb6cfd9cfda211e9c8b1f5240ca5fa61be3fc
lib/codeql/rust/elements/CallExpr.qll f336500ca7a611b164d48b90e80edb0c0d3816792b0ececce659ac1ff1ffeb3e f99a9c55466418ef53860c44d9f2d6161af4b492178ddd9e5870dff742b70ae5
lib/codeql/rust/elements/CallExprBase.qll 2846202b5208b541977500286951d96487bf555838c6c16cdd006a71e383745a c789d412bf099c624329379e0c7d94fa0d23ae2edea7a25a2ea0f3c0042ccf62
lib/codeql/rust/elements/Callable.qll 0f7f78c3bfabbe24962f6232b0440d27e51f06d2b8d341fc623ffbfbff173f47 5fd13aaa0eaf76ea0b47fa0641bd23eea20a069f0b3cbc1ee4e290e88321008a
lib/codeql/rust/elements/Callable.qll 08a46e987b8fde29069795a536fcd1ad1a96f60341f72293e4d07e20334d554f cfc2be9287000718e5ff3c2a35bb45ffc93fd36d97f2e034888e9aa2ae9af555
lib/codeql/rust/elements/CastExpr.qll 2fe1f36ba31fa29de309baf0a665cfcae67b61c73345e8f9bbd41e8c235fec45 c5b4c1e9dc24eb2357799defcb2df25989075e3a80e8663b74204a1c1b70e29a
lib/codeql/rust/elements/ClosureExpr.qll 69e0b7a7c7a4c348fcada5ad4da22dd2f51747109f856be239cede315a56d695 93400650282e2d4e682b826e9f5f844aa893dda126548e41ea1c703d2bf209ca
lib/codeql/rust/elements/Comment.qll fedad50575125e9a64a8a8776a8c1dbf1e76df990f01849d9f0955f9d74cb2a6 8eb1afad1e1007a4f0090fdac65d81726b23eda6517d067fd0185f70f17635ab
@@ -484,9 +484,9 @@ lib/codeql/rust/elements/internal/generated/BoxPat.qll 597bed52f7489e0addce3266f
lib/codeql/rust/elements/internal/generated/BreakExpr.qll 0f428a8b2f4209b134c2ffc3e1c93c30bc6b0e9c9172f140cefa88c1f77d8690 957b39f38ff6befe9061f55bc0b403c2f1c366dd0cf63b874bae6f8216576d76
lib/codeql/rust/elements/internal/generated/CallExpr.qll f1b8dae487077cc9d1dccf8c3cd61fd17afe860585f17ce8b860be4859be7ca4 6034fc03778e38802cdf3a6e460364b74e92912622581b31e6179951022bbbd6
lib/codeql/rust/elements/internal/generated/CallExprBase.qll 2268e01d65015014c05166161bb28e5a1e78164d525ca16fc1e3106866cf231d b2f9b912153ba4d3e3612df4f74ac0e83077c31d5b31383bd277974081417a56
lib/codeql/rust/elements/internal/generated/Callable.qll 9a8661aa018fd90a21529760c1dbc46c1ad3649e17b030e59ced0683fbf83f8a 8b573adfc23ec0ac91949da415e6a0c988fa02cbce9534d45ac98a5512d7b1ca
lib/codeql/rust/elements/internal/generated/Callable.qll 12368b998c771c6b80f54123cea4d3600af7432ab34c9e571bc0bf3894ceb17e 273a9fd9cdae56cf2edbdc9c49b15da49cd5ad04be70acbbe2475c9c50200183
lib/codeql/rust/elements/internal/generated/CastExpr.qll ddc20054b0b339ad4d40298f3461490d25d00af87c876da5ffbc6a11c0832295 f4247307afcd74d80e926f29f8c57e78c50800984483e6b6003a44681e4a71f3
lib/codeql/rust/elements/internal/generated/ClosureExpr.qll 1f77ea8ec01366f8027fa36793f7de5a74f562a1af1bf6954410e68670e6f68a bd61457093dcfc3985e6e526d4582299f29421bc7d3e9818e530152ac8ad8bed
lib/codeql/rust/elements/internal/generated/ClosureExpr.qll 818aff75d86821c670d8ba0720c3270681b3e070140a9c41beab2a811b43eee6 9bf2d1d38f6c4a99d7c058f8ed096141f5ba6a75d2d26a464f0d65ed4e554222
lib/codeql/rust/elements/internal/generated/Comment.qll cd1ef861e3803618f9f78a4ac00516d50ecfecdca1c1d14304dc5327cbe07a3b 8b67345aeb15beb5895212228761ea3496297846c93fd2127b417406ae87c201
lib/codeql/rust/elements/internal/generated/Const.qll 3e606f0198b6461a94964dba7a4d386408f01651d75378eeab251dfceccf49c8 20fe276cded4764bdb1cd50de956bea88d7cd731909c0b84b4abb972b3094959
lib/codeql/rust/elements/internal/generated/ConstArg.qll c52bf746f2dc89b8d71b8419736707bfcbb09cca424c3ba76e888e2add415bf6 89309a9df4fde23cfd3d8492908ccec4d90cc8457d35c507ef81371a369941b4
@@ -515,7 +515,7 @@ lib/codeql/rust/elements/internal/generated/FormatArgsArg.qll c762a4af8609472e28
lib/codeql/rust/elements/internal/generated/FormatArgsExpr.qll 8aed8715a27d3af3de56ded4610c6792a25216b1544eb7e57c8b0b37c14bd9c1 590a2b0063d2ecd00bbbd1ce29603c8fd69972e34e6daddf309c915ce4ec1375
lib/codeql/rust/elements/internal/generated/FormatArgument.qll cd05153276e63e689c95d5537fbc7d892615f62e110323759ef02e23a7587407 be2a4531b498f01625effa4c631d51ee8857698b00cfb829074120a0f2696d57
lib/codeql/rust/elements/internal/generated/FormatTemplateVariableAccess.qll a6175214fad445df9234b3ee9bf5147da75baf82473fb8d384b455e3add0dac1 a928db0ff126b2e54a18f5c488232abd1bd6c5eda24591d3c3bb80c6ee71c770
lib/codeql/rust/elements/internal/generated/Function.qll 695dbc61e1c4d67a75e438f30fffcaa4a251be629093428b6b7afba053342fb6 ddc34f1da6b4b2ac64d60028822c7cfc72da133dd08ad2490bd2dcae9d91e074
lib/codeql/rust/elements/internal/generated/Function.qll 25aa44c816233b9259b4ca12a15b6aff5856f4147d6a72fd0ec2fdebb24a5131 62a8a9080bf555950a854f84444d79cbe72d69b1d3f73ac801bb11e732fc7e46
lib/codeql/rust/elements/internal/generated/GenericArg.qll 908dadf36a631bc9f4423ab473d1344ed882c7f3f85ac169d82e0099ff6337d4 c6ef5358db3a0318987962a51cbe6b77ae9c0e39c1312a059306e40e86db7eb8
lib/codeql/rust/elements/internal/generated/GenericArgList.qll b8cd936bba6f28344e28c98acf38acb8ef43af6ecf8367d79ed487e5b9da17cb 8b14331261e49d004807285b02fca190aafd62bfb9378b05c7d9c1e95525fe7b
lib/codeql/rust/elements/internal/generated/GenericParam.qll 85ac027a42b3300febc9f7ede1098d3ffae7bac571cba6391bc00f9061780324 806cb9d1b0e93442bef180e362c4abc055ab31867ff34bac734b89d32bd82aa1
@@ -569,7 +569,7 @@ lib/codeql/rust/elements/internal/generated/ParamList.qll eaa0cd4402d3665013d47e
lib/codeql/rust/elements/internal/generated/ParenExpr.qll 812d2ff65079277f39f15c084657a955a960a7c1c0e96dd60472a58d56b945eb eb8c607f43e1fcbb41f37a10de203a1db806690e10ff4f04d48ed874189cb0eb
lib/codeql/rust/elements/internal/generated/ParenPat.qll 24f9dc7fce75827d6fddb856cd48f80168143151b27295c0bab6db5a06567a09 ebadbc6f5498e9ed754b39893ce0763840409a0721036a25b56e1ead7dcc09aa
lib/codeql/rust/elements/internal/generated/ParenTypeRepr.qll 03f5c5b96a37adeb845352d7fcea3e098da9050e534972d14ac0f70d60a2d776 ed3d6e5d02086523087adebce4e89e35461eb95f2a66d1d4100fe23fc691b126
lib/codeql/rust/elements/internal/generated/ParentChild.qll 7d67059559590954faf55aab56885fedc7b7a63a37b7a871b19204c42d493a4d 04ad386fd2b4e5d0150887aad97cf3ed8406391c8bc95dd2de29eb29a2ac0b6e
lib/codeql/rust/elements/internal/generated/ParentChild.qll 6e86fd9b6d5ec1b4aeeb5472cc6d2ebf3328bbaa8605cf52c9add56652cc47dc 3cf2a8e12ffb6631221c7b94fa112e8e3be96efba697996862685a87b2c9aff7
lib/codeql/rust/elements/internal/generated/ParenthesizedArgList.qll d901fdc8142a5b8847cc98fc2afcfd16428b8ace4fbffb457e761b5fd3901a77 5dbb0aea5a13f937da666ccb042494af8f11e776ade1459d16b70a4dd193f9fb
lib/codeql/rust/elements/internal/generated/Pat.qll 3605ac062be2f294ee73336e9669027b8b655f4ad55660e1eab35266275154ee 7f9400db2884d336dd1d21df2a8093759c2a110be9bf6482ce8e80ae0fd74ed4
lib/codeql/rust/elements/internal/generated/Path.qll 9b12afb46fc5a9ad3a811b05472621bbecccb900c47504feb7f29d96b28421ca bcacbffc36fb3e0c9b26523b5963af0ffa9fd6b19f00a2a31bdb2316071546bd
@@ -584,7 +584,7 @@ lib/codeql/rust/elements/internal/generated/PtrTypeRepr.qll 8d0ea4f6c7f8203340bf
lib/codeql/rust/elements/internal/generated/PureSynthConstructors.qll e5b8e69519012bbaae29dcb82d53f7f7ecce368c0358ec27ef6180b228a0057f e5b8e69519012bbaae29dcb82d53f7f7ecce368c0358ec27ef6180b228a0057f
lib/codeql/rust/elements/internal/generated/RangeExpr.qll 23cca03bf43535f33b22a38894f70d669787be4e4f5b8fe5c8f7b964d30e9027 18624cef6c6b679eeace2a98737e472432e0ead354cca02192b4d45330f047c9
lib/codeql/rust/elements/internal/generated/RangePat.qll 80826a6a6868a803aa2372e31c52a03e1811a3f1f2abdb469f91ca0bfdd9ecb6 34ee1e208c1690cba505dff2c588837c0cd91e185e2a87d1fe673191962276a9
lib/codeql/rust/elements/internal/generated/Raw.qll 11d48da73543efe2d6c4c5a30ac8ecdd3c24dc64bbd10bf6976b53445e248ef1 72fddbec1e8e5029442c962599877459406010d81dece075147aa1cc37cf7a42
lib/codeql/rust/elements/internal/generated/Raw.qll 3f86deef2f54093e3b4bd24237ba0d80fa94856fdcf2ba6a9812033bec6c0021 30cd773ce7a390afbdabd8a078f5f1408671eaca6fa7e213bed6196dfa872447
lib/codeql/rust/elements/internal/generated/RefExpr.qll 7d995884e3dc1c25fc719f5d7253179344d63650e217e9ff6530285fe7a57f64 f2c3c12551deea4964b66553fb9b6423ee16fec53bd63db4796191aa60dc6c66
lib/codeql/rust/elements/internal/generated/RefPat.qll 456ede39837463ee22a630ec7ab6c8630d3664a8ea206fcc6e4f199e92fa564c 5622062765f32930465ba6b170e986706f159f6070f48adee3c20e24e8df4e05
lib/codeql/rust/elements/internal/generated/RefTypeRepr.qll 5b0663a6d234572fb3e467e276d019415caa95ef006438cc59b7af4e1783161e 0e27c8a8f0e323c0e4d6db01fca821bf07c0864d293cdf96fa891b10820c1e4b
@@ -674,7 +674,7 @@ test/extractor-tests/generated/BoxPat/BoxPat.ql 854c9ba4e045dbe7ea1666866c1c443a
test/extractor-tests/generated/BreakExpr/BreakExpr.ql c2181211da3dfe983cfca93ead32d5d211e91181899b9477152c58124eaa846d 57e57b926e14db2efb2e88e04699608b2ba9797ee4f6c4f710135b6858982256
test/extractor-tests/generated/CallExpr/CallExpr.ql 2a1cd4485ccd8d4eb24a75889e832612adef9bb7feae414c90572796380bc6d7 95060b92aa04d7ad1fc6603c5ec14a275a5788ecb5a19932732e28105607a3b7
test/extractor-tests/generated/CastExpr/CastExpr.ql 3480ec51072399409b7553ab6139c832db6ed4ca991f3a7a2282a39afe07c6f2 614c8ea7a2fe30d57583dbf84ed7a12743c2aba49d8c6252d31af3ed10853a39
test/extractor-tests/generated/ClosureExpr/ClosureExpr.ql f9002cc327769edff05ae428d0c01ba80e18a217057d4d2c3a31eb24ab659ed6 8af2986890d0f3dd77c72023d992d5e587c9922b6f3ea378a6e268a51cfbbda5
test/extractor-tests/generated/ClosureExpr/ClosureExpr.ql 675ae07193241fbd710ece4f74f86e9b00f47841299b1c5934f55dbf13a4b4af 21fb0664619c9c889e9491bfd651c2814dcf0f158dd6269937bd0acc18be6b0e
test/extractor-tests/generated/Comment/Comment.ql 0e0454911d2cf2e7ef5c6d860b84c57b9d490090914ebcf4fa0e8a70f777f066 cbd1c195276ef163f8d3c122344738c884dc9fb70eb2f9b7067829d735d48c4c
test/extractor-tests/generated/Const/Const.ql 97797a56743b519c1990682ccb22af6d997ed5eea1e280b52ad31b16a5836f9e e5289ebcb71a25b7ac0a7e1aa0111e4f3ec83d26b7f83e819509c9b9d756921d
test/extractor-tests/generated/ConstArg/ConstArg.ql 21c7caf1939ff9fcc1bf0fe6dec5c6a6929f714cf1e17faf7a2f4a31c910194b 61eac00f4727f7269f926c53f53a62b5fae82ce7a02b42d23b9de6337b6f9d6e
@@ -698,7 +698,7 @@ test/extractor-tests/generated/FormatArgsExpr/FormatArgsArg.ql 5abcb565dcd2822e2
test/extractor-tests/generated/FormatArgsExpr/FormatArgsExpr.ql 243c2f9d830f1eae915749e81ac78d3c140280385b0002d10fcc4d2feaf14711 72b90a99a8b1c16baf1e254e1e3463c3ce5409624a2a90829122717d4e5a2b74
test/extractor-tests/generated/FormatArgsExpr/FormatArgument.ql 0a345eb48dba8e535d12a00e88008e71b3ce692fbf8f9686c8885e158635dffe eab1f230fd572474a3f304f97d05bbf4a004c52773aaf2d34f999192244c0b80
test/extractor-tests/generated/FormatArgsExpr/FormatTemplateVariableAccess.ql 24108cdc54feb77c24bb7894744e36e374f0c03d46d6e6c3fcb2012b1ad117f6 05a6b6f51029ee1a15039aa9d738bb1fd7145148f1aad790198fba832572c719
test/extractor-tests/generated/Function/Function.ql 061b34449c170b0fe50bbf8fe7b47f7ffc30d119c2479b906cb233f4dff9f006 5bc406906ea1537ee8ae299e29a1fbfa197c5920f97ff87f2c82b555c739de82
test/extractor-tests/generated/Function/Function.ql a98895a935f82c61538a93ad981d55a049dfc44eb7f4a28b0b3d611247617518 ed9e9b3d3804e83a40fe3d39888efb308eb2eb9d99c7a1adc5ab821cff2a44c0
test/extractor-tests/generated/GenericArgList/GenericArgList.ql 9bd6873e56a381a693fed0f595d60d973d0073ba7afa303750d5c6a0b887a811 0b373079f65aa91cacabfc9729c91215082a915197eb657b66bcdb3b6d5e7e53
test/extractor-tests/generated/GenericParamList/GenericParamList.ql 206f270690f5c142777d43cf87b65d6dda5ec9f3953c17ee943fe3d0e7b7761c 38a6e0bbca916778f85b106609df6d5929baed006d55811ec0d71c75fe137e92
test/extractor-tests/generated/IdentPat/IdentPat.ql 23006eddf0ca1188e11ba5ee25ad62a83157b83e0b99119bf924c7f74fd8e70d 6e572f48f607f0ced309113304019ccc0a828f6ddd71e818369504dcf832a0b5

View File

@@ -36,8 +36,7 @@ query predicate scopeNoFirst(CfgScope scope) {
Consistency::scopeNoFirst(scope) and
not scope =
[
any(AstNode f | not f.(Function).hasBody()),
any(ClosureExpr c | not c.hasBody()),
any(AstNode f | not f.(Callable).hasBody()),
any(AsyncBlockExpr b | not b.hasStmtList())
]
}

View File

@@ -35,16 +35,7 @@ final class CallableScope extends CfgScopeImpl, Callable {
CallableScope() {
// A function without a body corresponds to a trait method signature and
// should not have a CFG scope.
this.(Function).hasBody()
or
this instanceof ClosureExpr
}
/** Gets the body of this callable. */
AstNode getBody() {
result = this.(Function).getBody()
or
result = this.(ClosureExpr).getBody()
this.hasBody()
}
override predicate scopeFirst(AstNode first) {

View File

@@ -6,6 +6,7 @@
private import internal.CallableImpl
import codeql.rust.elements.AstNode
import codeql.rust.elements.Attr
import codeql.rust.elements.Expr
import codeql.rust.elements.Param
import codeql.rust.elements.ParamList

View File

@@ -29,5 +29,7 @@ module Impl {
*/
class ClosureExpr extends Generated::ClosureExpr {
override string toStringImpl() { result = "|...| " + this.getBody().toAbbreviatedString() }
override Expr getBody() { result = this.getClosureBody() }
}
}

View File

@@ -69,5 +69,7 @@ module Impl {
this.getLocation().getStartLine() <= result.getLocation().getStartLine() and
result.getLocation().getStartLine() <= this.getName().getLocation().getStartLine()
}
override BlockExpr getBody() { result = this.getFunctionBody() }
}
}

View File

@@ -309,7 +309,7 @@ module Impl {
private predicate parameterDeclInScope(Variable v, VariableScope scope) {
exists(Callable f |
v.getParameter() = f.getParamList().getAParamBase() and
scope = [f.(Function).getBody(), f.(ClosureExpr).getBody()]
scope = f.getBody()
)
}

View File

@@ -8,6 +8,7 @@ private import codeql.rust.elements.internal.generated.Synth
private import codeql.rust.elements.internal.generated.Raw
import codeql.rust.elements.internal.AstNodeImpl::Impl as AstNodeImpl
import codeql.rust.elements.Attr
import codeql.rust.elements.Expr
import codeql.rust.elements.Param
import codeql.rust.elements.ParamList
@@ -69,5 +70,15 @@ module Generated {
* Gets the number of parameters of this callable.
*/
final int getNumberOfParams() { result = count(int i | exists(this.getParam(i))) }
/**
* Gets the body of this callable, if it exists.
*/
Expr getBody() { none() }
/**
* Holds if `getBody()` exists.
*/
final predicate hasBody() { exists(this.getBody()) }
}
}

View File

@@ -38,17 +38,19 @@ module Generated {
override string getAPrimaryQlClass() { result = "ClosureExpr" }
/**
* Gets the body of this closure expression, if it exists.
* Gets the closure body of this closure expression, if it exists.
*/
Expr getBody() {
Expr getClosureBody() {
result =
Synth::convertExprFromRaw(Synth::convertClosureExprToRaw(this).(Raw::ClosureExpr).getBody())
Synth::convertExprFromRaw(Synth::convertClosureExprToRaw(this)
.(Raw::ClosureExpr)
.getClosureBody())
}
/**
* Holds if `getBody()` exists.
* Holds if `getClosureBody()` exists.
*/
final predicate hasBody() { exists(this.getBody()) }
final predicate hasClosureBody() { exists(this.getClosureBody()) }
/**
* Gets the for binder of this closure expression, if it exists.

View File

@@ -54,17 +54,19 @@ module Generated {
final predicate hasAbi() { exists(this.getAbi()) }
/**
* Gets the body of this function, if it exists.
* Gets the function body of this function, if it exists.
*/
BlockExpr getBody() {
BlockExpr getFunctionBody() {
result =
Synth::convertBlockExprFromRaw(Synth::convertFunctionToRaw(this).(Raw::Function).getBody())
Synth::convertBlockExprFromRaw(Synth::convertFunctionToRaw(this)
.(Raw::Function)
.getFunctionBody())
}
/**
* Holds if `getBody()` exists.
* Holds if `getFunctionBody()` exists.
*/
final predicate hasBody() { exists(this.getBody()) }
final predicate hasFunctionBody() { exists(this.getFunctionBody()) }
/**
* Gets the generic parameter list of this function, if it exists.

View File

@@ -1092,12 +1092,12 @@ private module Impl {
private Element getImmediateChildOfClosureExpr(
ClosureExpr e, int index, string partialPredicateCall
) {
exists(int n, int nParamList, int nAttr, int nBody, int nForBinder, int nRetType |
exists(int n, int nParamList, int nAttr, int nClosureBody, int nForBinder, int nRetType |
n = 0 and
nParamList = n + 1 and
nAttr = nParamList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and
nBody = nAttr + 1 and
nForBinder = nBody + 1 and
nClosureBody = nAttr + 1 and
nForBinder = nClosureBody + 1 and
nRetType = nForBinder + 1 and
(
none()
@@ -1107,9 +1107,9 @@ private module Impl {
result = e.getAttr(index - nParamList) and
partialPredicateCall = "Attr(" + (index - nParamList).toString() + ")"
or
index = nAttr and result = e.getBody() and partialPredicateCall = "Body()"
index = nAttr and result = e.getClosureBody() and partialPredicateCall = "ClosureBody()"
or
index = nBody and result = e.getForBinder() and partialPredicateCall = "ForBinder()"
index = nClosureBody and result = e.getForBinder() and partialPredicateCall = "ForBinder()"
or
index = nForBinder and result = e.getRetType() and partialPredicateCall = "RetType()"
)
@@ -2729,7 +2729,7 @@ private module Impl {
private Element getImmediateChildOfFunction(Function e, int index, string partialPredicateCall) {
exists(
int n, int nAttributeMacroExpansion, int nParamList, int nAttr, int nAbi, int nBody,
int n, int nAttributeMacroExpansion, int nParamList, int nAttr, int nAbi, int nFunctionBody,
int nGenericParamList, int nName, int nRetType, int nVisibility, int nWhereClause
|
n = 0 and
@@ -2737,8 +2737,8 @@ private module Impl {
nParamList = nAttributeMacroExpansion + 1 and
nAttr = nParamList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and
nAbi = nAttr + 1 and
nBody = nAbi + 1 and
nGenericParamList = nBody + 1 and
nFunctionBody = nAbi + 1 and
nGenericParamList = nFunctionBody + 1 and
nName = nGenericParamList + 1 and
nRetType = nName + 1 and
nVisibility = nRetType + 1 and
@@ -2759,9 +2759,9 @@ private module Impl {
or
index = nAttr and result = e.getAbi() and partialPredicateCall = "Abi()"
or
index = nAbi and result = e.getBody() and partialPredicateCall = "Body()"
index = nAbi and result = e.getFunctionBody() and partialPredicateCall = "FunctionBody()"
or
index = nBody and
index = nFunctionBody and
result = e.getGenericParamList() and
partialPredicateCall = "GenericParamList()"
or

View File

@@ -1906,9 +1906,9 @@ module Raw {
override string toString() { result = "ClosureExpr" }
/**
* Gets the body of this closure expression, if it exists.
* Gets the closure body of this closure expression, if it exists.
*/
Expr getBody() { closure_expr_bodies(this, result) }
Expr getClosureBody() { closure_expr_closure_bodies(this, result) }
/**
* Gets the for binder of this closure expression, if it exists.
@@ -4353,9 +4353,9 @@ module Raw {
Abi getAbi() { function_abis(this, result) }
/**
* Gets the body of this function, if it exists.
* Gets the function body of this function, if it exists.
*/
BlockExpr getBody() { function_bodies(this, result) }
BlockExpr getFunctionBody() { function_function_bodies(this, result) }
/**
* Gets the generic parameter list of this function, if it exists.

View File

@@ -279,7 +279,7 @@ private TypeMention getTypeAnnotation(AstNode n) {
or
exists(Function f |
result = f.getRetType().getTypeRepr() and
n = f.getBody()
n = f.getFunctionBody()
)
}
@@ -630,7 +630,7 @@ private predicate typeEquality(AstNode n1, TypePath prefix1, AstNode n2, TypePat
prefix2.isEmpty()
)
or
n1.(ClosureExpr).getBody() = n2 and
n1.(ClosureExpr).getClosureBody() = n2 and
prefix1 = closureReturnPath() and
prefix2.isEmpty()
}
@@ -2962,7 +2962,7 @@ private Type inferClosureExprType(AstNode n, TypePath path) {
result = TTuple(ce.getNumberOfParams())
or
// Propagate return type annotation to body
n = ce.getBody() and
n = ce.getClosureBody() and
result = ce.getRetType().getTypeRepr().(TypeMention).resolveTypeAt(path)
)
}

View File

@@ -1526,9 +1526,9 @@ closure_exprs(
);
#keyset[id]
closure_expr_bodies(
closure_expr_closure_bodies(
int id: @closure_expr ref,
int body: @expr ref
int closure_body: @expr ref
);
#keyset[id]
@@ -3308,9 +3308,9 @@ function_abis(
);
#keyset[id]
function_bodies(
function_function_bodies(
int id: @function ref,
int body: @block_expr ref
int function_body: @block_expr ref
);
#keyset[id]

View File

@@ -30,6 +30,13 @@ getBody
| gen_closure_expr.rs:8:5:9:15 | \|...\| ... | gen_closure_expr.rs:9:9:9:15 | YieldExpr |
| gen_closure_expr.rs:10:5:11:22 | \|...\| ... | gen_closure_expr.rs:11:16:11:22 | YieldExpr |
| gen_closure_expr.rs:12:5:14:5 | \|...\| ... | gen_closure_expr.rs:12:36:14:5 | { ... } |
getClosureBody
| gen_closure_expr.rs:5:5:5:13 | \|...\| ... | gen_closure_expr.rs:5:9:5:13 | ... + ... |
| gen_closure_expr.rs:6:5:6:34 | \|...\| ... | gen_closure_expr.rs:6:26:6:34 | { ... } |
| gen_closure_expr.rs:7:5:7:27 | \|...\| ... | gen_closure_expr.rs:7:23:7:27 | ... + ... |
| gen_closure_expr.rs:8:5:9:15 | \|...\| ... | gen_closure_expr.rs:9:9:9:15 | YieldExpr |
| gen_closure_expr.rs:10:5:11:22 | \|...\| ... | gen_closure_expr.rs:11:16:11:22 | YieldExpr |
| gen_closure_expr.rs:12:5:14:5 | \|...\| ... | gen_closure_expr.rs:12:36:14:5 | { ... } |
getForBinder
| gen_closure_expr.rs:12:5:14:5 | \|...\| ... | gen_closure_expr.rs:12:5:12:27 | for<...> |
getRetType

View File

@@ -37,6 +37,10 @@ query predicate getBody(ClosureExpr x, Expr getBody) {
toBeTested(x) and not x.isUnknown() and getBody = x.getBody()
}
query predicate getClosureBody(ClosureExpr x, Expr getClosureBody) {
toBeTested(x) and not x.isUnknown() and getClosureBody = x.getClosureBody()
}
query predicate getForBinder(ClosureExpr x, ForBinder getForBinder) {
toBeTested(x) and not x.isUnknown() and getForBinder = x.getForBinder()
}

View File

@@ -8,9 +8,11 @@ getParamList
getAttr
getParam
| gen_function.rs:3:1:4:38 | fn foo | 0 | gen_function.rs:4:8:4:13 | ...: u32 |
getAbi
getBody
| gen_function.rs:3:1:4:38 | fn foo | gen_function.rs:4:23:4:38 | { ... } |
getAbi
getFunctionBody
| gen_function.rs:3:1:4:38 | fn foo | gen_function.rs:4:23:4:38 | { ... } |
getGenericParamList
getName
| gen_function.rs:3:1:4:38 | fn foo | gen_function.rs:4:4:4:6 | foo |

View File

@@ -41,12 +41,16 @@ query predicate getParam(Function x, int index, Param getParam) {
toBeTested(x) and not x.isUnknown() and getParam = x.getParam(index)
}
query predicate getBody(Function x, Expr getBody) {
toBeTested(x) and not x.isUnknown() and getBody = x.getBody()
}
query predicate getAbi(Function x, Abi getAbi) {
toBeTested(x) and not x.isUnknown() and getAbi = x.getAbi()
}
query predicate getBody(Function x, BlockExpr getBody) {
toBeTested(x) and not x.isUnknown() and getBody = x.getBody()
query predicate getFunctionBody(Function x, BlockExpr getFunctionBody) {
toBeTested(x) and not x.isUnknown() and getFunctionBody = x.getFunctionBody()
}
query predicate getGenericParamList(Function x, GenericParamList getGenericParamList) {

View File

@@ -10,7 +10,7 @@ call.rs:
# 1| getIdentifier(): [NameRef] macro_expansion
# 3| getItem(1): [Function] fn call_some_functions
# 3| getParamList(): [ParamList] ParamList
# 3| getBody(): [BlockExpr] { ... }
# 3| getFunctionBody(): [BlockExpr] { ... }
# 3| getStmtList(): [StmtList] StmtList
# 4| getStatement(0): [ExprStmt] ExprStmt
# 4| getExpr(): [CallExpr] ...::foo(...)
@@ -129,7 +129,7 @@ included/included.rs:
# 1| [SourceFile] SourceFile
# 1| getItem(0): [Function] fn included
# 1| getParamList(): [ParamList] ParamList
# 1| getBody(): [BlockExpr] { ... }
# 1| getFunctionBody(): [BlockExpr] { ... }
# 1| getStmtList(): [StmtList] StmtList
# 2| getStatement(0): [ExprStmt] ExprStmt
# 2| getExpr(): [AssignmentExpr] ... = ...
@@ -178,7 +178,7 @@ macro_expansion.rs:
# 4| getAttributeMacroExpansion(): [MacroItems] MacroItems
# 4| getItem(0): [Function] fn foo
# 4| getParamList(): [ParamList] ParamList
# 4| getBody(): [BlockExpr] { ... }
# 4| getFunctionBody(): [BlockExpr] { ... }
# 4| getStmtList(): [StmtList] StmtList
# 5| getStatement(0): [ExprStmt] ExprStmt
# 5| getExpr(): [AssignmentExpr] ... = ...
@@ -194,12 +194,12 @@ macro_expansion.rs:
# 8| getAttributeMacroExpansion(): [MacroItems] MacroItems
# 8| getItem(0): [Function] fn inner_0
# 8| getParamList(): [ParamList] ParamList
# 8| getBody(): [BlockExpr] { ... }
# 8| getFunctionBody(): [BlockExpr] { ... }
# 8| getStmtList(): [StmtList] StmtList
# 8| getName(): [Name] inner_0
# 8| getItem(1): [Function] fn inner_1
# 8| getParamList(): [ParamList] ParamList
# 8| getBody(): [BlockExpr] { ... }
# 8| getFunctionBody(): [BlockExpr] { ... }
# 8| getStmtList(): [StmtList] StmtList
# 8| getName(): [Name] inner_1
# 8| getParamList(): [ParamList] ParamList
@@ -209,7 +209,7 @@ macro_expansion.rs:
# 7| getSegment(): [PathSegment] repeat
# 7| getIdentifier(): [NameRef] repeat
# 7| getTokenTree(): [TokenTree] TokenTree
# 8| getBody(): [BlockExpr] { ... }
# 8| getFunctionBody(): [BlockExpr] { ... }
# 8| getStmtList(): [StmtList] StmtList
# 8| getName(): [Name] inner
# 10| getStatement(2): [ExprStmt] ExprStmt
@@ -230,7 +230,7 @@ macro_expansion.rs:
# 4| getVisibility(): [Visibility] Visibility
# 4| getItem(1): [Function] fn foo_new
# 4| getParamList(): [ParamList] ParamList
# 4| getBody(): [BlockExpr] { ... }
# 4| getFunctionBody(): [BlockExpr] { ... }
# 4| getStmtList(): [StmtList] StmtList
# 5| getStatement(0): [ExprStmt] ExprStmt
# 5| getExpr(): [AssignmentExpr] ... = ...
@@ -246,12 +246,12 @@ macro_expansion.rs:
# 8| getAttributeMacroExpansion(): [MacroItems] MacroItems
# 8| getItem(0): [Function] fn inner_0
# 8| getParamList(): [ParamList] ParamList
# 8| getBody(): [BlockExpr] { ... }
# 8| getFunctionBody(): [BlockExpr] { ... }
# 8| getStmtList(): [StmtList] StmtList
# 8| getName(): [Name] inner_0
# 8| getItem(1): [Function] fn inner_1
# 8| getParamList(): [ParamList] ParamList
# 8| getBody(): [BlockExpr] { ... }
# 8| getFunctionBody(): [BlockExpr] { ... }
# 8| getStmtList(): [StmtList] StmtList
# 8| getName(): [Name] inner_1
# 8| getParamList(): [ParamList] ParamList
@@ -261,7 +261,7 @@ macro_expansion.rs:
# 7| getSegment(): [PathSegment] repeat
# 7| getIdentifier(): [NameRef] repeat
# 7| getTokenTree(): [TokenTree] TokenTree
# 8| getBody(): [BlockExpr] { ... }
# 8| getFunctionBody(): [BlockExpr] { ... }
# 8| getStmtList(): [StmtList] StmtList
# 8| getName(): [Name] inner
# 10| getStatement(2): [ExprStmt] ExprStmt
@@ -286,7 +286,7 @@ macro_expansion.rs:
# 3| getPath(): [Path] add_one
# 3| getSegment(): [PathSegment] add_one
# 3| getIdentifier(): [NameRef] add_one
# 4| getBody(): [BlockExpr] { ... }
# 4| getFunctionBody(): [BlockExpr] { ... }
# 4| getStmtList(): [StmtList] StmtList
# 5| getStatement(0): [ExprStmt] ExprStmt
# 5| getExpr(): [AssignmentExpr] ... = ...
@@ -305,7 +305,7 @@ macro_expansion.rs:
# 7| getSegment(): [PathSegment] repeat
# 7| getIdentifier(): [NameRef] repeat
# 7| getTokenTree(): [TokenTree] TokenTree
# 8| getBody(): [BlockExpr] { ... }
# 8| getFunctionBody(): [BlockExpr] { ... }
# 8| getStmtList(): [StmtList] StmtList
# 8| getName(): [Name] inner
# 10| getStatement(2): [ExprStmt] ExprStmt
@@ -330,13 +330,13 @@ macro_expansion.rs:
# 16| getAttributeMacroExpansion(): [MacroItems] MacroItems
# 16| getItem(0): [Function] fn bar_0
# 16| getParamList(): [ParamList] ParamList
# 16| getBody(): [BlockExpr] { ... }
# 16| getFunctionBody(): [BlockExpr] { ... }
# 16| getStmtList(): [StmtList] StmtList
# 16| getName(): [Name] bar_0
# 16| getVisibility(): [Visibility] Visibility
# 16| getItem(1): [Function] fn bar_0_new
# 16| getParamList(): [ParamList] ParamList
# 16| getBody(): [BlockExpr] { ... }
# 16| getFunctionBody(): [BlockExpr] { ... }
# 16| getStmtList(): [StmtList] StmtList
# 16| getName(): [Name] bar_0_new
# 16| getVisibility(): [Visibility] Visibility
@@ -346,7 +346,7 @@ macro_expansion.rs:
# 15| getPath(): [Path] add_one
# 15| getSegment(): [PathSegment] add_one
# 15| getIdentifier(): [NameRef] add_one
# 16| getBody(): [BlockExpr] { ... }
# 16| getFunctionBody(): [BlockExpr] { ... }
# 16| getStmtList(): [StmtList] StmtList
# 16| getName(): [Name] bar_0
# 16| getVisibility(): [Visibility] Visibility
@@ -354,13 +354,13 @@ macro_expansion.rs:
# 16| getAttributeMacroExpansion(): [MacroItems] MacroItems
# 16| getItem(0): [Function] fn bar_1
# 16| getParamList(): [ParamList] ParamList
# 16| getBody(): [BlockExpr] { ... }
# 16| getFunctionBody(): [BlockExpr] { ... }
# 16| getStmtList(): [StmtList] StmtList
# 16| getName(): [Name] bar_1
# 16| getVisibility(): [Visibility] Visibility
# 16| getItem(1): [Function] fn bar_1_new
# 16| getParamList(): [ParamList] ParamList
# 16| getBody(): [BlockExpr] { ... }
# 16| getFunctionBody(): [BlockExpr] { ... }
# 16| getStmtList(): [StmtList] StmtList
# 16| getName(): [Name] bar_1_new
# 16| getVisibility(): [Visibility] Visibility
@@ -370,7 +370,7 @@ macro_expansion.rs:
# 15| getPath(): [Path] add_one
# 15| getSegment(): [PathSegment] add_one
# 15| getIdentifier(): [NameRef] add_one
# 16| getBody(): [BlockExpr] { ... }
# 16| getFunctionBody(): [BlockExpr] { ... }
# 16| getStmtList(): [StmtList] StmtList
# 16| getName(): [Name] bar_1
# 16| getVisibility(): [Visibility] Visibility
@@ -386,7 +386,7 @@ macro_expansion.rs:
# 15| getPath(): [Path] add_one
# 15| getSegment(): [PathSegment] add_one
# 15| getIdentifier(): [NameRef] add_one
# 16| getBody(): [BlockExpr] { ... }
# 16| getFunctionBody(): [BlockExpr] { ... }
# 16| getStmtList(): [StmtList] StmtList
# 16| getName(): [Name] bar
# 16| getVisibility(): [Visibility] Visibility
@@ -398,7 +398,7 @@ macro_expansion.rs:
# 18| getPath(): [Path] erase
# 18| getSegment(): [PathSegment] erase
# 18| getIdentifier(): [NameRef] erase
# 19| getBody(): [BlockExpr] { ... }
# 19| getFunctionBody(): [BlockExpr] { ... }
# 19| getStmtList(): [StmtList] StmtList
# 19| getName(): [Name] baz
# 19| getVisibility(): [Visibility] Visibility
@@ -414,7 +414,7 @@ macro_expansion.rs:
# 32| getAttributeMacroExpansion(): [MacroItems] MacroItems
# 32| getItem(0): [Function] fn bzz_0
# 32| getParamList(): [ParamList] ParamList
# 32| getBody(): [BlockExpr] { ... }
# 32| getFunctionBody(): [BlockExpr] { ... }
# 32| getStmtList(): [StmtList] StmtList
# 33| getStatement(0): [ExprStmt] ExprStmt
# 33| getExpr(): [MacroExpr] MacroExpr
@@ -462,7 +462,7 @@ macro_expansion.rs:
# 32| getVisibility(): [Visibility] Visibility
# 32| getItem(1): [Function] fn bzz_1
# 32| getParamList(): [ParamList] ParamList
# 32| getBody(): [BlockExpr] { ... }
# 32| getFunctionBody(): [BlockExpr] { ... }
# 32| getStmtList(): [StmtList] StmtList
# 33| getStatement(0): [ExprStmt] ExprStmt
# 33| getExpr(): [MacroExpr] MacroExpr
@@ -510,7 +510,7 @@ macro_expansion.rs:
# 32| getVisibility(): [Visibility] Visibility
# 32| getItem(2): [Function] fn bzz_2
# 32| getParamList(): [ParamList] ParamList
# 32| getBody(): [BlockExpr] { ... }
# 32| getFunctionBody(): [BlockExpr] { ... }
# 32| getStmtList(): [StmtList] StmtList
# 33| getStatement(0): [ExprStmt] ExprStmt
# 33| getExpr(): [MacroExpr] MacroExpr
@@ -563,7 +563,7 @@ macro_expansion.rs:
# 31| getSegment(): [PathSegment] repeat
# 31| getIdentifier(): [NameRef] repeat
# 31| getTokenTree(): [TokenTree] TokenTree
# 32| getBody(): [BlockExpr] { ... }
# 32| getFunctionBody(): [BlockExpr] { ... }
# 32| getStmtList(): [StmtList] StmtList
# 33| getStatement(0): [ExprStmt] ExprStmt
# 33| getExpr(): [MacroExpr] MacroExpr
@@ -591,7 +591,7 @@ macro_expansion.rs:
# 44| getMacroCallExpansion(): [MacroItems] MacroItems
# 44| getItem(0): [Function] fn x
# 44| getParamList(): [ParamList] ParamList
# 44| getBody(): [BlockExpr] { ... }
# 44| getFunctionBody(): [BlockExpr] { ... }
# 44| getStmtList(): [StmtList] StmtList
# 44| getName(): [Name] x
# 44| getVisibility(): [Visibility] Visibility
@@ -604,7 +604,7 @@ macro_expansion.rs:
# 47| getTokenTree(): [TokenTree] TokenTree
# 52| getItem(10): [Function] fn test
# 52| getParamList(): [ParamList] ParamList
# 52| getBody(): [BlockExpr] { ... }
# 52| getFunctionBody(): [BlockExpr] { ... }
# 52| getStmtList(): [StmtList] StmtList
# 53| getStatement(0): [ExprStmt] ExprStmt
# 53| getExpr(): [AssignmentExpr] ... = ...
@@ -688,7 +688,7 @@ macro_expansion.rs:
# 61| getMacroCallExpansion(): [MacroItems] MacroItems
# 61| getItem(0): [Function] fn included
# 61| getParamList(): [ParamList] ParamList
# 61| getBody(): [BlockExpr] { ... }
# 61| getFunctionBody(): [BlockExpr] { ... }
# 61| getStmtList(): [StmtList] StmtList
# 61| getStatement(0): [ExprStmt] ExprStmt
# 61| getExpr(): [AssignmentExpr] ... = ...
@@ -714,7 +714,7 @@ macro_expansion.rs:
# 63| getPath(): [Path] doc
# 63| getSegment(): [PathSegment] doc
# 63| getIdentifier(): [NameRef] doc
# 64| getBody(): [BlockExpr] { ... }
# 64| getFunctionBody(): [BlockExpr] { ... }
# 64| getStmtList(): [StmtList] StmtList
# 64| getName(): [Name] documented
# 66| getItem(13): [MacroRules] MacroRules
@@ -722,7 +722,7 @@ macro_expansion.rs:
# 66| getTokenTree(): [TokenTree] TokenTree
# 70| getItem(14): [Function] fn answer
# 70| getParamList(): [ParamList] ParamList
# 70| getBody(): [BlockExpr] { ... }
# 70| getFunctionBody(): [BlockExpr] { ... }
# 70| getStmtList(): [StmtList] StmtList
# 71| getStatement(0): [LetStmt] let ... = 42
# 71| getInitializer(): [IntegerLiteralExpr] 42
@@ -814,7 +814,7 @@ macro_expansion.rs:
# 83| getName(): [Name] f
# 83| getSelfParam(): [SelfParam] SelfParam
# 83| getName(): [Name] self
# 84| getBody(): [BlockExpr] { ... }
# 84| getFunctionBody(): [BlockExpr] { ... }
# 84| getStmtList(): [StmtList] StmtList
# 84| getTailExpr(): [MatchExpr] match self { ... }
# 83| getScrutinee(): [PathExpr,VariableAccess] self
@@ -911,7 +911,7 @@ macro_expansion.rs:
# 88| getName(): [Name] other
# 88| getSelfParam(): [SelfParam] SelfParam
# 88| getName(): [Name] self
# 89| getBody(): [BlockExpr] { ... }
# 89| getFunctionBody(): [BlockExpr] { ... }
# 89| getStmtList(): [StmtList] StmtList
# 89| getTailExpr(): [MatchExpr] match ... { ... }
# 88| getScrutinee(): [TupleExpr] TupleExpr
@@ -1041,7 +1041,7 @@ macro_expansion.rs:
# 99| getAssocItemList(): [AssocItemList] AssocItemList
# 99| getAssocItem(0): [Function] fn my_method
# 98| getParamList(): [ParamList] ParamList
# 99| getBody(): [BlockExpr] { ... }
# 99| getFunctionBody(): [BlockExpr] { ... }
# 99| getStmtList(): [StmtList] StmtList
# 99| getTailExpr(): [PathExpr] CONST_MyDeriveUnion
# 99| getPath(): [Path] CONST_MyDeriveUnion
@@ -1128,7 +1128,7 @@ proc_macro.rs:
# 4| getPath(): [Path] proc_macro_attribute
# 4| getSegment(): [PathSegment] proc_macro_attribute
# 4| getIdentifier(): [NameRef] proc_macro_attribute
# 5| getBody(): [BlockExpr] { ... }
# 5| getFunctionBody(): [BlockExpr] { ... }
# 5| getStmtList(): [StmtList] StmtList
# 6| getStatement(0): [LetStmt] let ... = ...
# 6| getInitializer(): [MethodCallExpr] ... .unwrap()
@@ -1346,7 +1346,7 @@ proc_macro.rs:
# 9| getParam(0): [Param] ...
# 9| getPat(): [IdentPat] i
# 9| getName(): [Name] i
# 9| getBody(): [BlockExpr] { ... }
# 9| getClosureBody(): [BlockExpr] { ... }
# 9| getStmtList(): [StmtList] StmtList
# 10| getStatement(0): [LetStmt] let ... = ...
# 10| getInitializer(): [MethodCallExpr] ast.clone()
@@ -2104,7 +2104,7 @@ proc_macro.rs:
# 20| getPath(): [Path] proc_macro_attribute
# 20| getSegment(): [PathSegment] proc_macro_attribute
# 20| getIdentifier(): [NameRef] proc_macro_attribute
# 21| getBody(): [BlockExpr] { ... }
# 21| getFunctionBody(): [BlockExpr] { ... }
# 21| getStmtList(): [StmtList] StmtList
# 22| getStatement(0): [LetStmt] let ... = ...
# 22| getInitializer(): [MacroExpr] MacroExpr
@@ -2535,7 +2535,7 @@ proc_macro.rs:
# 31| getPath(): [Path] proc_macro_attribute
# 31| getSegment(): [PathSegment] proc_macro_attribute
# 31| getIdentifier(): [NameRef] proc_macro_attribute
# 32| getBody(): [BlockExpr] { ... }
# 32| getFunctionBody(): [BlockExpr] { ... }
# 32| getStmtList(): [StmtList] StmtList
# 33| getTailExpr(): [CallExpr] ...::new(...)
# 33| getArgList(): [ArgList] ArgList
@@ -2568,7 +2568,7 @@ proc_macro.rs:
# 36| getSegment(): [PathSegment] proc_macro_derive
# 36| getIdentifier(): [NameRef] proc_macro_derive
# 36| getTokenTree(): [TokenTree] TokenTree
# 37| getBody(): [BlockExpr] { ... }
# 37| getFunctionBody(): [BlockExpr] { ... }
# 37| getStmtList(): [StmtList] StmtList
# 38| getStatement(0): [LetStmt] let ... = ...
# 38| getInitializer(): [MacroExpr] MacroExpr

4
rust/schema/ast.py generated
View File

@@ -164,7 +164,7 @@ class CastExpr(Expr, ):
class ClosureExpr(Expr, ):
attrs: list["Attr"] | child
body: optional["Expr"] | child
closure_body: optional["Expr"] | child
for_binder: optional["ForBinder"] | child
is_async: predicate
is_const: predicate
@@ -241,7 +241,7 @@ class FieldExpr(Expr, ):
class Function(AssocItem, ExternItem, Item, ):
abi: optional["Abi"] | child
attrs: list["Attr"] | child
body: optional["BlockExpr"] | child
function_body: optional["BlockExpr"] | child
generic_param_list: optional["GenericParamList"] | child
is_async: predicate
is_const: predicate

View File

@@ -74,6 +74,7 @@ class Callable(AstNode):
param_list: optional["ParamList"] | child
attrs: list["Attr"] | child
params: list["Param"] | synth
body: optional["Expr"] | synth
class Addressable(AstNode):