mirror of
https://github.com/github/codeql.git
synced 2026-02-11 20:51:06 +01:00
Merge pull request #21205 from paldepind/shared/ti-boound-tm
Rust: Change `getATypeParameterConstraint` to not require a `TypeMention`
This commit is contained in:
@@ -141,17 +141,17 @@ private module Input2 implements InputSig2 {
|
||||
|
||||
TypeMention getABaseTypeMention(Type t) { none() }
|
||||
|
||||
TypeMention getATypeParameterConstraint(TypeParameter tp) {
|
||||
result = tp.(TypeParamTypeParameter).getTypeParam().getATypeBound().getTypeRepr()
|
||||
or
|
||||
result = tp.(SelfTypeParameter).getTrait()
|
||||
or
|
||||
result =
|
||||
tp.(ImplTraitTypeTypeParameter)
|
||||
.getImplTraitTypeRepr()
|
||||
.getTypeBoundList()
|
||||
.getABound()
|
||||
.getTypeRepr()
|
||||
Type getATypeParameterConstraint(TypeParameter tp, TypePath path) {
|
||||
exists(TypeMention tm | result = tm.resolveTypeAt(path) |
|
||||
tm = tp.(TypeParamTypeParameter).getTypeParam().getATypeBound().getTypeRepr() or
|
||||
tm = tp.(SelfTypeParameter).getTrait() or
|
||||
tm =
|
||||
tp.(ImplTraitTypeTypeParameter)
|
||||
.getImplTraitTypeRepr()
|
||||
.getTypeBoundList()
|
||||
.getABound()
|
||||
.getTypeRepr()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -343,7 +343,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
|
||||
* ```
|
||||
* the type parameter `T` has the constraint `IComparable<T>`.
|
||||
*/
|
||||
TypeMention getATypeParameterConstraint(TypeParameter tp);
|
||||
Type getATypeParameterConstraint(TypeParameter tp, TypePath path);
|
||||
|
||||
/**
|
||||
* Holds if
|
||||
@@ -1451,13 +1451,10 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
|
||||
accessDeclarationPositionMatch(apos, dpos) and
|
||||
constrainedTp = target.getTypeParameter(_) and
|
||||
tp = target.getTypeParameter(_) and
|
||||
tp = getATypeParameterConstraint(constrainedTp, pathToTp) and
|
||||
constrainedTp != tp and
|
||||
constrainedTp = target.getDeclaredType(dpos, pathToConstrained) and
|
||||
exists(TypeMention tm |
|
||||
tm = getATypeParameterConstraint(constrainedTp) and
|
||||
tm.resolveTypeAt(pathToTp) = tp and
|
||||
constraint = resolveTypeMentionRoot(tm)
|
||||
)
|
||||
constraint = getATypeParameterConstraint(constrainedTp, TypePath::nil())
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user