From 269ea7503679db9fe16df6dd74619c69dce9eac5 Mon Sep 17 00:00:00 2001 From: Paolo Tranquilli Date: Mon, 25 Nov 2024 17:21:19 +0100 Subject: [PATCH] Rust: `matched_expr` -> `scrutinee` --- rust/ql/.generated.list | 12 ++++++------ rust/ql/.gitattributes | 2 +- .../internal/ControlFlowGraphImpl.qll | 6 +++--- .../internal/generated/CfgNodes.qll | 18 +++++++++--------- .../rust/elements/internal/MatchExprImpl.qll | 2 +- .../elements/internal/generated/MatchExpr.qll | 12 +++++------- .../internal/generated/ParentChild.qll | 10 +++++----- .../rust/elements/internal/generated/Raw.qll | 4 ++-- .../generated/MatchExpr/MatchExpr.expected | 4 ++-- .../generated/MatchExpr/MatchExpr.ql | 8 ++++---- .../MatchExpr_getMatchedExpr.expected | 2 -- ...xpected => MatchExpr_getScrutinee.expected} | 0 ...atchedExpr.ql => MatchExpr_getScrutinee.ql} | 2 +- rust/schema/annotations.py | 2 +- 14 files changed, 40 insertions(+), 44 deletions(-) delete mode 100644 rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getMatchedExpr.expected rename rust/ql/test/extractor-tests/generated/MatchExpr/{MatchExpr_getMatched.expected => MatchExpr_getScrutinee.expected} (100%) rename rust/ql/test/extractor-tests/generated/MatchExpr/{MatchExpr_getMatchedExpr.ql => MatchExpr_getScrutinee.ql} (83%) diff --git a/rust/ql/.generated.list b/rust/ql/.generated.list index 041e1a565b2a..36416013959d 100644 --- a/rust/ql/.generated.list +++ b/rust/ql/.generated.list @@ -1,4 +1,4 @@ -lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll c0438ab3e984fbf7ce2cc4ac64aafa115f36f2be700a819fd81f15d777f363b6 bc57c07b7f9472156cff3f878459872255c7ee4ba0767258129d0258789f98df +lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll 5e6ce2581b312d74ac8ffde44941b77f643025a7ff2c47799b3834596a513fa4 24dc5d28eb4754f968cf850294ac32057a2a97cf5156a3e90e0924c28e50e810 lib/codeql/rust/elements/Abi.qll 4c973d28b6d628f5959d1f1cc793704572fd0acaae9a97dfce82ff9d73f73476 250f68350180af080f904cd34cb2af481c5c688dc93edf7365fd0ae99855e893 lib/codeql/rust/elements/ArgList.qll 661f5100f5d3ef8351452d9058b663a2a5c720eea8cf11bedd628969741486a2 28e424aac01a90fb58cd6f9f83c7e4cf379eea39e636bc0ba07efc818be71c71 lib/codeql/rust/elements/ArrayExpr.qll a3e6e122632f4011644ec31b37f88b32fe3f2b7e388e7e878a6883309937049f 12ccb5873d95c433da5606fd371d182ef2f71b78d0c53c2d6dec10fa45852bdc @@ -495,7 +495,7 @@ lib/codeql/rust/elements/internal/generated/MacroStmts.qll cb4f3c2721a4d0c8522e5 lib/codeql/rust/elements/internal/generated/MacroType.qll c462824df4a002956c036966d15cd0bce206e664888f8d0c7834dedb38b3c0bf 947480f07c40128ef3d00ad4c3a29a685472b3e20a661680c22f6bb318205ed1 lib/codeql/rust/elements/internal/generated/MatchArm.qll 8fb740a0f2e308782d9cf390672969cd7cf6e698e5b847fb02ae3fa6c205646f 42bfe8dd94fc24ec925fbd44016df111600f99d1216c9a698631373bb6048830 lib/codeql/rust/elements/internal/generated/MatchArmList.qll 13362680c037fe83fef4653562cc10a4429078316b5ec7c47b076336cf4aca2e 41c674293c13eceaca62134ae0c6778541f6a5201cbc5c146f0ba01b898dc267 -lib/codeql/rust/elements/internal/generated/MatchExpr.qll e1e5bf4623511028a6c2ebc6bb6e3c18ec9fe4f49ef4cd8654e5dc376121088d c0760592040b2df9a571cd766397a0f9c68684d24d72780756cae7a1878d102a +lib/codeql/rust/elements/internal/generated/MatchExpr.qll b686842e7000fd61e3a0598bf245fb4e18167b99eca9162fdfdff0b0963def22 00f1743b1b0f1a92c5a687f5260fda02d80cc5871694cad0d5e7d94bac7fe977 lib/codeql/rust/elements/internal/generated/MatchGuard.qll 521a507883963106780f1782084c581fbcf1179863c7c15438c4db79e30e78dd 6226feffaaa8d828a42ece0c693e616cd375672eb987c3b7ff1ca15fa23c116a lib/codeql/rust/elements/internal/generated/Meta.qll 38fca2c9958b4179de311546fe0850319010aca9cd17c97d57e12b521c5d0947 740f99c9d41044ceebfcc9d29baaa22f59c11a40f45502a34aa587d423c018f8 lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll 17bffcc826851a8be32a1900b8fdf777f9bab6aed9f8268d566173c4974c1cf9 134a2860bdf16daafdb3e574c52a69d2598210653db89c2fa062ca25e8f8a649 @@ -512,7 +512,7 @@ lib/codeql/rust/elements/internal/generated/ParamList.qll c808c9d84dd7800573832b lib/codeql/rust/elements/internal/generated/ParenExpr.qll bc0731505bfe88516205ec360582a4222d2681d11342c93e15258590ddee82f2 d4bd6e0c80cf1d63746c88d4bcb3a01d4c75732e5da09e3ebd9437ced227fb60 lib/codeql/rust/elements/internal/generated/ParenPat.qll ce24b8f8ecbf0f204af200317405724063887257460c80cf250c39b2fdf37185 e7c87d37e1a0ca7ea03840017e1aa9ddb7f927f1f3b6396c0305b46aeee33db6 lib/codeql/rust/elements/internal/generated/ParenType.qll 9cc954d73f8330dcac7b475f97748b63af5c8766dee9d2f2872c0a7e4c903537 c07534c8a9c683c4a9b11d490095647e420de0a0bfc23273eaf6f31b00244273 -lib/codeql/rust/elements/internal/generated/ParentChild.qll a19adfe192c88023b77f938d91f8539df6e42fa14172389537069decfe8baa7d 6be35ca8755d80c0365eeb9ecc51982fb0e24d2ed53ec6b17a15da4af6fbe6e6 +lib/codeql/rust/elements/internal/generated/ParentChild.qll 78723cac5f2999f91317f39cf53267043fd2a56e98e838f013eae01b6b39929e 26dd29e5fd868f89982269db6b25aa799be942abdbe41ff1a8ffd4dae4385bdc lib/codeql/rust/elements/internal/generated/Pat.qll 3605ac062be2f294ee73336e9669027b8b655f4ad55660e1eab35266275154ee 7f9400db2884d336dd1d21df2a8093759c2a110be9bf6482ce8e80ae0fd74ed4 lib/codeql/rust/elements/internal/generated/Path.qll 4c1c8e840ed57880e574142b081b11d7a7428a009f10e3aa8f4645e211f6b2e0 989668cf0f1bdee7557e2f97c01e41d2a56848227fed41477833f5fc1e1d35f6 lib/codeql/rust/elements/internal/generated/PathExpr.qll 2096e3c1db22ee488a761690adabfc9cfdea501c99f7c5d96c0019cb113fc506 54245ce0449c4e263173213df01e079d5168a758503a5dbd61b25ad35a311140 @@ -525,7 +525,7 @@ lib/codeql/rust/elements/internal/generated/PtrType.qll 40099c5a4041314b66932dfd lib/codeql/rust/elements/internal/generated/PureSynthConstructors.qll ea294a3ba33fd1bc632046c4fedbcb84dcb961a8e4599969d65893b19d90e590 ea294a3ba33fd1bc632046c4fedbcb84dcb961a8e4599969d65893b19d90e590 lib/codeql/rust/elements/internal/generated/RangeExpr.qll 23cca03bf43535f33b22a38894f70d669787be4e4f5b8fe5c8f7b964d30e9027 18624cef6c6b679eeace2a98737e472432e0ead354cca02192b4d45330f047c9 lib/codeql/rust/elements/internal/generated/RangePat.qll efd93730de217cf50dcba5875595263a5eadf9f7e4e1272401342a094d158614 229b251b3d118932e31e78ac4dfb75f48b766f240f20d436062785606d44467b -lib/codeql/rust/elements/internal/generated/Raw.qll f1af475812318f9fbfd1731a1e97ae77783bcc8a7ad45463cd9916e4c46e783a 1e06a7cd87c4c704f76bbc70ba3d7601ca6f1b3dd11f124ee448d8b834f7ce55 +lib/codeql/rust/elements/internal/generated/Raw.qll b342060fd7fe2214eea191859f559334a8a64cf6785048f784ed641ea1e616fd 4737f09bbd2e190eee9bb83476a0045887ff2982dd06cd4e6538fc31637ab521 lib/codeql/rust/elements/internal/generated/RecordExpr.qll eb6cb662e463f9260efae1a6ce874fa781172063b916ef1963f861e9942d308d 1a21cbccc8f3799ff13281e822818ebfb21d81591720a427cac3625512cb9d40 lib/codeql/rust/elements/internal/generated/RecordExprField.qll 7e9f8663d3b74ebbc9603b10c9912f082febba6bd73d344b100bbd3edf837802 fbe6b578e7fd5d5a6f21bbb8c388957ab7210a6a249ec71510a50fb35b319ea1 lib/codeql/rust/elements/internal/generated/RecordExprFieldList.qll 179a97211fe7aa6265085d4d54115cdbc0e1cd7c9b2135591e8f36d6432f13d3 dd44bbbc1e83a1ed3a587afb729d7debf7aeb7b63245de181726af13090e50c0 @@ -845,10 +845,10 @@ test/extractor-tests/generated/MatchArm/MatchArm_getPat.ql b346bca229226414b32ac test/extractor-tests/generated/MatchArmList/MatchArmList.ql 14b5e110d48e2b77c85b7a188262e6a98300e0d4d507bb7ed9179c5802251dd6 4d091f06b12fef0fffe1c80a10f74438d8068f2fa09c50d5e240b6d140e60d90 test/extractor-tests/generated/MatchArmList/MatchArmList_getArm.ql 4781d002538a92b7f40fb0ec3d61aeedb6348341ddc354bbdd3ff61b74d59767 ae0da9497a30ce006e03bdb70e0ee24b685df529ac15a7d99a6869b5f7d7b371 test/extractor-tests/generated/MatchArmList/MatchArmList_getAttr.ql 4d7e6d152d2dbeb4c9f594becabea27d3b25fecbde40d791a2907c69cc0c9631 4be9be658bb22e1b764c4ebc8d6b99bf50fd939f35ea44fbb869056c14632bd4 -test/extractor-tests/generated/MatchExpr/MatchExpr.ql 22a3ace49ec98524388ccfb031c180eedc741cbc5b58a4815cc9e52fe292e6b3 5b56c71cbc02ac3aecfcbe93e7bbdb55727aae39d7949a7d8db3d6f93ea7ca80 +test/extractor-tests/generated/MatchExpr/MatchExpr.ql 2966bf0507c0d45db1b933442ce8f1c4e0a9d4212c53a768791665cd2e0927f0 8af3b87528b6dd4cd3ff4fc6d2d389b1a743f979d9ccacd0aff134b5a4376118 test/extractor-tests/generated/MatchExpr/MatchExpr_getAttr.ql cb8057372dcf24dfa02896ebf4e60a0b757dc4742b94011edc38f5b898ed4d25 6809695c2d3ac3b92c06049c9b920e8c0e99ee1998a11a7f181f2b0ceb47c197 test/extractor-tests/generated/MatchExpr/MatchExpr_getMatchArmList.ql d97055bcb0431e8b258b5ecdd98aa07cb24ece06b0cd658b697cd71da4ede8fc 5e9c03b2665ef6b2af98897996abb2e0a9c18d54eb64588340b8efbcee9793bd -test/extractor-tests/generated/MatchExpr/MatchExpr_getMatchedExpr.ql 478585d26c2b301f474f04569deb79728c80b3f67fe5c2536b64f5a29dcccf30 750d24c48dc0f57992265c3fc60fbfa400263f58f74b7951774a383d3ae4ae0a +test/extractor-tests/generated/MatchExpr/MatchExpr_getScrutinee.ql 0bfeb8f903fb23356d50b7edd80377f4a67045010ffbed04c835191b5bd62820 7dc8e38730ad72b4cea91c1f023cdbe83057053e8dbd077ff925c59e92744498 test/extractor-tests/generated/MatchGuard/MatchGuard.ql 23e47ec1b13e2d80e31b57894a46ec789d6ab5ed1eb66bdb6bba9bd5ae71d3ef 7302f4a93108a83228e0ebd5b4a1bc6bccc1f6f0f3272054866fa90378c0dcc4 test/extractor-tests/generated/MatchGuard/MatchGuard_getCondition.ql 8a79dd46798f111f8d0d5a975380b5cebe5e337267752b77b3718b268ba2773d 6691d8fb483f64fc7e3ad3f46e3129e0a1184d7beb9f83a1000acdbb081c8b5e test/extractor-tests/generated/Meta/Meta.ql 16f163f00ba2bbaa0a8c6f3f6710c860a8f61d02d43321c78e05a10a3606e39b ba982c6bb93ddb4fc2c44d24635bd487128a5b1d1f885214044c989a21f4d05a diff --git a/rust/ql/.gitattributes b/rust/ql/.gitattributes index 6b97bf454706..69c1ecbc2c6a 100644 --- a/rust/ql/.gitattributes +++ b/rust/ql/.gitattributes @@ -850,7 +850,7 @@ /test/extractor-tests/generated/MatchExpr/MatchExpr.ql linguist-generated /test/extractor-tests/generated/MatchExpr/MatchExpr_getAttr.ql linguist-generated /test/extractor-tests/generated/MatchExpr/MatchExpr_getMatchArmList.ql linguist-generated -/test/extractor-tests/generated/MatchExpr/MatchExpr_getMatchedExpr.ql linguist-generated +/test/extractor-tests/generated/MatchExpr/MatchExpr_getScrutinee.ql linguist-generated /test/extractor-tests/generated/MatchGuard/MatchGuard.ql linguist-generated /test/extractor-tests/generated/MatchGuard/MatchGuard_getCondition.ql linguist-generated /test/extractor-tests/generated/Meta/Meta.ql linguist-generated diff --git a/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll b/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll index 42487f1689d3..91eeb75fe398 100644 --- a/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll +++ b/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll @@ -514,14 +514,14 @@ module ExprTrees { class MatchExprTree extends PostOrderTree instanceof MatchExpr { override predicate propagatesAbnormal(AstNode child) { - child = [super.getMatchedExpr(), super.getAnArm().getExpr()] + child = [super.getScrutinee(), super.getAnArm().getExpr()] } - override predicate first(AstNode node) { first(super.getMatchedExpr(), node) } + override predicate first(AstNode node) { first(super.getScrutinee(), node) } override predicate succ(AstNode pred, AstNode succ, Completion c) { // Edge from the scrutinee to the first arm or to the match expression if no arms. - last(super.getMatchedExpr(), pred, c) and + last(super.getScrutinee(), pred, c) and ( first(super.getArm(0).getPat(), succ) or diff --git a/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll b/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll index aeebf92e02b1..44024a9d76e7 100644 --- a/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll +++ b/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll @@ -1709,7 +1709,7 @@ module MakeCfgNodes Input> { override predicate relevantChild(AstNode child) { none() or - child = this.getMatchedExpr() + child = this.getScrutinee() } } @@ -1752,16 +1752,16 @@ module MakeCfgNodes Input> { int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } /** - * Gets the expression of this match expression, if it exists. + * Gets the scrutinee (the expression being matched) of this match expression, if it exists. */ - ExprCfgNode getMatchedExpr() { - any(ChildMapping mapping).hasCfgChild(node, node.getMatchedExpr(), this, result) + ExprCfgNode getScrutinee() { + any(ChildMapping mapping).hasCfgChild(node, node.getScrutinee(), this, result) } /** - * Holds if `getMatchedExpr()` exists. + * Holds if `getScrutinee()` exists. */ - predicate hasMatchedExpr() { exists(this.getMatchedExpr()) } + predicate hasScrutinee() { exists(this.getScrutinee()) } /** * Gets the match arm list of this match expression, if it exists. @@ -3451,14 +3451,14 @@ module MakeCfgNodes Input> { cfgNode ) or - pred = "getMatchedExpr" and + pred = "getScrutinee" and parent = any(Nodes::MatchExprCfgNode cfgNode, MatchExpr astNode | astNode = cfgNode.getMatchExpr() and - child = getDesugared(astNode.getMatchedExpr()) and + child = getDesugared(astNode.getScrutinee()) and i = -1 and hasCfgNode(child) and - not child = cfgNode.getMatchedExpr().getAstNode() + not child = cfgNode.getScrutinee().getAstNode() | cfgNode ) diff --git a/rust/ql/lib/codeql/rust/elements/internal/MatchExprImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/MatchExprImpl.qll index 445c4c869452..15fdcf7e73fb 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/MatchExprImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/MatchExprImpl.qll @@ -29,7 +29,7 @@ module Impl { */ class MatchExpr extends Generated::MatchExpr { override string toString() { - result = "match " + this.getMatchedExpr().toAbbreviatedString() + " { ... }" + result = "match " + this.getScrutinee().toAbbreviatedString() + " { ... }" } /** diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/MatchExpr.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/MatchExpr.qll index 5c2974c82feb..8f49407e5f9e 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/MatchExpr.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/MatchExpr.qll @@ -55,19 +55,17 @@ module Generated { final int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } /** - * Gets the expression of this match expression, if it exists. + * Gets the scrutinee (the expression being matched) of this match expression, if it exists. */ - Expr getMatchedExpr() { + Expr getScrutinee() { result = - Synth::convertExprFromRaw(Synth::convertMatchExprToRaw(this) - .(Raw::MatchExpr) - .getMatchedExpr()) + Synth::convertExprFromRaw(Synth::convertMatchExprToRaw(this).(Raw::MatchExpr).getScrutinee()) } /** - * Holds if `getMatchedExpr()` exists. + * Holds if `getScrutinee()` exists. */ - final predicate hasMatchedExpr() { exists(this.getMatchedExpr()) } + final predicate hasScrutinee() { exists(this.getScrutinee()) } /** * Gets the match arm list of this match expression, if it exists. diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll index 9dd9eff45eb9..970cfb223640 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll @@ -2030,13 +2030,13 @@ private module Impl { } private Element getImmediateChildOfMatchExpr(MatchExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nMatchedExpr, int nMatchArmList | + exists(int b, int bExpr, int n, int nAttr, int nScrutinee, int nMatchArmList | b = 0 and bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and n = bExpr and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - nMatchedExpr = nAttr + 1 and - nMatchArmList = nMatchedExpr + 1 and + nScrutinee = nAttr + 1 and + nMatchArmList = nScrutinee + 1 and ( none() or @@ -2045,9 +2045,9 @@ private module Impl { result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or - index = nAttr and result = e.getMatchedExpr() and partialPredicateCall = "MatchedExpr()" + index = nAttr and result = e.getScrutinee() and partialPredicateCall = "Scrutinee()" or - index = nMatchedExpr and + index = nScrutinee and result = e.getMatchArmList() and partialPredicateCall = "MatchArmList()" ) diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll index b54d0cba5832..69aa32d4ad8c 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll @@ -2170,9 +2170,9 @@ module Raw { Attr getAttr(int index) { match_expr_attrs(this, index, result) } /** - * Gets the expression of this match expression, if it exists. + * Gets the scrutinee (the expression being matched) of this match expression, if it exists. */ - Expr getMatchedExpr() { match_expr_exprs(this, result) } + Expr getScrutinee() { match_expr_exprs(this, result) } /** * Gets the match arm list of this match expression, if it exists. diff --git a/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.expected b/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.expected index 68912b3f01ac..8c5b0a32a8fa 100644 --- a/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.expected +++ b/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.expected @@ -1,2 +1,2 @@ -| gen_match_expr.rs:5:5:8:5 | match x { ... } | getNumberOfAttrs: | 0 | hasMatchedExpr: | yes | hasMatchArmList: | yes | -| gen_match_expr.rs:9:5:12:5 | match x { ... } | getNumberOfAttrs: | 0 | hasMatchedExpr: | yes | hasMatchArmList: | yes | +| gen_match_expr.rs:5:5:8:5 | match x { ... } | getNumberOfAttrs: | 0 | hasScrutinee: | yes | hasMatchArmList: | yes | +| gen_match_expr.rs:9:5:12:5 | match x { ... } | getNumberOfAttrs: | 0 | hasScrutinee: | yes | hasMatchArmList: | yes | diff --git a/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.ql b/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.ql index e99d3c70e1b4..0847933e937c 100644 --- a/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.ql +++ b/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr.ql @@ -2,12 +2,12 @@ import codeql.rust.elements import TestUtils -from MatchExpr x, int getNumberOfAttrs, string hasMatchedExpr, string hasMatchArmList +from MatchExpr x, int getNumberOfAttrs, string hasScrutinee, string hasMatchArmList where toBeTested(x) and not x.isUnknown() and getNumberOfAttrs = x.getNumberOfAttrs() and - (if x.hasMatchedExpr() then hasMatchedExpr = "yes" else hasMatchedExpr = "no") and + (if x.hasScrutinee() then hasScrutinee = "yes" else hasScrutinee = "no") and if x.hasMatchArmList() then hasMatchArmList = "yes" else hasMatchArmList = "no" -select x, "getNumberOfAttrs:", getNumberOfAttrs, "hasMatchedExpr:", hasMatchedExpr, - "hasMatchArmList:", hasMatchArmList +select x, "getNumberOfAttrs:", getNumberOfAttrs, "hasScrutinee:", hasScrutinee, "hasMatchArmList:", + hasMatchArmList diff --git a/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getMatchedExpr.expected b/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getMatchedExpr.expected deleted file mode 100644 index 427af7c6ed0c..000000000000 --- a/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getMatchedExpr.expected +++ /dev/null @@ -1,2 +0,0 @@ -| gen_match_expr.rs:5:5:8:5 | match x { ... } | gen_match_expr.rs:5:11:5:11 | x | -| gen_match_expr.rs:9:5:12:5 | match x { ... } | gen_match_expr.rs:9:11:9:11 | x | diff --git a/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getMatched.expected b/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getScrutinee.expected similarity index 100% rename from rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getMatched.expected rename to rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getScrutinee.expected diff --git a/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getMatchedExpr.ql b/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getScrutinee.ql similarity index 83% rename from rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getMatchedExpr.ql rename to rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getScrutinee.ql index 0a7bb7ae3322..4d29f21fbfba 100644 --- a/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getMatchedExpr.ql +++ b/rust/ql/test/extractor-tests/generated/MatchExpr/MatchExpr_getScrutinee.ql @@ -4,4 +4,4 @@ import TestUtils from MatchExpr x where toBeTested(x) and not x.isUnknown() -select x, x.getMatchedExpr() +select x, x.getScrutinee() diff --git a/rust/schema/annotations.py b/rust/schema/annotations.py index b93151fec338..9e857ad7b0f2 100644 --- a/rust/schema/annotations.py +++ b/rust/schema/annotations.py @@ -289,7 +289,7 @@ class _: } ``` """ - expr: _ | ql.name("matched_expr") + expr: _ | ql.name("scrutinee") | doc("scrutinee (the expression being matched) of this match expression") @annotate(ContinueExpr, cfg = True)