Skip to content

Commit a2a28b0

Browse files
committed
Rust: Remove restriction that blanket(-like) impls must have a constraint
1 parent cc4926a commit a2a28b0

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

rust/ql/lib/codeql/rust/internal/typeinference/BlanketImplementation.qll

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ predicate isBlanketLike(ImplItemNode i, TypePath blanketSelfPath, TypeParam blan
4949
complexSelfRoot(root, tp) and
5050
tm.resolveType() = root and
5151
tm.resolveTypeAt(blanketSelfPath) = TTypeParamTypeParameter(blanketTypeParam) and
52-
blanketSelfPath = TypePath::singleton(tp) and
53-
hasFirstNonTrivialTraitBound(blanketTypeParam, _)
52+
blanketSelfPath = TypePath::singleton(tp)
5453
)
5554
}
5655

@@ -126,7 +125,7 @@ module SatisfiesBlanketConstraint<
126125

127126
/**
128127
* Holds if the argument type `at` satisfies the first non-trivial blanket
129-
* constraint of `impl`.
128+
* constraint of `impl`, or if there are no non-trivial constraints of `impl`.
130129
*/
131130
pragma[nomagic]
132131
predicate satisfiesBlanketConstraint(ArgumentType at, ImplItemNode impl) {
@@ -135,6 +134,11 @@ module SatisfiesBlanketConstraint<
135134
SatisfiesBlanketConstraintInput::relevantConstraint(ato, impl, traitBound) and
136135
SatisfiesBlanketConstraint::satisfiesConstraintType(ato, TTrait(traitBound), _, _)
137136
)
137+
or
138+
exists(TypeParam blanketTypeParam |
139+
hasBlanketCandidate(at, impl, _, blanketTypeParam) and
140+
not hasFirstNonTrivialTraitBound(blanketTypeParam, _)
141+
)
138142
}
139143

140144
/**

0 commit comments

Comments
 (0)