From 56f53285305932b2fd98c4dbcac6438c9c10b7a9 Mon Sep 17 00:00:00 2001 From: Simon Friis Vindum Date: Thu, 8 Jan 2026 11:59:10 +0100 Subject: [PATCH] Rust: Use `getAssocItem` consistently in stdlib classes --- .../codeql/rust/frameworks/stdlib/Stdlib.qll | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/rust/ql/lib/codeql/rust/frameworks/stdlib/Stdlib.qll b/rust/ql/lib/codeql/rust/frameworks/stdlib/Stdlib.qll index ec0e38f57399..114c283bbdb1 100644 --- a/rust/ql/lib/codeql/rust/frameworks/stdlib/Stdlib.qll +++ b/rust/ql/lib/codeql/rust/frameworks/stdlib/Stdlib.qll @@ -1,5 +1,5 @@ /** - * Provides classes modeling security-relevant aspects of the standard libraries. + * Provides classes modeling relevant aspects of the standard libraries. */ private import rust @@ -140,10 +140,7 @@ class FutureTrait extends Trait { /** Gets the `Output` associated type. */ pragma[nomagic] - TypeAlias getOutputType() { - result = this.getAssocItemList().getAnAssocItem() and - result.getName().getText() = "Output" - } + TypeAlias getOutputType() { result = this.(TraitItemNode).getAssocItem("Output") } } /** @@ -160,10 +157,7 @@ class FnOnceTrait extends Trait { /** Gets the `Output` associated type. */ pragma[nomagic] - TypeAlias getOutputType() { - result = this.getAssocItemList().getAnAssocItem() and - result.getName().getText() = "Output" - } + TypeAlias getOutputType() { result = this.(TraitItemNode).getAssocItem("Output") } } /** @@ -177,10 +171,7 @@ class IteratorTrait extends Trait { /** Gets the `Item` associated type. */ pragma[nomagic] - TypeAlias getItemType() { - result = this.getAssocItemList().getAnAssocItem() and - result.getName().getText() = "Item" - } + TypeAlias getItemType() { result = this.(TraitItemNode).getAssocItem("Item") } } /** @@ -194,10 +185,7 @@ class IntoIteratorTrait extends Trait { /** Gets the `Item` associated type. */ pragma[nomagic] - TypeAlias getItemType() { - result = this.getAssocItemList().getAnAssocItem() and - result.getName().getText() = "Item" - } + TypeAlias getItemType() { result = this.(TraitItemNode).getAssocItem("Item") } } /** @@ -224,10 +212,7 @@ class DerefTrait extends Trait { /** Gets the `Target` associated type. */ pragma[nomagic] - TypeAlias getTargetType() { - result = this.getAssocItemList().getAnAssocItem() and - result.getName().getText() = "Target" - } + TypeAlias getTargetType() { result = this.(TraitItemNode).getAssocItem("Target") } } /** @@ -244,10 +229,7 @@ class IndexTrait extends Trait { /** Gets the `Output` associated type. */ pragma[nomagic] - TypeAlias getOutputType() { - result = this.getAssocItemList().getAnAssocItem() and - result.getName().getText() = "Output" - } + TypeAlias getOutputType() { result = this.(TraitItemNode).getAssocItem("Output") } } /**