Rust: Change getATypeParameterConstraint to not require a TypeMention

This commit is contained in:
Simon Friis Vindum
2026-01-22 13:02:06 +01:00
parent 201512525b
commit ffaf1c0a24
2 changed files with 14 additions and 17 deletions

View File

@@ -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()
)
}
/**

View File

@@ -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())
)
}