Merge pull request #19649 from github/redsun82/rust-has-implementation

Rust: extract `hasImplementation` on functions and consts
This commit is contained in:
Paolo Tranquilli
2025-06-12 15:19:23 +00:00
committed by GitHub
20 changed files with 14566 additions and 18 deletions

View File

@@ -63,8 +63,8 @@ pub struct {{name}} {
impl {{name}} {
{{#detached_fields}}
pub fn emit_{{singular_field_name}}(id: trap::Label<Self>, {{#is_repeated}}{{^is_unordered}}i: usize, {{/is_unordered}}{{/is_repeated}}value: {{base_type}}, out: &mut trap::Writer) {
out.add_tuple("{{table_name}}", vec![id.into(), {{#is_repeated}}{{^is_unordered}}i.into(), {{/is_unordered}}{{/is_repeated}}value.into()]);
pub fn emit_{{singular_field_name}}(id: trap::Label<Self>{{^is_predicate}}{{#is_repeated}}{{^is_unordered}}, i: usize{{/is_unordered}}{{/is_repeated}}, value: {{base_type}}{{/is_predicate}}, out: &mut trap::Writer) {
out.add_tuple("{{table_name}}", vec![id.into(){{^is_predicate}}{{#is_repeated}}{{^is_unordered}}, i.into(){{/is_unordered}}{{/is_repeated}}, value.into(){{/is_predicate}}]);
}
{{/detached_fields}}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
description: Remove `function_has_implementation` and `const_has_implementation` tables
compatibility: full
function_has_implementation.rel: delete
const_has_implementation.rel: delete

View File

@@ -1,2 +1,2 @@
mod.rs 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7
top.rs 7f8a694078bc0cde1ce420544d0cf5b83bb297dd29ee4f9d7bcbb1572f0e815a 7f8a694078bc0cde1ce420544d0cf5b83bb297dd29ee4f9d7bcbb1572f0e815a
top.rs 69c1fcaf0efea87feb898f32fdb7bcb842a22119b69ecedd61c2d946eb7e67de 69c1fcaf0efea87feb898f32fdb7bcb842a22119b69ecedd61c2d946eb7e67de

View File

@@ -9084,6 +9084,12 @@ impl trap::TrapEntry for Const {
}
}
impl Const {
pub fn emit_has_implementation(id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("const_has_implementation", vec![id.into()]);
}
}
impl trap::TrapClass for Const {
fn class_name() -> &'static str { "Const" }
}
@@ -9497,6 +9503,12 @@ impl trap::TrapEntry for Function {
}
}
impl Function {
pub fn emit_has_implementation(id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("function_has_implementation", vec![id.into()]);
}
}
impl trap::TrapClass for Function {
fn class_name() -> &'static str { "Function" }
}

View File

@@ -38,6 +38,7 @@ macro_rules! post_emit {
$self.extract_macro_call_expanded($node, $label);
};
(Function, $self:ident, $node:ident, $label:ident) => {
$self.emit_function_has_implementation($node, $label);
$self.extract_canonical_origin($node, $label.into());
};
(Trait, $self:ident, $node:ident, $label:ident) => {
@@ -83,6 +84,9 @@ macro_rules! post_emit {
(PathSegment, $self:ident, $node:ident, $label:ident) => {
$self.extract_types_from_path_segment($node, $label.into());
};
(Const, $self:ident, $node:ident, $label:ident) => {
$self.emit_const_has_implementation($node, $label);
};
($($_:tt)*) => {};
}
@@ -761,4 +765,24 @@ impl<'a> Translator<'a> {
generated::Item::emit_attribute_macro_expansion(label, expanded, &mut self.trap.writer);
}
}
pub(crate) fn emit_function_has_implementation(
&mut self,
node: &ast::Fn,
label: Label<generated::Function>,
) {
if node.body().is_some() {
generated::Function::emit_has_implementation(label, &mut self.trap.writer);
}
}
pub(crate) fn emit_const_has_implementation(
&mut self,
node: &ast::Const,
label: Label<generated::Const>,
) {
if node.body().is_some() {
generated::Const::emit_has_implementation(label, &mut self.trap.writer);
}
}
}

View File

@@ -497,7 +497,7 @@ lib/codeql/rust/elements/internal/generated/CastExpr.qll ddc20054b0b339ad4d40298
lib/codeql/rust/elements/internal/generated/ClosureBinder.qll ab199df96f525a083a0762fd654cd098802033c79700a593bb204a9a0c69ec01 86b33543e0886715830cfcdaca43b555a242a4f12a4caa18b88732d5afb584bd
lib/codeql/rust/elements/internal/generated/ClosureExpr.qll 34149bf82f107591e65738221e1407ec1dc9cc0dfb10ae7f761116fda45162de fd2fbc9a87fc0773c940db64013cf784d5e4137515cc1020e2076da329f5a952
lib/codeql/rust/elements/internal/generated/Comment.qll cd1ef861e3803618f9f78a4ac00516d50ecfecdca1c1d14304dc5327cbe07a3b 8b67345aeb15beb5895212228761ea3496297846c93fd2127b417406ae87c201
lib/codeql/rust/elements/internal/generated/Const.qll ab494351d5807321114620194c54ebf6b5bacf322b710edf7558b3ee092967ae 057d6a13b6a479bd69a2f291a6718a97747a20f517b16060223a412bbadc6083
lib/codeql/rust/elements/internal/generated/Const.qll 6300d7150d03f6bc2f0b29bb7d4a7bc1381c377644b0c61860733be685bac646 f5299a799a33fa28ca5b6d198f43a80696556144236df39124784211a1ad8285
lib/codeql/rust/elements/internal/generated/ConstArg.qll c52bf746f2dc89b8d71b8419736707bfcbb09cca424c3ba76e888e2add415bf6 89309a9df4fde23cfd3d8492908ccec4d90cc8457d35c507ef81371a369941b4
lib/codeql/rust/elements/internal/generated/ConstBlockPat.qll 7526d83ee9565d74776f42db58b1a2efff6fb324cfc7137f51f2206fee815d79 0ab3c22908ff790e7092e576a5df3837db33c32a7922a513a0f5e495729c1ac5
lib/codeql/rust/elements/internal/generated/ConstParam.qll 2e24198f636e4932c79f28c324f395ae5f61f713795ed4543e920913898e2815 5abe6d3df395c679c28a7720479bad455c53bc5ade9133f1ff113ea54dc66c11
@@ -523,7 +523,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 6c04fffdc9de54cd01ff76f93aef5fcd3f2f779a2735523c9b1a859d394cefc9 af3c0f05c05ecd74560ab7b128a4a8e9822aa3cb80eddf304d51ea44725ac706
lib/codeql/rust/elements/internal/generated/Function.qll befc4220bef166531e52625b08642f129115ae918a70021d69874dc794e41be7 e6433f67000eb5f3e02b209d7ee8018fea30abed9e7c491fa1fbbd9d998e98ae
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
@@ -577,7 +577,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 794df100370be92e8537c2b90431d02558c4eeb783c68ffdc7fc6445629acae2 61cf70eb649f241e2fcd5e0ba34df63f3a14f07032811b9ae151721783a0fd20
lib/codeql/rust/elements/internal/generated/ParentChild.qll 5278b74de04d54708f078fd813d83ae5f934fa12d420b188c1334e3a7c3b8324 61cf70eb649f241e2fcd5e0ba34df63f3a14f07032811b9ae151721783a0fd20
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
@@ -592,7 +592,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 55ec0031a67964805e9dfb8d3190385e101178d1bcce1c4efd53d8f58d1cf0be d34faae700e7c2cb9e6eb2183244ff900a270c761676491d3ffe6a939903edd7
lib/codeql/rust/elements/internal/generated/Raw.qll b6e439cc24f8c02fe73301cd2bc16d59dfd28e2a8a201388d8318c43937309e2 62139c3df2f6c4dca1c897b1384233ff0151b7e5fb1c41a178c5e8e41b5e7f05
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
@@ -748,7 +748,7 @@ test/extractor-tests/generated/ClosureExpr/ClosureExpr_getParam.ql c87b61e80dd62
test/extractor-tests/generated/ClosureExpr/ClosureExpr_getParamList.ql 68ce501516094512dd5bfed42a785474583a91312f704087cba801b02ba7b834 eacbf89d63159e7decfd84c2a1dc5c067dfce56a8157fbb52bc133e9702d266d
test/extractor-tests/generated/ClosureExpr/ClosureExpr_getRetType.ql c95bc7306b2d77aa05a6501b6321e6f1e7a48b7ad422ba082635ab20014288ae fe72d44c9819b42fff49b9092a9fb2bfafde6d3b9e4967547fb5298822f30bc3
test/extractor-tests/generated/Comment/Comment.ql 5428b8417a737f88f0d55d87de45c4693d81f03686f03da11dc5369e163d977b 8948c1860cde198d49cff7c74741f554a9e89f8af97bb94de80f3c62e1e29244
test/extractor-tests/generated/Const/Const.ql 6794d0056060a82258d1e832ad265e2eb276206f0224a3f0eb9221e225370066 0a6134fb5a849ce9bd1a28de783460301cafca5773bd7caa4fb1f774f81b476a
test/extractor-tests/generated/Const/Const.ql 7f9c9ce5b04391ff8f0d419a62972292b1d9811a978cceb129ef5a0f68a02fab c6c1dfa688248310cadd2d6d71d1a70a2b48f5b29ea2078f4dd51db59a0021c0
test/extractor-tests/generated/Const/Const_getAttr.ql bd6296dab00065db39663db8d09fe62146838875206ff9d8595d06d6439f5043 34cb55ca6d1f44e27d82a8b624f16f9408bae2485c85da94cc76327eed168577
test/extractor-tests/generated/Const/Const_getAttributeMacroExpansion.ql 82e86399d5cd72621dc8d9cd9f310d3dc7f2ecf208149dab0d202047ccbbd2f8 33df8c5b5044f49ec244e183c61c3b81fabd987f590ba6da4e18e08231343dc8
test/extractor-tests/generated/Const/Const_getBody.ql f50f79b7f42bb1043b79ec96f999fa4740c8014e6969a25812d5d023d7a5a5d8 90e5060ba9757f1021429ed4ec4913bc78747f3fc415456ef7e7fc284b8a0026
@@ -834,7 +834,7 @@ test/extractor-tests/generated/FormatArgsExpr/FormatTemplateVariableAccess.ql 27
test/extractor-tests/generated/FormatArgsExpr/Format_getArgumentRef.ql 634efdffaae4199aa9d95652cf081a8dc26e88224e24678845f8a67dc24ce090 d0302fee5c50403214771d5c6b896ba7c6e52be10c9bea59720ef2bb954e6f40
test/extractor-tests/generated/FormatArgsExpr/Format_getPrecisionArgument.ql 0d2140f84d0220b0c72c48c6bd272f4cfe1863d1797eddd16a6e238552a61e4d f4fe9b29697041e30764fa3dea44f125546bfb648f32c3474a1e922a4255c534
test/extractor-tests/generated/FormatArgsExpr/Format_getWidthArgument.ql 01ef27dd0bfab273e1ddc57ada0e079ece8a2bfd195ce413261006964b444093 acd0161f86010759417015c5b58044467a7f760f288ec4e8525458c54ae9a715
test/extractor-tests/generated/Function/Function.ql b32c49f4371a51b9c217758fa5da2601d58bcbf3b195e7c8adb76bae5180d315 12e55c66a90ee88207c729736f388866cda13af78ea07a5d4e995c4a58a1e378
test/extractor-tests/generated/Function/Function.ql 66e6a81a80cdf30652f00fae1b060e93b9d7c61b08cb3d3c1cac16cad445e769 97ace9f51b9ae933c79484b06b92355164ff3582cadfc6e3bac5c00072cdeff3
test/extractor-tests/generated/Function/Function_getAbi.ql e5c9c97de036ddd51cae5d99d41847c35c6b2eabbbd145f4467cb501edc606d8 0b81511528bd0ef9e63b19edfc3cb638d8af43eb87d018fad69d6ef8f8221454
test/extractor-tests/generated/Function/Function_getAttr.ql 44067ee11bdec8e91774ff10de0704a8c5c1b60816d587378e86bf3d82e1f660 b4bebf9441bda1f2d1e34e9261e07a7468cbabf53cf8047384f3c8b11869f04e
test/extractor-tests/generated/Function/Function_getAttributeMacroExpansion.ql 17a346a9e5d28af99522520d1af3852db4cae01fb3d290a65c5f84d8d039c345 36fb06b55370828d9bc379cf5fad7f383cdb6f6db6f7377660276943ab0e1ec8

View File

@@ -108,5 +108,15 @@ module Generated {
* Holds if `getVisibility()` exists.
*/
final predicate hasVisibility() { exists(this.getVisibility()) }
/**
* Holds if this constant has an implementation.
*
* This is the same as `hasBody` for source code, but for library code (for which we always skip
* the body), this will hold when the body was present in the original code.
*/
predicate hasImplementation() {
Synth::convertConstToRaw(this).(Raw::Const).hasImplementation()
}
}
}

View File

@@ -164,5 +164,15 @@ module Generated {
* Holds if `getWhereClause()` exists.
*/
final predicate hasWhereClause() { exists(this.getWhereClause()) }
/**
* Holds if this function has an implementation.
*
* This is the same as `hasBody` for source code, but for library code (for which we always skip
* the body), this will hold when the body was present in the original code.
*/
predicate hasImplementation() {
Synth::convertFunctionToRaw(this).(Raw::Function).hasImplementation()
}
}
}

View File

@@ -3734,6 +3734,14 @@ module Raw {
* Gets the visibility of this const, if it exists.
*/
Visibility getVisibility() { const_visibilities(this, result) }
/**
* Holds if this constant has an implementation.
*
* This is the same as `hasBody` for source code, but for library code (for which we always skip
* the body), this will hold when the body was present in the original code.
*/
predicate hasImplementation() { const_has_implementation(this) }
}
/**
@@ -3922,6 +3930,14 @@ module Raw {
* Gets the where clause of this function, if it exists.
*/
WhereClause getWhereClause() { function_where_clauses(this, result) }
/**
* Holds if this function has an implementation.
*
* This is the same as `hasBody` for source code, but for library code (for which we always skip
* the body), this will hold when the body was present in the original code.
*/
predicate hasImplementation() { function_has_implementation(this) }
}
/**

View File

@@ -2816,6 +2816,11 @@ const_visibilities(
int visibility: @visibility ref
);
#keyset[id]
const_has_implementation(
int id: @const ref
);
enums(
unique int id: @enum
);
@@ -2985,6 +2990,11 @@ function_where_clauses(
int where_clause: @where_clause ref
);
#keyset[id]
function_has_implementation(
int id: @function ref
);
impls(
unique int id: @impl
);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
description: Add `function_has_implementation` and `const_has_implementation` tables
compatibility: backwards
function_has_implementation.rel: reorder function_bodies (@function id, @block_expr body) id
const_has_implementation.rel: reorder const_bodies (@const id, @expr body) id

View File

@@ -1 +1 @@
| gen_const.rs:4:5:7:22 | Const | hasExtendedCanonicalPath: | no | hasCrateOrigin: | no | hasAttributeMacroExpansion: | no | getNumberOfAttrs: | 0 | hasBody: | yes | isConst: | yes | isDefault: | no | hasName: | yes | hasTypeRepr: | yes | hasVisibility: | no |
| gen_const.rs:4:5:7:22 | Const | hasExtendedCanonicalPath: | no | hasCrateOrigin: | no | hasAttributeMacroExpansion: | no | getNumberOfAttrs: | 0 | hasBody: | yes | isConst: | yes | isDefault: | no | hasName: | yes | hasTypeRepr: | yes | hasVisibility: | no | hasImplementation: | yes |

View File

@@ -5,7 +5,8 @@ import TestUtils
from
Const x, string hasExtendedCanonicalPath, string hasCrateOrigin,
string hasAttributeMacroExpansion, int getNumberOfAttrs, string hasBody, string isConst,
string isDefault, string hasName, string hasTypeRepr, string hasVisibility
string isDefault, string hasName, string hasTypeRepr, string hasVisibility,
string hasImplementation
where
toBeTested(x) and
not x.isUnknown() and
@@ -26,8 +27,10 @@ where
(if x.isDefault() then isDefault = "yes" else isDefault = "no") and
(if x.hasName() then hasName = "yes" else hasName = "no") and
(if x.hasTypeRepr() then hasTypeRepr = "yes" else hasTypeRepr = "no") and
if x.hasVisibility() then hasVisibility = "yes" else hasVisibility = "no"
(if x.hasVisibility() then hasVisibility = "yes" else hasVisibility = "no") and
if x.hasImplementation() then hasImplementation = "yes" else hasImplementation = "no"
select x, "hasExtendedCanonicalPath:", hasExtendedCanonicalPath, "hasCrateOrigin:", hasCrateOrigin,
"hasAttributeMacroExpansion:", hasAttributeMacroExpansion, "getNumberOfAttrs:", getNumberOfAttrs,
"hasBody:", hasBody, "isConst:", isConst, "isDefault:", isDefault, "hasName:", hasName,
"hasTypeRepr:", hasTypeRepr, "hasVisibility:", hasVisibility
"hasTypeRepr:", hasTypeRepr, "hasVisibility:", hasVisibility, "hasImplementation:",
hasImplementation

View File

@@ -1,2 +1,2 @@
| gen_function.rs:3:1:4:38 | fn foo | hasParamList: | yes | getNumberOfAttrs: | 0 | getNumberOfParams: | 1 | hasExtendedCanonicalPath: | yes | hasCrateOrigin: | yes | hasAttributeMacroExpansion: | no | hasAbi: | no | hasBody: | yes | hasGenericParamList: | no | isAsync: | no | isConst: | no | isDefault: | no | isGen: | no | isUnsafe: | no | hasName: | yes | hasRetType: | yes | hasVisibility: | no | hasWhereClause: | no |
| gen_function.rs:7:5:7:13 | fn bar | hasParamList: | yes | getNumberOfAttrs: | 0 | getNumberOfParams: | 0 | hasExtendedCanonicalPath: | yes | hasCrateOrigin: | yes | hasAttributeMacroExpansion: | no | hasAbi: | no | hasBody: | no | hasGenericParamList: | no | isAsync: | no | isConst: | no | isDefault: | no | isGen: | no | isUnsafe: | no | hasName: | yes | hasRetType: | no | hasVisibility: | no | hasWhereClause: | no |
| gen_function.rs:3:1:4:38 | fn foo | hasParamList: | yes | getNumberOfAttrs: | 0 | getNumberOfParams: | 1 | hasExtendedCanonicalPath: | yes | hasCrateOrigin: | yes | hasAttributeMacroExpansion: | no | hasAbi: | no | hasBody: | yes | hasGenericParamList: | no | isAsync: | no | isConst: | no | isDefault: | no | isGen: | no | isUnsafe: | no | hasName: | yes | hasRetType: | yes | hasVisibility: | no | hasWhereClause: | no | hasImplementation: | yes |
| gen_function.rs:7:5:7:13 | fn bar | hasParamList: | yes | getNumberOfAttrs: | 0 | getNumberOfParams: | 0 | hasExtendedCanonicalPath: | yes | hasCrateOrigin: | yes | hasAttributeMacroExpansion: | no | hasAbi: | no | hasBody: | no | hasGenericParamList: | no | isAsync: | no | isConst: | no | isDefault: | no | isGen: | no | isUnsafe: | no | hasName: | yes | hasRetType: | no | hasVisibility: | no | hasWhereClause: | no | hasImplementation: | no |

View File

@@ -7,7 +7,7 @@ from
string hasExtendedCanonicalPath, string hasCrateOrigin, string hasAttributeMacroExpansion,
string hasAbi, string hasBody, string hasGenericParamList, string isAsync, string isConst,
string isDefault, string isGen, string isUnsafe, string hasName, string hasRetType,
string hasVisibility, string hasWhereClause
string hasVisibility, string hasWhereClause, string hasImplementation
where
toBeTested(x) and
not x.isUnknown() and
@@ -36,11 +36,12 @@ where
(if x.hasName() then hasName = "yes" else hasName = "no") and
(if x.hasRetType() then hasRetType = "yes" else hasRetType = "no") and
(if x.hasVisibility() then hasVisibility = "yes" else hasVisibility = "no") and
if x.hasWhereClause() then hasWhereClause = "yes" else hasWhereClause = "no"
(if x.hasWhereClause() then hasWhereClause = "yes" else hasWhereClause = "no") and
if x.hasImplementation() then hasImplementation = "yes" else hasImplementation = "no"
select x, "hasParamList:", hasParamList, "getNumberOfAttrs:", getNumberOfAttrs,
"getNumberOfParams:", getNumberOfParams, "hasExtendedCanonicalPath:", hasExtendedCanonicalPath,
"hasCrateOrigin:", hasCrateOrigin, "hasAttributeMacroExpansion:", hasAttributeMacroExpansion,
"hasAbi:", hasAbi, "hasBody:", hasBody, "hasGenericParamList:", hasGenericParamList, "isAsync:",
isAsync, "isConst:", isConst, "isDefault:", isDefault, "isGen:", isGen, "isUnsafe:", isUnsafe,
"hasName:", hasName, "hasRetType:", hasRetType, "hasVisibility:", hasVisibility,
"hasWhereClause:", hasWhereClause
"hasWhereClause:", hasWhereClause, "hasImplementation:", hasImplementation

View File

@@ -987,6 +987,10 @@ class _:
const X: i32 = 42;
```
"""
has_implementation: predicate | doc("this constant has an implementation") | desc("""
This is the same as `hasBody` for source code, but for library code (for which we always skip
the body), this will hold when the body was present in the original code.
""") | rust.detach
@annotate(ConstArg)
@@ -2135,6 +2139,10 @@ class _:
class _:
param_list: drop
attrs: drop
has_implementation: predicate | doc("this function has an implementation") | desc("""
This is the same as `hasBody` for source code, but for library code (for which we always skip
the body), this will hold when the body was present in the original code.
""") | rust.detach
@annotate(ClosureExpr, add_bases=[Callable])