diff --git a/rust/ql/.generated.list b/rust/ql/.generated.list index 13b8156aaa96..5ed2894e273f 100644 --- a/rust/ql/.generated.list +++ b/rust/ql/.generated.list @@ -287,7 +287,6 @@ lib/codeql/rust/elements/internal/ImplConstructor.qll 24edccca59f70d812d1458b412 lib/codeql/rust/elements/internal/ImplTraitTypeReprConstructor.qll 1ed355e5e56f432b24b6f4778e4dc45c6e65095190cacb7a5015529e0c9d01f8 c8505185a042da4eb20a0cc32323194a0290c4bf821c7e0fce7351b194b10f31 lib/codeql/rust/elements/internal/IndexExprConstructor.qll 99bdc3d793c4dbd993860da60abe2b7c604345d645e86916462bc55a6939a5d1 3fe9d7da725956903707806aadbecac8d5b3874e8bed63c9bab54fff630e75dd lib/codeql/rust/elements/internal/InferTypeReprConstructor.qll bc5f16853401617fc9c5af8a1287a23c5921df1b615cfbe2d7c7a70145ecfcbd da93bd28ea2daade2cbb0a729be3fbf05f72bc02009565c7bb062e4f68fdb9e7 -lib/codeql/rust/elements/internal/ItemImpl.qll e3fb78d572ce1c3cc857d2671bd71ff4d7850321acfddc5f15533ff87accda79 fbabc2081e4b2773b04938d57bb51af908c80b7bc53c3127c74ab5d4fb9837bc lib/codeql/rust/elements/internal/ItemListConstructor.qll 08af3bd12536941c3dd4a43c81cc861be24325e242e2593c087a3ce632674291 2fa166159c409d2aaffa73a30babb40829a6de580bd40894d909ee6152801082 lib/codeql/rust/elements/internal/ItemListImpl.qll 195dbe93c334ad2bfc29db530bda9aaea88fc31696b2f230faae9e6c2ecb74a8 e498983a5b2f7a91e2fd336e85ac17e521a18c677784a0788d95bb283f3652e7 lib/codeql/rust/elements/internal/LabelConstructor.qll 1f814c94251e664bfa1b1a606aef995382e40e78d4f953350ec951ee0bc8bd34 3157fb8c7c6bd365a739f217ad73ba1e0b65ccd59b922e5ab034e3449915b36c diff --git a/rust/ql/.gitattributes b/rust/ql/.gitattributes index ff149fb36d36..bde61270e6aa 100644 --- a/rust/ql/.gitattributes +++ b/rust/ql/.gitattributes @@ -289,7 +289,6 @@ /lib/codeql/rust/elements/internal/ImplTraitTypeReprConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/IndexExprConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/InferTypeReprConstructor.qll linguist-generated -/lib/codeql/rust/elements/internal/ItemImpl.qll linguist-generated /lib/codeql/rust/elements/internal/ItemListConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/ItemListImpl.qll linguist-generated /lib/codeql/rust/elements/internal/LabelConstructor.qll linguist-generated diff --git a/rust/ql/lib/codeql/rust/elements/internal/AstNodeImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/AstNodeImpl.qll index 237ebfa6b413..69138190dba3 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/AstNodeImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/AstNodeImpl.qll @@ -13,9 +13,9 @@ private import codeql.rust.controlflow.ControlFlowGraph */ module Impl { private import rust + private import codeql.rust.elements.internal.ElementImpl::Impl as ElementImpl private import codeql.rust.elements.internal.generated.ParentChild private import codeql.rust.controlflow.ControlFlowGraph - private import codeql.rust.elements.internal.MacroCallImpl::Impl as MacroCallImpl /** * Gets the immediate parent of a non-`AstNode` element `e`. @@ -71,21 +71,15 @@ module Impl { } /** Holds if this node is inside a macro expansion. */ - predicate isInMacroExpansion() { MacroCallImpl::isInMacroExpansion(_, this) } + predicate isInMacroExpansion() { ElementImpl::MacroExpansion::isInMacroExpansion(this) } /** * Holds if this node exists only as the result of a macro expansion. * * This is the same as `isInMacroExpansion()`, but excludes AST nodes corresponding - * to macro arguments. + * to macro arguments, including attribute macro targets. */ - pragma[nomagic] - predicate isFromMacroExpansion() { - exists(AstNode root | - MacroCallImpl::isInMacroExpansion(root, this) and - not this = root.(MacroCall).getATokenTreeNode() - ) - } + predicate isFromMacroExpansion() { ElementImpl::MacroExpansion::isFromMacroExpansion(this) } /** * Gets a control flow node for this AST node, if any. diff --git a/rust/ql/lib/codeql/rust/elements/internal/ElementImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/ElementImpl.qll index 7a464a378d1e..f8aaf597ca2f 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/ElementImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/ElementImpl.qll @@ -11,7 +11,118 @@ private import codeql.rust.elements.internal.generated.Element * be referenced directly. */ module Impl { + private import rust + private import codeql.rust.elements.internal.generated.ParentChild + private import codeql.rust.elements.internal.generated.Synth + private import codeql.rust.elements.internal.generated.Raw + private import codeql.rust.elements.internal.LocationImpl + + /** + * Provides logic for classifying elements with respect to macro expansions. + */ + cached + module MacroExpansion { + /** + * Holds if `e` is superseded by an attribute macro expansion. That is, `e` is + * a transitive child of an item with an attribute macro expansion. + * + * Since this predicate is referenced in the charpred of `Element`, we need to + * use the parent-child relation on raw elements to avoid non-monotonicity. + */ + private predicate supersededByAttributeMacroExpansionRaw(Raw::Item item, Raw::Element e) { + exists(item.getAttributeMacroExpansion()) and + e = Raw::getImmediateChild(item, _) and + not e = item.getAttributeMacroExpansion() and + // Don't consider attributes themselves to be superseded. E.g., in `#[a] fn + // f() {}` the macro expansion supersedes `fn f() {}` but not `#[a]`. + not e instanceof Raw::Attr + or + exists(Raw::Element parent | + e = Raw::getImmediateChild(parent, _) and + supersededByAttributeMacroExpansionRaw(item, parent) + ) + } + + private predicate isMacroExpansion(AstNode macro, AstNode expansion) { + expansion = macro.(MacroCall).getMacroCallExpansion() + or + expansion = macro.(Adt).getDeriveMacroExpansion(_) + or + expansion = macro.(Item).getAttributeMacroExpansion() + } + + /** + * Gets the immediately enclosing macro invocation for element `e`, if any. + * + * The result is either a `MacroCall`, an `Adt` with a derive macro expansion, or + * an `Item` with an attribute macro expansion. + */ + cached + AstNode getImmediatelyEnclosingMacroInvocation(Element e) { + isMacroExpansion(result, e) + or + exists(Element mid | + result = getImmediatelyEnclosingMacroInvocation(mid) and + mid = getImmediateParent(e) and + not isMacroExpansion(mid, e) + ) + } + + pragma[nomagic] + private predicate isAttributeMacroExpansionSourceLocation(Item i, Location l) { + exists(Raw::Locatable e, @location_default loc | + supersededByAttributeMacroExpansionRaw(Synth::convertElementToRaw(i), e) and + locatable_locations(e, loc) and + l = LocationImpl::TLocationDefault(loc) + ) + } + + /** Gets an AST node whose location is inside the token tree belonging to `mc`. */ + pragma[nomagic] + private AstNode getATokenTreeNode(MacroCall mc) { + mc = getImmediatelyEnclosingMacroInvocation(result) and + mc.getTokenTree().getLocation().contains(result.getLocation()) + } + + /** Holds if `n` is inside a macro expansion. */ + cached + predicate isInMacroExpansion(AstNode n) { exists(getImmediatelyEnclosingMacroInvocation(n)) } + + /** + * Holds if `n` exists only as the result of a macro expansion. + * + * This is the same as `isInMacroExpansion(n)`, but excludes AST nodes corresponding + * to macro arguments, including attribute macro targets. + * + * Note: This predicate is a heuristic based on location information and may not be + * accurate in all cases. + */ + cached + predicate isFromMacroExpansion(AstNode n) { + exists(AstNode macro | + macro = getImmediatelyEnclosingMacroInvocation(n) and + not n = getATokenTreeNode(macro) and + not isAttributeMacroExpansionSourceLocation(macro, n.getLocation()) + ) + or + isFromMacroExpansion(getImmediatelyEnclosingMacroInvocation(n)) + } + + cached + predicate isRelevantElement(Generated::Element e) { + exists(Raw::Element raw | + raw = Synth::convertElementToRaw(e) and + not supersededByAttributeMacroExpansionRaw(_, raw) + ) + or + // Synthetic elements are relevant when their parents are + Synth::convertFormatArgsExprToRaw(_) = Synth::getSynthParent(e) + } + } + class Element extends Generated::Element { + Element() { MacroExpansion::isRelevantElement(this) } + override string toStringImpl() { result = this.getAPrimaryQlClass() } /** diff --git a/rust/ql/lib/codeql/rust/elements/internal/ItemImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/ItemImpl.qll index f211708bc812..46e554e4b420 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/ItemImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/ItemImpl.qll @@ -1,4 +1,3 @@ -// generated by codegen, remove this comment if you wish to edit this file /** * This module provides a hand-modifiable wrapper around the generated class `Item`. * @@ -12,6 +11,7 @@ private import codeql.rust.elements.internal.generated.Item * be referenced directly. */ module Impl { + // the following QLdoc is generated: if you need to edit it, do it in the schema file /** * An item such as a function, struct, enum, etc. * @@ -23,4 +23,10 @@ module Impl { * ``` */ class Item extends Generated::Item { } + + private class ItemWithAttributeMacroExpansion extends Item { + ItemWithAttributeMacroExpansion() { this.hasAttributeMacroExpansion() } + + override string toStringImpl() { result = "(item with attribute macro expansion)" } + } } diff --git a/rust/ql/lib/codeql/rust/elements/internal/LocatableImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/LocatableImpl.qll index fcb5289e0493..78a9e7f38eca 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/LocatableImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/LocatableImpl.qll @@ -5,6 +5,7 @@ */ import codeql.Locations +private import codeql.rust.elements.internal.ElementImpl::Impl as ElementImpl private import codeql.rust.elements.internal.LocationImpl private import codeql.rust.elements.internal.generated.Locatable private import codeql.rust.elements.internal.generated.Synth @@ -50,21 +51,12 @@ module Impl { locatable_locations(Synth::convertLocatableToRaw(l), result) } - private MacroCall getImmediatelyEnclosingMacroCall(AstNode n) { - result = n.getParentNode() - or - exists(AstNode mid | - result = getImmediatelyEnclosingMacroCall(mid) and - n.getParentNode() = mid and - not mid instanceof MacroCall - ) - } - /** Gets the non-synthesized location of `l`, if any. */ LocationImpl::LocationDefault getLocationDefault(Locatable l) { result = LocationImpl::TLocationDefault(getDbLocation(l)) or not exists(getDbLocation(l)) and - result = getLocationDefault(getImmediatelyEnclosingMacroCall(l)) + result = + getLocationDefault(ElementImpl::MacroExpansion::getImmediatelyEnclosingMacroInvocation(l)) } } diff --git a/rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll index 17cc47d803f8..8e048517f63c 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll @@ -14,17 +14,6 @@ module Impl { private import rust private import codeql.rust.internal.PathResolution - pragma[nomagic] - predicate isInMacroExpansion(AstNode root, AstNode n) { - n = root.(MacroCall).getMacroCallExpansion() - or - n = root.(Adt).getDeriveMacroExpansion(_) - or - n = root.(Item).getAttributeMacroExpansion() - or - isInMacroExpansion(root, n.getParentNode()) - } - // the following QLdoc is generated: if you need to edit it, do it in the schema file /** * A macro invocation. @@ -35,16 +24,7 @@ module Impl { * ``` */ class MacroCall extends Generated::MacroCall { - override string toStringImpl() { - if this.hasPath() then result = this.getPath().toAbbreviatedString() + "!..." else result = "" - } - - /** Gets an AST node whose location is inside the token tree belonging to this macro call. */ - pragma[nomagic] - AstNode getATokenTreeNode() { - isInMacroExpansion(this, result) and - this.getTokenTree().getLocation().contains(result.getLocation()) - } + override string toStringImpl() { result = this.getPath().toAbbreviatedString() + "!..." } /** * Gets the macro definition that this macro call resolves to. diff --git a/rust/ql/lib/codeql/rust/internal/PathResolution.qll b/rust/ql/lib/codeql/rust/internal/PathResolution.qll index fc49b7ca5e82..2bf316f78bc0 100644 --- a/rust/ql/lib/codeql/rust/internal/PathResolution.qll +++ b/rust/ql/lib/codeql/rust/internal/PathResolution.qll @@ -90,24 +90,6 @@ private module UseOption = Option; private class UseOption = UseOption::Option; -/** - * Holds if `n` is superseded by an attribute macro expansion. That is, `n` is - * an item or a transitive child of an item with an attribute macro expansion. - */ -predicate supersededByAttributeMacroExpansion(AstNode n) { - n.(Item).hasAttributeMacroExpansion() - or - exists(AstNode parent | - n.getParentNode() = parent and - supersededByAttributeMacroExpansion(parent) and - // Don't exclude expansions themselves as they supercede other nodes. - not n = parent.(Item).getAttributeMacroExpansion() and - // Don't consider attributes themselves to be superseded. E.g., in `#[a] fn - // f() {}` the macro expansion supercedes `fn f() {}` but not `#[a]`. - not n instanceof Attr - ) -} - /** * An item that may be referred to by a path, and which is a node in * the _item graph_. @@ -186,10 +168,7 @@ predicate supersededByAttributeMacroExpansion(AstNode n) { * - https://doc.rust-lang.org/reference/names/namespaces.html */ abstract class ItemNode extends Locatable { - ItemNode() { - // Exclude items that are superseded by the expansion of an attribute macro. - not supersededByAttributeMacroExpansion(this) - } + ItemNode() { not this.(Item).hasAttributeMacroExpansion() } /** Gets the (original) name of this item. */ abstract string getName(); diff --git a/rust/ql/lib/utils/test/PathResolutionInlineExpectationsTest.qll b/rust/ql/lib/utils/test/PathResolutionInlineExpectationsTest.qll index f7606b941ace..d8b2703203dc 100644 --- a/rust/ql/lib/utils/test/PathResolutionInlineExpectationsTest.qll +++ b/rust/ql/lib/utils/test/PathResolutionInlineExpectationsTest.qll @@ -10,9 +10,8 @@ private import utils.test.InlineExpectationsTest private module ResolveTest implements TestSig { string getARelevantTag() { result = "item" } - private predicate itemAt(ItemNode i, string filepath, int line, boolean inMacro) { - i.getLocation().hasLocationInfo(filepath, _, _, line, _) and - if i.(AstNode).isInMacroExpansion() then inMacro = true else inMacro = false + private predicate itemAt(ItemNode i, string filepath, int line) { + i.getLocation().hasLocationInfo(filepath, _, _, line, _) } private predicate commmentAt(string text, string filepath, int line) { @@ -25,7 +24,7 @@ private module ResolveTest implements TestSig { } private predicate item(ItemNode i, string value) { - exists(string filepath, int line, boolean inMacro | itemAt(i, filepath, line, inMacro) | + exists(string filepath, int line | itemAt(i, filepath, line) | if i instanceof SourceFile then value = i.getFile().getBaseName() else ( diff --git a/rust/ql/src/queries/unusedentities/UnreachableCode.ql b/rust/ql/src/queries/unusedentities/UnreachableCode.ql index 15a45c6f4b58..bb9092fb5703 100644 --- a/rust/ql/src/queries/unusedentities/UnreachableCode.ql +++ b/rust/ql/src/queries/unusedentities/UnreachableCode.ql @@ -33,7 +33,7 @@ predicate hiddenNode(AstNode n) { n instanceof ControlFlowGraphImpl::PostOrderTree and // location is counter-intuitive not n instanceof MacroExpr or - n.isInMacroExpansion() + n.isFromMacroExpansion() } /** diff --git a/rust/ql/src/queries/unusedentities/UnusedValue.ql b/rust/ql/src/queries/unusedentities/UnusedValue.ql index 14204a2273b7..07e80b00b45a 100644 --- a/rust/ql/src/queries/unusedentities/UnusedValue.ql +++ b/rust/ql/src/queries/unusedentities/UnusedValue.ql @@ -18,7 +18,7 @@ from AstNode write, Ssa::Variable v where variableWrite(_, write, v) and not v instanceof DiscardVariable and - not write.isInMacroExpansion() and + not write.isFromMacroExpansion() and not isAllowableUnused(v) and // SSA definitions are only created for live writes not write = any(Ssa::WriteDefinition def).getWriteAccess().getAstNode() and diff --git a/rust/ql/src/queries/unusedentities/UnusedVariable.qll b/rust/ql/src/queries/unusedentities/UnusedVariable.qll index ad75415634c6..c0684636e77b 100644 --- a/rust/ql/src/queries/unusedentities/UnusedVariable.qll +++ b/rust/ql/src/queries/unusedentities/UnusedVariable.qll @@ -36,7 +36,7 @@ class IncompleteCallable extends Callable { */ predicate isAllowableUnused(Variable v) { // in a macro expansion - v.getPat().isInMacroExpansion() + v.getPat().isInMacroExpansion() // TODO: replace with `isFromMacroExpansion()` when false positives have been removed or // declared in an incomplete callable v.getEnclosingCfgScope() instanceof IncompleteCallable diff --git a/rust/ql/test/extractor-tests/macro-expansion/PrintAst.expected b/rust/ql/test/extractor-tests/macro-expansion/PrintAst.expected index ffff0f53e7e5..1a0ded6950d3 100644 --- a/rust/ql/test/extractor-tests/macro-expansion/PrintAst.expected +++ b/rust/ql/test/extractor-tests/macro-expansion/PrintAst.expected @@ -174,7 +174,7 @@ macro_expansion.rs: # 1| getPath(): [Path] MyTrait # 1| getSegment(): [PathSegment] MyTrait # 1| getIdentifier(): [NameRef] MyTrait -# 3| getItem(1): [Function] fn foo +# 3| getItem(1): [Function] (item with attribute macro expansion) # 4| getAttributeMacroExpansion(): [MacroItems] MacroItems # 4| getItem(0): [Function] fn foo # 4| getParamList(): [ParamList] ParamList @@ -190,7 +190,7 @@ macro_expansion.rs: # 5| getIdentifier(): [NameRef] concat # 5| getTokenTree(): [TokenTree] TokenTree # 5| getMacroCallExpansion(): [StringLiteralExpr] "Hello world!" -# 7| getStatement(1): [Function] fn inner +# 7| getStatement(1): [Function] (item with attribute macro expansion) # 8| getAttributeMacroExpansion(): [MacroItems] MacroItems # 8| getItem(0): [Function] fn inner_0 # 8| getParamList(): [ParamList] ParamList @@ -202,16 +202,12 @@ macro_expansion.rs: # 8| getFunctionBody(): [BlockExpr] { ... } # 8| getStmtList(): [StmtList] StmtList # 8| getName(): [Name] inner_1 -# 8| getParamList(): [ParamList] ParamList # 7| getAttr(0): [Attr] Attr # 7| getMeta(): [Meta] Meta # 7| getPath(): [Path] repeat # 7| getSegment(): [PathSegment] repeat # 7| getIdentifier(): [NameRef] repeat # 7| getTokenTree(): [TokenTree] TokenTree -# 8| getFunctionBody(): [BlockExpr] { ... } -# 8| getStmtList(): [StmtList] StmtList -# 8| getName(): [Name] inner # 10| getStatement(2): [ExprStmt] ExprStmt # 10| getExpr(): [CallExpr] inner_0(...) # 10| getArgList(): [ArgList] ArgList @@ -242,7 +238,7 @@ macro_expansion.rs: # 5| getIdentifier(): [NameRef] concat # 5| getTokenTree(): [TokenTree] TokenTree # 5| getMacroCallExpansion(): [StringLiteralExpr] "Hello world!" -# 7| getStatement(1): [Function] fn inner +# 7| getStatement(1): [Function] (item with attribute macro expansion) # 8| getAttributeMacroExpansion(): [MacroItems] MacroItems # 8| getItem(0): [Function] fn inner_0 # 8| getParamList(): [ParamList] ParamList @@ -254,16 +250,12 @@ macro_expansion.rs: # 8| getFunctionBody(): [BlockExpr] { ... } # 8| getStmtList(): [StmtList] StmtList # 8| getName(): [Name] inner_1 -# 8| getParamList(): [ParamList] ParamList # 7| getAttr(0): [Attr] Attr # 7| getMeta(): [Meta] Meta # 7| getPath(): [Path] repeat # 7| getSegment(): [PathSegment] repeat # 7| getIdentifier(): [NameRef] repeat # 7| getTokenTree(): [TokenTree] TokenTree -# 8| getFunctionBody(): [BlockExpr] { ... } -# 8| getStmtList(): [StmtList] StmtList -# 8| getName(): [Name] inner # 10| getStatement(2): [ExprStmt] ExprStmt # 10| getExpr(): [CallExpr] inner_0(...) # 10| getArgList(): [ArgList] ArgList @@ -280,53 +272,14 @@ macro_expansion.rs: # 11| getIdentifier(): [NameRef] inner_1 # 4| getName(): [Name] foo_new # 4| getVisibility(): [Visibility] Visibility -# 4| getParamList(): [ParamList] ParamList # 3| getAttr(0): [Attr] Attr # 3| getMeta(): [Meta] Meta # 3| getPath(): [Path] add_one # 3| getSegment(): [PathSegment] add_one # 3| getIdentifier(): [NameRef] add_one -# 4| getFunctionBody(): [BlockExpr] { ... } -# 4| getStmtList(): [StmtList] StmtList -# 5| getStatement(0): [ExprStmt] ExprStmt -# 5| getExpr(): [AssignmentExpr] ... = ... -# 5| getLhs(): [UnderscoreExpr] _ -# 5| getRhs(): [MacroExpr] MacroExpr -# 5| getMacroCall(): [MacroCall] concat!... -# 5| getPath(): [Path] concat -# 5| getSegment(): [PathSegment] concat -# 5| getIdentifier(): [NameRef] concat -# 5| getTokenTree(): [TokenTree] TokenTree -# 7| getStatement(1): [Function] fn inner -# 8| getParamList(): [ParamList] ParamList -# 7| getAttr(0): [Attr] Attr -# 7| getMeta(): [Meta] Meta -# 7| getPath(): [Path] repeat -# 7| getSegment(): [PathSegment] repeat -# 7| getIdentifier(): [NameRef] repeat -# 7| getTokenTree(): [TokenTree] TokenTree -# 8| getFunctionBody(): [BlockExpr] { ... } -# 8| getStmtList(): [StmtList] StmtList -# 8| getName(): [Name] inner -# 10| getStatement(2): [ExprStmt] ExprStmt -# 10| getExpr(): [CallExpr] inner_0(...) -# 10| getArgList(): [ArgList] ArgList -# 10| getFunction(): [PathExpr] inner_0 -# 10| getPath(): [Path] inner_0 -# 10| getSegment(): [PathSegment] inner_0 -# 10| getIdentifier(): [NameRef] inner_0 -# 11| getStatement(3): [ExprStmt] ExprStmt -# 11| getExpr(): [CallExpr] inner_1(...) -# 11| getArgList(): [ArgList] ArgList -# 11| getFunction(): [PathExpr] inner_1 -# 11| getPath(): [Path] inner_1 -# 11| getSegment(): [PathSegment] inner_1 -# 11| getIdentifier(): [NameRef] inner_1 -# 4| getName(): [Name] foo -# 4| getVisibility(): [Visibility] Visibility -# 14| getItem(2): [Function] fn bar +# 14| getItem(2): [Function] (item with attribute macro expansion) # 15| getAttributeMacroExpansion(): [MacroItems] MacroItems -# 15| getItem(0): [Function] fn bar_0 +# 15| getItem(0): [Function] (item with attribute macro expansion) # 16| getAttributeMacroExpansion(): [MacroItems] MacroItems # 16| getItem(0): [Function] fn bar_0 # 16| getParamList(): [ParamList] ParamList @@ -340,17 +293,12 @@ macro_expansion.rs: # 16| getStmtList(): [StmtList] StmtList # 16| getName(): [Name] bar_0_new # 16| getVisibility(): [Visibility] Visibility -# 16| getParamList(): [ParamList] ParamList # 15| getAttr(0): [Attr] Attr # 15| getMeta(): [Meta] Meta # 15| getPath(): [Path] add_one # 15| getSegment(): [PathSegment] add_one # 15| getIdentifier(): [NameRef] add_one -# 16| getFunctionBody(): [BlockExpr] { ... } -# 16| getStmtList(): [StmtList] StmtList -# 16| getName(): [Name] bar_0 -# 16| getVisibility(): [Visibility] Visibility -# 15| getItem(1): [Function] fn bar_1 +# 15| getItem(1): [Function] (item with attribute macro expansion) # 16| getAttributeMacroExpansion(): [MacroItems] MacroItems # 16| getItem(0): [Function] fn bar_1 # 16| getParamList(): [ParamList] ParamList @@ -364,17 +312,11 @@ macro_expansion.rs: # 16| getStmtList(): [StmtList] StmtList # 16| getName(): [Name] bar_1_new # 16| getVisibility(): [Visibility] Visibility -# 16| getParamList(): [ParamList] ParamList # 15| getAttr(0): [Attr] Attr # 15| getMeta(): [Meta] Meta # 15| getPath(): [Path] add_one # 15| getSegment(): [PathSegment] add_one # 15| getIdentifier(): [NameRef] add_one -# 16| getFunctionBody(): [BlockExpr] { ... } -# 16| getStmtList(): [StmtList] StmtList -# 16| getName(): [Name] bar_1 -# 16| getVisibility(): [Visibility] Visibility -# 16| getParamList(): [ParamList] ParamList # 14| getAttr(0): [Attr] Attr # 14| getMeta(): [Meta] Meta # 14| getPath(): [Path] repeat @@ -386,22 +328,13 @@ macro_expansion.rs: # 15| getPath(): [Path] add_one # 15| getSegment(): [PathSegment] add_one # 15| getIdentifier(): [NameRef] add_one -# 16| getFunctionBody(): [BlockExpr] { ... } -# 16| getStmtList(): [StmtList] StmtList -# 16| getName(): [Name] bar -# 16| getVisibility(): [Visibility] Visibility -# 18| getItem(3): [Function] fn baz +# 18| getItem(3): [Function] (item with attribute macro expansion) # 18| getAttributeMacroExpansion(): [MacroItems] MacroItems -# 19| getParamList(): [ParamList] ParamList # 18| getAttr(0): [Attr] Attr # 18| getMeta(): [Meta] Meta # 18| getPath(): [Path] erase # 18| getSegment(): [PathSegment] erase # 18| getIdentifier(): [NameRef] erase -# 19| getFunctionBody(): [BlockExpr] { ... } -# 19| getStmtList(): [StmtList] StmtList -# 19| getName(): [Name] baz -# 19| getVisibility(): [Visibility] Visibility # 22| getItem(4): [MacroRules] MacroRules # 22| getName(): [Name] hello # 22| getTokenTree(): [TokenTree] TokenTree @@ -410,7 +343,7 @@ macro_expansion.rs: # 28| getVisibility(): [Visibility] Visibility # 30| getItem(6): [Impl] impl S { ... } # 30| getAssocItemList(): [AssocItemList] AssocItemList -# 31| getAssocItem(0): [Function] fn bzz +# 31| getAssocItem(0): [Function] (item with attribute macro expansion) # 32| getAttributeMacroExpansion(): [MacroItems] MacroItems # 32| getItem(0): [Function] fn bzz_0 # 32| getParamList(): [ParamList] ParamList @@ -556,24 +489,12 @@ macro_expansion.rs: # 31| getIdentifier(): [NameRef] _print # 32| getName(): [Name] bzz_2 # 32| getVisibility(): [Visibility] Visibility -# 32| getParamList(): [ParamList] ParamList # 31| getAttr(0): [Attr] Attr # 31| getMeta(): [Meta] Meta # 31| getPath(): [Path] repeat # 31| getSegment(): [PathSegment] repeat # 31| getIdentifier(): [NameRef] repeat # 31| getTokenTree(): [TokenTree] TokenTree -# 32| getFunctionBody(): [BlockExpr] { ... } -# 32| getStmtList(): [StmtList] StmtList -# 33| getStatement(0): [ExprStmt] ExprStmt -# 33| getExpr(): [MacroExpr] MacroExpr -# 33| getMacroCall(): [MacroCall] hello!... -# 33| getPath(): [Path] hello -# 33| getSegment(): [PathSegment] hello -# 33| getIdentifier(): [NameRef] hello -# 33| getTokenTree(): [TokenTree] TokenTree -# 32| getName(): [Name] bzz -# 32| getVisibility(): [Visibility] Visibility # 30| getSelfTy(): [PathTypeRepr] S # 30| getPath(): [Path] S # 30| getSegment(): [PathSegment] S diff --git a/rust/ql/test/extractor-tests/macro-expansion/test.expected b/rust/ql/test/extractor-tests/macro-expansion/test.expected index 930a0f443bd8..5abff30113bc 100644 --- a/rust/ql/test/extractor-tests/macro-expansion/test.expected +++ b/rust/ql/test/extractor-tests/macro-expansion/test.expected @@ -1,19 +1,19 @@ attribute_macros -| macro_expansion.rs:3:1:12:1 | fn foo | 0 | macro_expansion.rs:4:1:12:1 | fn foo | -| macro_expansion.rs:3:1:12:1 | fn foo | 1 | macro_expansion.rs:4:1:12:1 | fn foo_new | -| macro_expansion.rs:7:5:8:17 | fn inner | 0 | macro_expansion.rs:8:5:8:17 | fn inner_0 | -| macro_expansion.rs:7:5:8:17 | fn inner | 0 | macro_expansion.rs:8:5:8:17 | fn inner_0 | -| macro_expansion.rs:7:5:8:17 | fn inner | 1 | macro_expansion.rs:8:5:8:17 | fn inner_1 | -| macro_expansion.rs:7:5:8:17 | fn inner | 1 | macro_expansion.rs:8:5:8:17 | fn inner_1 | -| macro_expansion.rs:14:1:16:15 | fn bar | 0 | macro_expansion.rs:15:1:16:15 | fn bar_0 | -| macro_expansion.rs:14:1:16:15 | fn bar | 1 | macro_expansion.rs:15:1:16:15 | fn bar_1 | -| macro_expansion.rs:15:1:16:15 | fn bar_0 | 0 | macro_expansion.rs:16:1:16:15 | fn bar_0 | -| macro_expansion.rs:15:1:16:15 | fn bar_0 | 1 | macro_expansion.rs:16:1:16:15 | fn bar_0_new | -| macro_expansion.rs:15:1:16:15 | fn bar_1 | 0 | macro_expansion.rs:16:1:16:15 | fn bar_1 | -| macro_expansion.rs:15:1:16:15 | fn bar_1 | 1 | macro_expansion.rs:16:1:16:15 | fn bar_1_new | -| macro_expansion.rs:31:5:34:5 | fn bzz | 0 | macro_expansion.rs:32:5:34:5 | fn bzz_0 | -| macro_expansion.rs:31:5:34:5 | fn bzz | 1 | macro_expansion.rs:32:5:34:5 | fn bzz_1 | -| macro_expansion.rs:31:5:34:5 | fn bzz | 2 | macro_expansion.rs:32:5:34:5 | fn bzz_2 | +| macro_expansion.rs:3:1:12:1 | (item with attribute macro expansion) | 0 | macro_expansion.rs:4:1:12:1 | fn foo | +| macro_expansion.rs:3:1:12:1 | (item with attribute macro expansion) | 1 | macro_expansion.rs:4:1:12:1 | fn foo_new | +| macro_expansion.rs:7:5:8:17 | (item with attribute macro expansion) | 0 | macro_expansion.rs:8:5:8:17 | fn inner_0 | +| macro_expansion.rs:7:5:8:17 | (item with attribute macro expansion) | 0 | macro_expansion.rs:8:5:8:17 | fn inner_0 | +| macro_expansion.rs:7:5:8:17 | (item with attribute macro expansion) | 1 | macro_expansion.rs:8:5:8:17 | fn inner_1 | +| macro_expansion.rs:7:5:8:17 | (item with attribute macro expansion) | 1 | macro_expansion.rs:8:5:8:17 | fn inner_1 | +| macro_expansion.rs:14:1:16:15 | (item with attribute macro expansion) | 0 | macro_expansion.rs:15:1:16:15 | (item with attribute macro expansion) | +| macro_expansion.rs:14:1:16:15 | (item with attribute macro expansion) | 1 | macro_expansion.rs:15:1:16:15 | (item with attribute macro expansion) | +| macro_expansion.rs:15:1:16:15 | (item with attribute macro expansion) | 0 | macro_expansion.rs:16:1:16:15 | fn bar_0 | +| macro_expansion.rs:15:1:16:15 | (item with attribute macro expansion) | 0 | macro_expansion.rs:16:1:16:15 | fn bar_1 | +| macro_expansion.rs:15:1:16:15 | (item with attribute macro expansion) | 1 | macro_expansion.rs:16:1:16:15 | fn bar_0_new | +| macro_expansion.rs:15:1:16:15 | (item with attribute macro expansion) | 1 | macro_expansion.rs:16:1:16:15 | fn bar_1_new | +| macro_expansion.rs:31:5:34:5 | (item with attribute macro expansion) | 0 | macro_expansion.rs:32:5:34:5 | fn bzz_0 | +| macro_expansion.rs:31:5:34:5 | (item with attribute macro expansion) | 1 | macro_expansion.rs:32:5:34:5 | fn bzz_1 | +| macro_expansion.rs:31:5:34:5 | (item with attribute macro expansion) | 2 | macro_expansion.rs:32:5:34:5 | fn bzz_2 | derive_macros | macro_expansion.rs:83:1:86:1 | struct MyDerive | 0 | 0 | macro_expansion.rs:84:8:85:9 | impl ...::Debug for MyDerive::<...> { ... } | | macro_expansion.rs:88:1:92:1 | enum MyDeriveEnum | 0 | 0 | macro_expansion.rs:89:6:91:12 | impl ...::PartialEq for MyDeriveEnum::<...> { ... } | @@ -46,8 +46,6 @@ macro_calls | macro_expansion.rs:79:12:79:20 | my_int!... | macro_expansion.rs:79:12:79:18 | i32 | unexpanded_macro_calls | included/included.rs:2:9:2:39 | concat!... | -| macro_expansion.rs:5:9:5:35 | concat!... | -| macro_expansion.rs:33:9:33:16 | hello!... | | macro_expansion.rs:56:9:56:31 | concat!... | | macro_expansion.rs:63:9:63:32 | include_str!... | warnings diff --git a/rust/ql/test/extractor-tests/macro-in-library/PrintAst.expected b/rust/ql/test/extractor-tests/macro-in-library/PrintAst.expected index b88537912102..30dbc24103b9 100644 --- a/rust/ql/test/extractor-tests/macro-in-library/PrintAst.expected +++ b/rust/ql/test/extractor-tests/macro-in-library/PrintAst.expected @@ -5,7 +5,7 @@ lib.rs: # 1| getVisibility(): [Visibility] Visibility macro_in_library.rs: # 1| [SourceFile] SourceFile -# 1| getItem(0): [MacroCall] +# 1| getItem(0): [MacroCall] (item with attribute macro expansion) # 2| getAttributeMacroExpansion(): [MacroItems] MacroItems # 2| getItem(0): [Function] fn foo # 2| getParamList(): [ParamList] ParamList diff --git a/rust/ql/test/library-tests/dataflow/sources/net/CONSISTENCY/PathResolutionConsistency.expected b/rust/ql/test/library-tests/dataflow/sources/net/CONSISTENCY/PathResolutionConsistency.expected index 352992bf4f2d..ca5c386b720c 100644 --- a/rust/ql/test/library-tests/dataflow/sources/net/CONSISTENCY/PathResolutionConsistency.expected +++ b/rust/ql/test/library-tests/dataflow/sources/net/CONSISTENCY/PathResolutionConsistency.expected @@ -7,4 +7,3 @@ multipleCallTargets | test.rs:447:30:447:67 | pinned.poll_read(...) | | test.rs:470:26:470:54 | pinned.poll_fill_buf(...) | | test.rs:519:50:519:66 | ...::from(...) | -| test.rs:519:50:519:66 | ...::from(...) | diff --git a/rust/ql/test/library-tests/dataflow/sources/net/TaintSources.expected b/rust/ql/test/library-tests/dataflow/sources/net/TaintSources.expected index 190628f93d7d..bfe1ce0e56bc 100644 --- a/rust/ql/test/library-tests/dataflow/sources/net/TaintSources.expected +++ b/rust/ql/test/library-tests/dataflow/sources/net/TaintSources.expected @@ -15,4 +15,3 @@ | test.rs:332:22:332:50 | ...::new | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:373:19:373:36 | ...::connect | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:519:16:519:29 | ...::args | Flow source 'CommandLineArgs' of type commandargs (DEFAULT). | -| test.rs:519:16:519:29 | ...::args | Flow source 'CommandLineArgs' of type commandargs (DEFAULT). | diff --git a/rust/ql/test/library-tests/dataflow/sources/web_frameworks/InlineFlow.expected b/rust/ql/test/library-tests/dataflow/sources/web_frameworks/InlineFlow.expected index e128916f8473..24a0cf78aec0 100644 --- a/rust/ql/test/library-tests/dataflow/sources/web_frameworks/InlineFlow.expected +++ b/rust/ql/test/library-tests/dataflow/sources/web_frameworks/InlineFlow.expected @@ -12,20 +12,12 @@ models | 11 | Summary: ::as_str; Argument[self]; ReturnValue; value | edges | test.rs:11:31:11:31 | a | test.rs:13:14:13:14 | a | provenance | | -| test.rs:11:31:11:31 | a | test.rs:13:14:13:14 | a | provenance | | -| test.rs:11:31:11:31 | a | test.rs:13:14:13:23 | a.as_str() | provenance | MaD:11 | | test.rs:11:31:11:31 | a | test.rs:13:14:13:23 | a.as_str() | provenance | MaD:11 | | test.rs:11:31:11:31 | a | test.rs:14:14:14:14 | a | provenance | | -| test.rs:11:31:11:31 | a | test.rs:14:14:14:14 | a | provenance | | | test.rs:11:31:11:31 | a | test.rs:14:14:14:25 | a.as_bytes() | provenance | MaD:10 | -| test.rs:11:31:11:31 | a | test.rs:14:14:14:25 | a.as_bytes() | provenance | MaD:10 | -| test.rs:11:31:11:31 | a | test.rs:15:14:15:14 | a | provenance | | | test.rs:11:31:11:31 | a | test.rs:15:14:15:14 | a | provenance | | | test.rs:13:14:13:14 | a | test.rs:13:14:13:23 | a.as_str() | provenance | MaD:11 | -| test.rs:13:14:13:14 | a | test.rs:13:14:13:23 | a.as_str() | provenance | MaD:11 | | test.rs:14:14:14:14 | a | test.rs:14:14:14:25 | a.as_bytes() | provenance | MaD:10 | -| test.rs:14:14:14:14 | a | test.rs:14:14:14:25 | a.as_bytes() | provenance | MaD:10 | -| test.rs:68:15:68:15 | a | test.rs:70:14:70:14 | a | provenance | | | test.rs:68:15:68:15 | a | test.rs:70:14:70:14 | a | provenance | | | test.rs:98:9:98:31 | ...: ...::Path::<...> | test.rs:100:17:100:33 | path.into_inner() | provenance | MaD:9 | | test.rs:98:9:98:31 | ...: ...::Path::<...> | test.rs:100:17:100:33 | path.into_inner() [tuple.0] | provenance | MaD:6 | @@ -87,37 +79,21 @@ edges | test.rs:139:41:139:42 | to | test.rs:98:9:98:31 | ...: ...::Path::<...> | provenance | Src:MaD:5 | | test.rs:140:45:140:46 | to | test.rs:109:9:109:41 | ...: ...::Path::<...> | provenance | Src:MaD:5 | | test.rs:242:33:242:35 | map | test.rs:242:38:242:46 | ...: String | provenance | Src:MaD:2 | -| test.rs:242:33:242:35 | map | test.rs:242:38:242:46 | ...: String | provenance | Src:MaD:2 | | test.rs:242:38:242:46 | ...: String | test.rs:244:18:244:18 | a | provenance | | -| test.rs:242:38:242:46 | ...: String | test.rs:244:18:244:18 | a | provenance | | -| test.rs:250:46:250:49 | then | test.rs:251:25:251:33 | ...: String | provenance | Src:MaD:3 | | test.rs:250:46:250:49 | then | test.rs:251:25:251:33 | ...: String | provenance | Src:MaD:3 | | test.rs:251:25:251:33 | ...: String | test.rs:252:22:252:22 | a | provenance | | -| test.rs:251:25:251:33 | ...: String | test.rs:252:22:252:22 | a | provenance | | -| test.rs:259:50:259:57 | and_then | test.rs:260:26:260:32 | ...: u64 | provenance | Src:MaD:1 | | test.rs:259:50:259:57 | and_then | test.rs:260:26:260:32 | ...: u64 | provenance | Src:MaD:1 | | test.rs:260:26:260:32 | ...: u64 | test.rs:263:22:263:23 | id | provenance | | -| test.rs:260:26:260:32 | ...: u64 | test.rs:263:22:263:23 | id | provenance | | | test.rs:272:75:272:77 | map | test.rs:273:15:273:23 | ...: String | provenance | Src:MaD:2 | -| test.rs:272:75:272:77 | map | test.rs:273:15:273:23 | ...: String | provenance | Src:MaD:2 | -| test.rs:273:15:273:23 | ...: String | test.rs:275:22:275:22 | a | provenance | | | test.rs:273:15:273:23 | ...: String | test.rs:275:22:275:22 | a | provenance | | nodes | test.rs:11:31:11:31 | a | semmle.label | a | -| test.rs:11:31:11:31 | a | semmle.label | a | | test.rs:13:14:13:14 | a | semmle.label | a | -| test.rs:13:14:13:14 | a | semmle.label | a | -| test.rs:13:14:13:23 | a.as_str() | semmle.label | a.as_str() | | test.rs:13:14:13:23 | a.as_str() | semmle.label | a.as_str() | | test.rs:14:14:14:14 | a | semmle.label | a | -| test.rs:14:14:14:14 | a | semmle.label | a | | test.rs:14:14:14:25 | a.as_bytes() | semmle.label | a.as_bytes() | -| test.rs:14:14:14:25 | a.as_bytes() | semmle.label | a.as_bytes() | -| test.rs:15:14:15:14 | a | semmle.label | a | | test.rs:15:14:15:14 | a | semmle.label | a | | test.rs:68:15:68:15 | a | semmle.label | a | -| test.rs:68:15:68:15 | a | semmle.label | a | -| test.rs:70:14:70:14 | a | semmle.label | a | | test.rs:70:14:70:14 | a | semmle.label | a | | test.rs:98:9:98:31 | ...: ...::Path::<...> | semmle.label | ...: ...::Path::<...> | | test.rs:100:13:100:13 | a | semmle.label | a | @@ -162,39 +138,23 @@ nodes | test.rs:139:41:139:42 | to | semmle.label | to | | test.rs:140:45:140:46 | to | semmle.label | to | | test.rs:242:33:242:35 | map | semmle.label | map | -| test.rs:242:33:242:35 | map | semmle.label | map | | test.rs:242:38:242:46 | ...: String | semmle.label | ...: String | -| test.rs:242:38:242:46 | ...: String | semmle.label | ...: String | -| test.rs:244:18:244:18 | a | semmle.label | a | | test.rs:244:18:244:18 | a | semmle.label | a | | test.rs:250:46:250:49 | then | semmle.label | then | -| test.rs:250:46:250:49 | then | semmle.label | then | | test.rs:251:25:251:33 | ...: String | semmle.label | ...: String | -| test.rs:251:25:251:33 | ...: String | semmle.label | ...: String | -| test.rs:252:22:252:22 | a | semmle.label | a | | test.rs:252:22:252:22 | a | semmle.label | a | | test.rs:259:50:259:57 | and_then | semmle.label | and_then | -| test.rs:259:50:259:57 | and_then | semmle.label | and_then | | test.rs:260:26:260:32 | ...: u64 | semmle.label | ...: u64 | -| test.rs:260:26:260:32 | ...: u64 | semmle.label | ...: u64 | -| test.rs:263:22:263:23 | id | semmle.label | id | | test.rs:263:22:263:23 | id | semmle.label | id | | test.rs:272:75:272:77 | map | semmle.label | map | -| test.rs:272:75:272:77 | map | semmle.label | map | -| test.rs:273:15:273:23 | ...: String | semmle.label | ...: String | | test.rs:273:15:273:23 | ...: String | semmle.label | ...: String | | test.rs:275:22:275:22 | a | semmle.label | a | -| test.rs:275:22:275:22 | a | semmle.label | a | subpaths testFailures #select | test.rs:13:14:13:23 | a.as_str() | test.rs:11:31:11:31 | a | test.rs:13:14:13:23 | a.as_str() | $@ | test.rs:11:31:11:31 | a | a | -| test.rs:13:14:13:23 | a.as_str() | test.rs:11:31:11:31 | a | test.rs:13:14:13:23 | a.as_str() | $@ | test.rs:11:31:11:31 | a | a | -| test.rs:14:14:14:25 | a.as_bytes() | test.rs:11:31:11:31 | a | test.rs:14:14:14:25 | a.as_bytes() | $@ | test.rs:11:31:11:31 | a | a | | test.rs:14:14:14:25 | a.as_bytes() | test.rs:11:31:11:31 | a | test.rs:14:14:14:25 | a.as_bytes() | $@ | test.rs:11:31:11:31 | a | a | | test.rs:15:14:15:14 | a | test.rs:11:31:11:31 | a | test.rs:15:14:15:14 | a | $@ | test.rs:11:31:11:31 | a | a | -| test.rs:15:14:15:14 | a | test.rs:11:31:11:31 | a | test.rs:15:14:15:14 | a | $@ | test.rs:11:31:11:31 | a | a | -| test.rs:70:14:70:14 | a | test.rs:68:15:68:15 | a | test.rs:70:14:70:14 | a | $@ | test.rs:68:15:68:15 | a | a | | test.rs:70:14:70:14 | a | test.rs:68:15:68:15 | a | test.rs:70:14:70:14 | a | $@ | test.rs:68:15:68:15 | a | a | | test.rs:101:14:101:23 | a.as_str() | test.rs:139:41:139:42 | to | test.rs:101:14:101:23 | a.as_str() | $@ | test.rs:139:41:139:42 | to | to | | test.rs:102:14:102:25 | a.as_bytes() | test.rs:139:41:139:42 | to | test.rs:102:14:102:25 | a.as_bytes() | $@ | test.rs:139:41:139:42 | to | to | @@ -203,10 +163,6 @@ testFailures | test.rs:114:14:114:14 | b | test.rs:140:45:140:46 | to | test.rs:114:14:114:14 | b | $@ | test.rs:140:45:140:46 | to | to | | test.rs:132:14:132:14 | a | test.rs:127:5:127:20 | to | test.rs:132:14:132:14 | a | $@ | test.rs:127:5:127:20 | to | to | | test.rs:244:18:244:18 | a | test.rs:242:33:242:35 | map | test.rs:244:18:244:18 | a | $@ | test.rs:242:33:242:35 | map | map | -| test.rs:244:18:244:18 | a | test.rs:242:33:242:35 | map | test.rs:244:18:244:18 | a | $@ | test.rs:242:33:242:35 | map | map | -| test.rs:252:22:252:22 | a | test.rs:250:46:250:49 | then | test.rs:252:22:252:22 | a | $@ | test.rs:250:46:250:49 | then | then | | test.rs:252:22:252:22 | a | test.rs:250:46:250:49 | then | test.rs:252:22:252:22 | a | $@ | test.rs:250:46:250:49 | then | then | | test.rs:263:22:263:23 | id | test.rs:259:50:259:57 | and_then | test.rs:263:22:263:23 | id | $@ | test.rs:259:50:259:57 | and_then | and_then | -| test.rs:263:22:263:23 | id | test.rs:259:50:259:57 | and_then | test.rs:263:22:263:23 | id | $@ | test.rs:259:50:259:57 | and_then | and_then | -| test.rs:275:22:275:22 | a | test.rs:272:75:272:77 | map | test.rs:275:22:275:22 | a | $@ | test.rs:272:75:272:77 | map | map | | test.rs:275:22:275:22 | a | test.rs:272:75:272:77 | map | test.rs:275:22:275:22 | a | $@ | test.rs:272:75:272:77 | map | map | diff --git a/rust/ql/test/library-tests/dataflow/sources/web_frameworks/TaintSources.expected b/rust/ql/test/library-tests/dataflow/sources/web_frameworks/TaintSources.expected index 549f9c4ab762..20a20ce3f9b1 100644 --- a/rust/ql/test/library-tests/dataflow/sources/web_frameworks/TaintSources.expected +++ b/rust/ql/test/library-tests/dataflow/sources/web_frameworks/TaintSources.expected @@ -1,12 +1,7 @@ | test.rs:11:31:11:31 | a | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:11:31:11:31 | a | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:22:14:22:19 | TuplePat | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:22:14:22:19 | TuplePat | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:48:14:48:30 | MyStruct {...} | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:48:14:48:30 | MyStruct {...} | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:58:14:58:15 | ms | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:58:14:58:15 | ms | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:68:15:68:15 | a | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:68:15:68:15 | a | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:127:5:127:20 | to | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:127:5:127:20 | to | Flow source 'RemoteSource' of type remote (DEFAULT). | @@ -48,20 +43,6 @@ | test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:242:33:242:35 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | @@ -70,15 +51,6 @@ | test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:250:46:250:49 | then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | @@ -87,15 +59,6 @@ | test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:259:50:259:57 | and_then | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | -| test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | | test.rs:272:75:272:77 | map | Flow source 'RemoteSource' of type remote (DEFAULT). | diff --git a/rust/ql/test/library-tests/variables/variables.ql b/rust/ql/test/library-tests/variables/variables.ql index dbde4f56e858..9997b29c7d0e 100644 --- a/rust/ql/test/library-tests/variables/variables.ql +++ b/rust/ql/test/library-tests/variables/variables.ql @@ -35,7 +35,7 @@ module VariableAccessTest implements TestSig { private predicate declAt(Variable v, string filepath, int line, boolean inMacro) { variable(v) and v.getLocation().hasLocationInfo(filepath, _, _, line, _) and - if v.getPat().isInMacroExpansion() then inMacro = true else inMacro = false + if v.getPat().isFromMacroExpansion() then inMacro = true else inMacro = false } private predicate commmentAt(string text, string filepath, int line) { diff --git a/rust/ql/test/query-tests/security/CWE-696/CONSISTENCY/PathResolutionConsistency.expected b/rust/ql/test/query-tests/security/CWE-696/CONSISTENCY/PathResolutionConsistency.expected index b1c7e787dee5..538ecf9c2e35 100644 --- a/rust/ql/test/query-tests/security/CWE-696/CONSISTENCY/PathResolutionConsistency.expected +++ b/rust/ql/test/query-tests/security/CWE-696/CONSISTENCY/PathResolutionConsistency.expected @@ -1,3 +1,2 @@ multipleCallTargets | test.rs:117:9:117:21 | ptr.is_null() | -| test.rs:117:9:117:21 | ptr.is_null() | diff --git a/rust/ql/test/query-tests/security/CWE-918/CONSISTENCY/PathResolutionConsistency.expected b/rust/ql/test/query-tests/security/CWE-918/CONSISTENCY/PathResolutionConsistency.expected index 5caae105914c..821f75cee26d 100644 --- a/rust/ql/test/query-tests/security/CWE-918/CONSISTENCY/PathResolutionConsistency.expected +++ b/rust/ql/test/query-tests/security/CWE-918/CONSISTENCY/PathResolutionConsistency.expected @@ -1,3 +1,2 @@ multipleCallTargets | request_forgery_tests.rs:30:36:30:52 | user_url.as_str() | -| request_forgery_tests.rs:30:36:30:52 | user_url.as_str() | diff --git a/rust/ql/test/query-tests/security/CWE-918/RequestForgery.expected b/rust/ql/test/query-tests/security/CWE-918/RequestForgery.expected index aa5003a0e9d3..0f931ed3a0f8 100644 --- a/rust/ql/test/query-tests/security/CWE-918/RequestForgery.expected +++ b/rust/ql/test/query-tests/security/CWE-918/RequestForgery.expected @@ -1,29 +1,20 @@ #select | request_forgery_tests.rs:8:24:8:35 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:8:24:8:35 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | -| request_forgery_tests.rs:8:24:8:35 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:8:24:8:35 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | | request_forgery_tests.rs:17:25:17:36 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:17:25:17:36 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | | request_forgery_tests.rs:21:25:21:36 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:21:25:21:36 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | | request_forgery_tests.rs:25:25:25:36 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:25:25:25:36 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | | request_forgery_tests.rs:31:29:31:40 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:31:29:31:40 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | -| request_forgery_tests.rs:31:29:31:40 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:31:29:31:40 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | | request_forgery_tests.rs:37:37:37:48 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:37:37:37:48 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | -| request_forgery_tests.rs:37:37:37:48 | ...::get | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:37:37:37:48 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:5:29:5:36 | user_url | user-provided value | -| request_forgery_tests.rs:68:28:68:39 | ...::get | request_forgery_tests.rs:65:33:65:40 | and_then | request_forgery_tests.rs:68:28:68:39 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:65:33:65:40 | and_then | user-provided value | | request_forgery_tests.rs:68:28:68:39 | ...::get | request_forgery_tests.rs:65:33:65:40 | and_then | request_forgery_tests.rs:68:28:68:39 | ...::get | The URL of this request depends on a $@. | request_forgery_tests.rs:65:33:65:40 | and_then | user-provided value | edges | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:8:38:8:45 | user_url | provenance | | -| request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:8:38:8:45 | user_url | provenance | | | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:16:27:16:49 | MacroExpr | provenance | | | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:20:27:20:57 | MacroExpr | provenance | | | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:24:27:24:70 | MacroExpr | provenance | | | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:31:43:31:50 | user_url | provenance | | -| request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:31:43:31:50 | user_url | provenance | | | request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:37:51:37:58 | user_url | provenance | | -| request_forgery_tests.rs:5:29:5:36 | user_url | request_forgery_tests.rs:37:51:37:58 | user_url | provenance | | -| request_forgery_tests.rs:8:37:8:45 | &user_url [&ref] | request_forgery_tests.rs:8:24:8:35 | ...::get | provenance | MaD:1 Sink:MaD:1 | | request_forgery_tests.rs:8:37:8:45 | &user_url [&ref] | request_forgery_tests.rs:8:24:8:35 | ...::get | provenance | MaD:1 Sink:MaD:1 | | request_forgery_tests.rs:8:38:8:45 | user_url | request_forgery_tests.rs:8:37:8:45 | &user_url [&ref] | provenance | | -| request_forgery_tests.rs:8:38:8:45 | user_url | request_forgery_tests.rs:8:37:8:45 | &user_url [&ref] | provenance | | | request_forgery_tests.rs:16:13:16:15 | url | request_forgery_tests.rs:17:39:17:41 | url | provenance | | | request_forgery_tests.rs:16:27:16:49 | ...::format(...) | request_forgery_tests.rs:16:27:16:49 | { ... } | provenance | | | request_forgery_tests.rs:16:27:16:49 | ...::must_use(...) | request_forgery_tests.rs:16:13:16:15 | url | provenance | | @@ -46,21 +37,13 @@ edges | request_forgery_tests.rs:25:38:25:41 | &url [&ref] | request_forgery_tests.rs:25:25:25:36 | ...::get | provenance | MaD:1 Sink:MaD:1 | | request_forgery_tests.rs:25:39:25:41 | url | request_forgery_tests.rs:25:38:25:41 | &url [&ref] | provenance | | | request_forgery_tests.rs:31:42:31:50 | &user_url [&ref] | request_forgery_tests.rs:31:29:31:40 | ...::get | provenance | MaD:1 Sink:MaD:1 | -| request_forgery_tests.rs:31:42:31:50 | &user_url [&ref] | request_forgery_tests.rs:31:29:31:40 | ...::get | provenance | MaD:1 Sink:MaD:1 | | request_forgery_tests.rs:31:43:31:50 | user_url | request_forgery_tests.rs:31:42:31:50 | &user_url [&ref] | provenance | | -| request_forgery_tests.rs:31:43:31:50 | user_url | request_forgery_tests.rs:31:42:31:50 | &user_url [&ref] | provenance | | -| request_forgery_tests.rs:37:50:37:58 | &user_url [&ref] | request_forgery_tests.rs:37:37:37:48 | ...::get | provenance | MaD:1 Sink:MaD:1 | | request_forgery_tests.rs:37:50:37:58 | &user_url [&ref] | request_forgery_tests.rs:37:37:37:48 | ...::get | provenance | MaD:1 Sink:MaD:1 | | request_forgery_tests.rs:37:51:37:58 | user_url | request_forgery_tests.rs:37:50:37:58 | &user_url [&ref] | provenance | | -| request_forgery_tests.rs:37:51:37:58 | user_url | request_forgery_tests.rs:37:50:37:58 | &user_url [&ref] | provenance | | -| request_forgery_tests.rs:65:33:65:40 | and_then | request_forgery_tests.rs:65:49:65:57 | ...: String | provenance | Src:MaD:2 | | request_forgery_tests.rs:65:33:65:40 | and_then | request_forgery_tests.rs:65:49:65:57 | ...: String | provenance | Src:MaD:2 | | request_forgery_tests.rs:65:49:65:57 | ...: String | request_forgery_tests.rs:68:42:68:42 | a | provenance | | -| request_forgery_tests.rs:65:49:65:57 | ...: String | request_forgery_tests.rs:68:42:68:42 | a | provenance | | -| request_forgery_tests.rs:68:41:68:42 | &a [&ref] | request_forgery_tests.rs:68:28:68:39 | ...::get | provenance | MaD:1 Sink:MaD:1 | | request_forgery_tests.rs:68:41:68:42 | &a [&ref] | request_forgery_tests.rs:68:28:68:39 | ...::get | provenance | MaD:1 Sink:MaD:1 | | request_forgery_tests.rs:68:42:68:42 | a | request_forgery_tests.rs:68:41:68:42 | &a [&ref] | provenance | | -| request_forgery_tests.rs:68:42:68:42 | a | request_forgery_tests.rs:68:41:68:42 | &a [&ref] | provenance | | models | 1 | Sink: reqwest::get; Argument[0]; request-url | | 2 | Source: <_ as warp::filter::Filter>::and_then; Argument[0].Parameter[0..7]; remote | @@ -68,13 +51,9 @@ models | 4 | Summary: core::hint::must_use; Argument[0]; ReturnValue; value | nodes | request_forgery_tests.rs:5:29:5:36 | user_url | semmle.label | user_url | -| request_forgery_tests.rs:5:29:5:36 | user_url | semmle.label | user_url | | request_forgery_tests.rs:8:24:8:35 | ...::get | semmle.label | ...::get | -| request_forgery_tests.rs:8:24:8:35 | ...::get | semmle.label | ...::get | -| request_forgery_tests.rs:8:37:8:45 | &user_url [&ref] | semmle.label | &user_url [&ref] | | request_forgery_tests.rs:8:37:8:45 | &user_url [&ref] | semmle.label | &user_url [&ref] | | request_forgery_tests.rs:8:38:8:45 | user_url | semmle.label | user_url | -| request_forgery_tests.rs:8:38:8:45 | user_url | semmle.label | user_url | | request_forgery_tests.rs:16:13:16:15 | url | semmle.label | url | | request_forgery_tests.rs:16:27:16:49 | ...::format(...) | semmle.label | ...::format(...) | | request_forgery_tests.rs:16:27:16:49 | ...::must_use(...) | semmle.label | ...::must_use(...) | @@ -100,25 +79,14 @@ nodes | request_forgery_tests.rs:25:38:25:41 | &url [&ref] | semmle.label | &url [&ref] | | request_forgery_tests.rs:25:39:25:41 | url | semmle.label | url | | request_forgery_tests.rs:31:29:31:40 | ...::get | semmle.label | ...::get | -| request_forgery_tests.rs:31:29:31:40 | ...::get | semmle.label | ...::get | | request_forgery_tests.rs:31:42:31:50 | &user_url [&ref] | semmle.label | &user_url [&ref] | -| request_forgery_tests.rs:31:42:31:50 | &user_url [&ref] | semmle.label | &user_url [&ref] | -| request_forgery_tests.rs:31:43:31:50 | user_url | semmle.label | user_url | | request_forgery_tests.rs:31:43:31:50 | user_url | semmle.label | user_url | | request_forgery_tests.rs:37:37:37:48 | ...::get | semmle.label | ...::get | -| request_forgery_tests.rs:37:37:37:48 | ...::get | semmle.label | ...::get | -| request_forgery_tests.rs:37:50:37:58 | &user_url [&ref] | semmle.label | &user_url [&ref] | | request_forgery_tests.rs:37:50:37:58 | &user_url [&ref] | semmle.label | &user_url [&ref] | | request_forgery_tests.rs:37:51:37:58 | user_url | semmle.label | user_url | -| request_forgery_tests.rs:37:51:37:58 | user_url | semmle.label | user_url | -| request_forgery_tests.rs:65:33:65:40 | and_then | semmle.label | and_then | | request_forgery_tests.rs:65:33:65:40 | and_then | semmle.label | and_then | | request_forgery_tests.rs:65:49:65:57 | ...: String | semmle.label | ...: String | -| request_forgery_tests.rs:65:49:65:57 | ...: String | semmle.label | ...: String | -| request_forgery_tests.rs:68:28:68:39 | ...::get | semmle.label | ...::get | | request_forgery_tests.rs:68:28:68:39 | ...::get | semmle.label | ...::get | | request_forgery_tests.rs:68:41:68:42 | &a [&ref] | semmle.label | &a [&ref] | -| request_forgery_tests.rs:68:41:68:42 | &a [&ref] | semmle.label | &a [&ref] | -| request_forgery_tests.rs:68:42:68:42 | a | semmle.label | a | | request_forgery_tests.rs:68:42:68:42 | a | semmle.label | a | subpaths diff --git a/rust/ql/test/query-tests/unusedentities/UnusedValue.expected b/rust/ql/test/query-tests/unusedentities/UnusedValue.expected index c5f0f59966cb..c52863616626 100644 --- a/rust/ql/test/query-tests/unusedentities/UnusedValue.expected +++ b/rust/ql/test/query-tests/unusedentities/UnusedValue.expected @@ -15,8 +15,10 @@ | main.rs:322:12:322:12 | j | Variable $@ is assigned a value that is never used. | main.rs:322:12:322:12 | j | j | | main.rs:382:9:382:9 | x | Variable $@ is assigned a value that is never used. | main.rs:382:9:382:9 | x | x | | main.rs:390:17:390:17 | x | Variable $@ is assigned a value that is never used. | main.rs:390:17:390:17 | x | x | -| main.rs:536:9:536:20 | var_in_macro | Variable $@ is assigned a value that is never used. | main.rs:536:9:536:20 | var_in_macro | var_in_macro | -| main.rs:545:9:545:9 | c | Variable $@ is assigned a value that is never used. | main.rs:545:9:545:9 | c | c | +| main.rs:491:16:491:16 | a | Variable $@ is assigned a value that is never used. | main.rs:489:9:489:9 | a | a | +| main.rs:516:41:516:41 | x | Variable $@ is assigned a value that is never used. | main.rs:515:9:515:9 | x | x | +| main.rs:530:9:530:20 | var_in_macro | Variable $@ is assigned a value that is never used. | main.rs:530:9:530:20 | var_in_macro | var_in_macro | +| main.rs:539:9:539:9 | c | Variable $@ is assigned a value that is never used. | main.rs:539:9:539:9 | c | c | | more.rs:44:9:44:14 | a_ptr4 | Variable $@ is assigned a value that is never used. | more.rs:44:9:44:14 | a_ptr4 | a_ptr4 | | more.rs:59:9:59:13 | d_ptr | Variable $@ is assigned a value that is never used. | more.rs:59:9:59:13 | d_ptr | d_ptr | | more.rs:65:13:65:17 | f_ptr | Variable $@ is assigned a value that is never used. | more.rs:65:13:65:17 | f_ptr | f_ptr | diff --git a/rust/ql/test/query-tests/unusedentities/main.rs b/rust/ql/test/query-tests/unusedentities/main.rs index 01b7cc14bc8c..a08a05a83bde 100644 --- a/rust/ql/test/query-tests/unusedentities/main.rs +++ b/rust/ql/test/query-tests/unusedentities/main.rs @@ -488,7 +488,7 @@ macro_rules! use_value { fn macros1() { let a: u16; let b: u16 = 2; - set_value!(a, 1); + set_value!(a, 1); // $ Alert[rust/unused-value] use_value!(b); match std::env::args().nth(1).unwrap().parse::() { @@ -513,13 +513,7 @@ fn macros2() { fn macros3() { let x; - println!( - "The value of x is {}", - ({ - x = 10; // $ MISSING: Alert[rust/unused-value] - 10 - }) - ); + println!("The value of x is {}", ({ x = 10; 10 })); // $ Alert[rust/unused-value] } macro_rules! let_in_macro {