Skip to content

Commit 47e375f

Browse files
authored
Merge pull request #21057 from hvitved/rust/fix-bad-join
Rust: Fix bad join
2 parents adfaefd + 5c604fc commit 47e375f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,19 @@ class IndexTrait extends Trait {
250250
}
251251
}
252252

253+
/**
254+
* The [`IndexMut` trait][1].
255+
*
256+
* [1]: https://doc.rust-lang.org/std/ops/trait.IndexMut.html
257+
*/
258+
class IndexMutTrait extends Trait {
259+
pragma[nomagic]
260+
IndexMutTrait() { this.getCanonicalPath() = "core::ops::index::IndexMut" }
261+
262+
/** Gets the `index_mut` function. */
263+
Function getIndexMutFunction() { result = this.(TraitItemNode).getAssocItem("index_mut") }
264+
}
265+
253266
/**
254267
* The [`Box` struct][1].
255268
*

rust/ql/lib/codeql/rust/internal/TypeInference.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,8 +1839,8 @@ private module MethodResolution {
18391839

18401840
override Trait getTrait() {
18411841
if this.isInMutableContext()
1842-
then result.getCanonicalPath() = "core::ops::index::IndexMut"
1843-
else result.getCanonicalPath() = "core::ops::index::Index"
1842+
then result instanceof IndexMutTrait
1843+
else result instanceof IndexTrait
18441844
}
18451845
}
18461846

0 commit comments

Comments
 (0)