Skip to content

Commit 4df7945

Browse files
committed
Rust: Suppress type inference inconsistency that can be explained by path resolution
1 parent de8e535 commit 4df7945

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,13 @@ module Consistency {
226226

227227
predicate nonUniqueCertainType(AstNode n, TypePath path, Type t) {
228228
strictcount(CertainTypeInference::inferCertainType(n, path)) > 1 and
229-
t = CertainTypeInference::inferCertainType(n, path)
229+
t = CertainTypeInference::inferCertainType(n, path) and
230+
// Suppress the inconsistency if `n` is a self parameter and path resolution
231+
// provides multiple targets for the self path of the impl block.
232+
not exists(ImplItemNode impl |
233+
n = impl.getAnAssocItem().(Function).getParamList().getSelfParam() and
234+
count(impl.resolveSelfTy()) > 1
235+
)
230236
}
231237
}
232238

@@ -2467,8 +2473,9 @@ private module Debug {
24672473
private Locatable getRelevantLocatable() {
24682474
exists(string filepath, int startline, int startcolumn, int endline, int endcolumn |
24692475
result.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) and
2470-
filepath.matches("%/sqlx.rs") and
2471-
startline = [56 .. 60]
2476+
// filepath.matches("%/sort_compare.rs") // and
2477+
filepath.matches("%/main.rs") // and
2478+
// startline = [56 .. 60]
24722479
)
24732480
}
24742481

0 commit comments

Comments
 (0)