Skip to content

Commit e610465

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

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
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 the type
231+
// mention for the self type has multiple types for a path.
232+
not exists(ImplItemNode impl, TypePath path0 |
233+
n = impl.getAnAssocItem().(Function).getParamList().getSelfParam() and
234+
strictcount(impl.(Impl).getSelfTy().(TypeMention).resolveTypeAt(path0)) > 1
235+
)
230236
}
231237
}
232238

0 commit comments

Comments
 (0)