Rust: Reimplement type inference for impl Traits and await expressions

This commit is contained in:
Tom Hvitved
2025-06-02 12:58:51 +02:00
parent f2832712bc
commit c6efc05de1
9 changed files with 327 additions and 162 deletions

View File

@@ -220,6 +220,10 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
predicate isCons(TypeParameter tp, TypePath suffix) {
suffix = this.stripPrefix(TypePath::singleton(tp))
}
/** Gets the head of this path, if any. */
bindingset[this]
TypeParameter getHead() { result = this.getTypeParameter(0) }
}
/** Provides predicates for constructing `TypePath`s. */
@@ -1110,7 +1114,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
Declaration decl, DeclarationPosition dpos, Type base, TypePath path, TypeParameter tp
) {
tp = decl.getDeclaredType(dpos, path) and
path.isCons(base.getATypeParameter(), _)
base.getATypeParameter() = path.getHead()
}
/**