Skip to content

Commit ac644b2

Browse files
authored
Merge pull request #20848 from hvitved/rust/ranked-forex-rename
Rust: Use `ToIndex` instead of `FromIndex` in ranked `forex` predicates
2 parents c7a0411 + 3419c00 commit ac644b2

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ module ArgsAreInstantiationsOf<ArgsAreInstantiationsOfInputSig Input> {
352352
|
353353
rnk = 0
354354
or
355-
argsAreInstantiationsOfFromIndex(call, abs, f, rnk - 1)
355+
argsAreInstantiationsOfToIndex(call, abs, f, rnk - 1)
356356
)
357357
}
358358

@@ -361,15 +361,15 @@ module ArgsAreInstantiationsOf<ArgsAreInstantiationsOfInputSig Input> {
361361
}
362362
}
363363

364-
private module ArgIsInstantiationOfFromIndex =
364+
private module ArgIsInstantiationOfToIndex =
365365
ArgIsInstantiationOf<CallAndPos, ArgIsInstantiationOfInput>;
366366

367367
pragma[nomagic]
368-
private predicate argsAreInstantiationsOfFromIndex(
368+
private predicate argsAreInstantiationsOfToIndex(
369369
Input::Call call, ImplOrTraitItemNode i, Function f, int rnk
370370
) {
371371
exists(FunctionPosition pos |
372-
ArgIsInstantiationOfFromIndex::argIsInstantiationOf(MkCallAndPos(call, pos), i, _) and
372+
ArgIsInstantiationOfToIndex::argIsInstantiationOf(MkCallAndPos(call, pos), i, _) and
373373
call.hasTargetCand(i, f) and
374374
toCheckRanked(i, f, pos, rnk)
375375
)
@@ -382,7 +382,7 @@ module ArgsAreInstantiationsOf<ArgsAreInstantiationsOfInputSig Input> {
382382
pragma[nomagic]
383383
predicate argsAreInstantiationsOf(Input::Call call, ImplOrTraitItemNode i, Function f) {
384384
exists(int rnk |
385-
argsAreInstantiationsOfFromIndex(call, i, f, rnk) and
385+
argsAreInstantiationsOfToIndex(call, i, f, rnk) and
386386
rnk = max(int r | toCheckRanked(i, f, _, r))
387387
)
388388
}

shared/typeinference/codeql/typeinference/internal/TypeInference.qll

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -580,21 +580,21 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
580580
}
581581

582582
pragma[nomagic]
583-
private predicate satisfiesConcreteTypesFromIndex(
583+
private predicate satisfiesConcreteTypesToIndex(
584584
App app, TypeAbstraction abs, Constraint constraint, int i
585585
) {
586586
exists(Type t, TypePath path |
587587
t = resolveNthTypeAt(app, abs, constraint, i, path) and
588588
if t = abs.getATypeParameter() then any() else app.getTypeAt(path) = t
589589
) and
590590
// Recurse unless we are at the first path
591-
if i = 0 then any() else satisfiesConcreteTypesFromIndex(app, abs, constraint, i - 1)
591+
if i = 0 then any() else satisfiesConcreteTypesToIndex(app, abs, constraint, i - 1)
592592
}
593593

594594
/** Holds if all the concrete types in `constraint` also occur in `app`. */
595595
pragma[nomagic]
596596
private predicate satisfiesConcreteTypes(App app, TypeAbstraction abs, Constraint constraint) {
597-
satisfiesConcreteTypesFromIndex(app, abs, constraint,
597+
satisfiesConcreteTypesToIndex(app, abs, constraint,
598598
max(int i | exists(getNthPath(constraint, i))))
599599
}
600600

@@ -622,7 +622,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
622622
}
623623

624624
pragma[nomagic]
625-
private predicate typeParametersEqualFromIndexBase(
625+
private predicate typeParametersEqualToIndexBase(
626626
App app, TypeAbstraction abs, Constraint constraint, TypeParameter tp, TypePath path
627627
) {
628628
path = getNthTypeParameterPath(constraint, tp, 0) and
@@ -632,15 +632,15 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
632632
}
633633

634634
pragma[nomagic]
635-
private predicate typeParametersEqualFromIndex(
635+
private predicate typeParametersEqualToIndex(
636636
App app, TypeAbstraction abs, Constraint constraint, TypeParameter tp, Type t, int i
637637
) {
638638
exists(TypePath path |
639639
t = app.getTypeAt(path) and
640640
if i = 0
641-
then typeParametersEqualFromIndexBase(app, abs, constraint, tp, path)
641+
then typeParametersEqualToIndexBase(app, abs, constraint, tp, path)
642642
else (
643-
typeParametersEqualFromIndex(app, abs, constraint, tp, t, i - 1) and
643+
typeParametersEqualToIndex(app, abs, constraint, tp, t, i - 1) and
644644
path = getNthTypeParameterPath(constraint, tp, i)
645645
)
646646
)
@@ -657,19 +657,19 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
657657
exists(int n | n = max(int i | exists(getNthTypeParameterPath(constraint, tp, i))) |
658658
// If the largest index is 0, then there are no equalities to check as
659659
// the type parameter only occurs once.
660-
if n = 0 then any() else typeParametersEqualFromIndex(app, abs, constraint, tp, _, n)
660+
if n = 0 then any() else typeParametersEqualToIndex(app, abs, constraint, tp, _, n)
661661
)
662662
)
663663
}
664664

665-
private predicate typeParametersHaveEqualInstantiationFromIndex(
665+
private predicate typeParametersHaveEqualInstantiationToIndex(
666666
App app, TypeAbstraction abs, Constraint constraint, int i
667667
) {
668668
exists(TypeParameter tp | tp = getNthTypeParameter(abs, i) |
669669
typeParametersEqual(app, abs, constraint, tp) and
670670
if i = 0
671671
then any()
672-
else typeParametersHaveEqualInstantiationFromIndex(app, abs, constraint, i - 1)
672+
else typeParametersHaveEqualInstantiationToIndex(app, abs, constraint, i - 1)
673673
)
674674
}
675675

@@ -699,7 +699,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
699699
not exists(getNthTypeParameter(abs, _))
700700
or
701701
exists(int n | n = max(int i | exists(getNthTypeParameter(abs, i))) |
702-
typeParametersHaveEqualInstantiationFromIndex(app, abs, constraint, n)
702+
typeParametersHaveEqualInstantiationToIndex(app, abs, constraint, n)
703703
)
704704
)
705705
}

0 commit comments

Comments
 (0)