Skip to content

Commit c8728c2

Browse files
authored
Merge pull request #21125 from paldepind/rust/builtin-refactor
Rust: Use `getAssocItem` consistently in stdlib classes
2 parents 608fa1a + 56f5328 commit c8728c2

File tree

1 file changed

+7
-25
lines changed
  • rust/ql/lib/codeql/rust/frameworks/stdlib

1 file changed

+7
-25
lines changed

rust/ql/lib/codeql/rust/frameworks/stdlib/Stdlib.qll

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Provides classes modeling security-relevant aspects of the standard libraries.
2+
* Provides classes modeling relevant aspects of the standard libraries.
33
*/
44

55
private import rust
@@ -140,10 +140,7 @@ class FutureTrait extends Trait {
140140

141141
/** Gets the `Output` associated type. */
142142
pragma[nomagic]
143-
TypeAlias getOutputType() {
144-
result = this.getAssocItemList().getAnAssocItem() and
145-
result.getName().getText() = "Output"
146-
}
143+
TypeAlias getOutputType() { result = this.(TraitItemNode).getAssocItem("Output") }
147144
}
148145

149146
/**
@@ -160,10 +157,7 @@ class FnOnceTrait extends Trait {
160157

161158
/** Gets the `Output` associated type. */
162159
pragma[nomagic]
163-
TypeAlias getOutputType() {
164-
result = this.getAssocItemList().getAnAssocItem() and
165-
result.getName().getText() = "Output"
166-
}
160+
TypeAlias getOutputType() { result = this.(TraitItemNode).getAssocItem("Output") }
167161
}
168162

169163
/**
@@ -177,10 +171,7 @@ class IteratorTrait extends Trait {
177171

178172
/** Gets the `Item` associated type. */
179173
pragma[nomagic]
180-
TypeAlias getItemType() {
181-
result = this.getAssocItemList().getAnAssocItem() and
182-
result.getName().getText() = "Item"
183-
}
174+
TypeAlias getItemType() { result = this.(TraitItemNode).getAssocItem("Item") }
184175
}
185176

186177
/**
@@ -194,10 +185,7 @@ class IntoIteratorTrait extends Trait {
194185

195186
/** Gets the `Item` associated type. */
196187
pragma[nomagic]
197-
TypeAlias getItemType() {
198-
result = this.getAssocItemList().getAnAssocItem() and
199-
result.getName().getText() = "Item"
200-
}
188+
TypeAlias getItemType() { result = this.(TraitItemNode).getAssocItem("Item") }
201189
}
202190

203191
/**
@@ -224,10 +212,7 @@ class DerefTrait extends Trait {
224212

225213
/** Gets the `Target` associated type. */
226214
pragma[nomagic]
227-
TypeAlias getTargetType() {
228-
result = this.getAssocItemList().getAnAssocItem() and
229-
result.getName().getText() = "Target"
230-
}
215+
TypeAlias getTargetType() { result = this.(TraitItemNode).getAssocItem("Target") }
231216
}
232217

233218
/**
@@ -244,10 +229,7 @@ class IndexTrait extends Trait {
244229

245230
/** Gets the `Output` associated type. */
246231
pragma[nomagic]
247-
TypeAlias getOutputType() {
248-
result = this.getAssocItemList().getAnAssocItem() and
249-
result.getName().getText() = "Output"
250-
}
232+
TypeAlias getOutputType() { result = this.(TraitItemNode).getAssocItem("Output") }
251233
}
252234

253235
/**

0 commit comments

Comments
 (0)