Skip to content

Commit 983257d

Browse files
committed
WIP
1 parent 7bbf269 commit 983257d

File tree

3 files changed

+88
-394
lines changed

3 files changed

+88
-394
lines changed

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,14 @@ private module BlanketImplementation {
17651765
t =
17661766
rank[1](Trait trait, int i |
17671767
trait = getBlanketImplementationTypeParam(impl).resolveBound(i) and
1768-
not trait.getName().getText() = ["Sized", "Fn", "FnOnce", "FnMut"]
1768+
// Exclude traits that are "trivial" in the sense that they are known to
1769+
// not narrow things down very much.
1770+
not trait.getName().getText() =
1771+
[
1772+
"Sized", "Clone", "Fn", "FnOnce", "FnMut",
1773+
// The auto traits
1774+
"Send", "Sync", "Unpin", "UnwindSafe", "RefUnwindSafe"
1775+
]
17691776
|
17701777
trait order by i
17711778
)
@@ -1793,12 +1800,18 @@ private module BlanketImplementation {
17931800
Impl impl, Trait trait, string name, int arity, Function f
17941801
) {
17951802
isCanonicalBlanketImplementation(impl) and
1796-
f = impl.(ImplItemNode).getASuccessor(name) and
17971803
blanketImplementationTraitBound(impl, trait) and
17981804
f.getParamList().hasSelfParam() and
17991805
arity = f.getParamList().getNumberOfParams() and
18001806
// Make this stronger and document
1801-
not trait.(TraitItemNode).getASuccessor(name) = f
1807+
(
1808+
f = impl.(ImplItemNode).getAssocItem(name)
1809+
or
1810+
f = impl.(ImplItemNode).resolveTraitTy().getAssocItem(name) and
1811+
not f = impl.(ImplItemNode).getAssocItem(name)
1812+
) and
1813+
not getBlanketImplementationTypeParam(impl).resolveABound().(TraitItemNode).getASuccessor(name) =
1814+
f
18021815
}
18031816

18041817
predicate methodCallMatchesBlanketImpl(MethodCall mc, Type t, Impl impl, Trait trait, Function f) {
@@ -1821,13 +1834,6 @@ private module BlanketImplementation {
18211834
predicate useUniversalConditions() { none() }
18221835
}
18231836

1824-
predicate debugSatisfiesConstraintType(MethodCall mc, Trait trait, TypePath path, Type ty) {
1825-
SatisfiesConstraint<MethodCall, SatisfiesConstraintInput>::satisfiesConstraintType(mc,
1826-
TTrait(trait), path, ty) and
1827-
// 521 results
1828-
trait.getName().getText() = "TryFuture"
1829-
}
1830-
18311837
predicate getBlanketImpl(MethodCall mc, Type t, Impl impl, Trait trait, Function f) {
18321838
SatisfiesConstraint<MethodCall, SatisfiesConstraintInput>::satisfiesConstraintType(mc,
18331839
TTrait(trait), _, _) and

0 commit comments

Comments
 (0)