Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions rust/ql/lib/codeql/rust/frameworks/stdlib/Stdlib.qll
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,19 @@ class IndexTrait extends Trait {
}
}

/**
* The [`IndexMut` trait][1].
*
* [1]: https://doc.rust-lang.org/std/ops/trait.IndexMut.html
*/
class IndexMutTrait extends Trait {
pragma[nomagic]
IndexMutTrait() { this.getCanonicalPath() = "core::ops::index::IndexMut" }

/** Gets the `index_mut` function. */
Function getIndexMutFunction() { result = this.(TraitItemNode).getAssocItem("index_mut") }
}

/**
* The [`Box` struct][1].
*
Expand Down
4 changes: 2 additions & 2 deletions rust/ql/lib/codeql/rust/internal/TypeInference.qll
Original file line number Diff line number Diff line change
Expand Up @@ -1786,8 +1786,8 @@ private module MethodResolution {

override Trait getTrait() {
if this.isInMutableContext()
then result.getCanonicalPath() = "core::ops::index::IndexMut"
else result.getCanonicalPath() = "core::ops::index::Index"
then result instanceof IndexMutTrait
else result instanceof IndexTrait
}
}

Expand Down