Skip to content

Commit bf0dc3c

Browse files
committed
Rust: Use useUniversalConditions() { none() }
1 parent 46f5d89 commit bf0dc3c

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

rust/ql/lib/codeql/rust/internal/TypeInference.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3074,6 +3074,8 @@ private module AwaitSatisfiesConstraintInput implements SatisfiesConstraintInput
30743074
exists(term) and
30753075
constraint.(TraitType).getTrait() instanceof FutureTrait
30763076
}
3077+
3078+
predicate useUniversalConditions() { none() }
30773079
}
30783080

30793081
pragma[nomagic]
@@ -3249,6 +3251,8 @@ private module ForIterableSatisfiesConstraintInput implements
32493251
t instanceof IntoIteratorTrait
32503252
)
32513253
}
3254+
3255+
predicate useUniversalConditions() { none() }
32523256
}
32533257

32543258
pragma[nomagic]
@@ -3303,6 +3307,8 @@ private module InvokedClosureSatisfiesConstraintInput implements
33033307
exists(term) and
33043308
constraint.(TraitType).getTrait() instanceof FnOnceTrait
33053309
}
3310+
3311+
predicate useUniversalConditions() { none() }
33063312
}
33073313

33083314
/** Gets the type of `ce` when viewed as an implementation of `FnOnce`. */

rust/ql/test/library-tests/type-inference/type-inference.expected

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5399,7 +5399,6 @@ inferType
53995399
| main.rs:2612:40:2612:40 | 1 | | {EXTERNAL LOCATION} | i32 |
54005400
| main.rs:2612:43:2612:44 | { ... } | | {EXTERNAL LOCATION} | () |
54015401
| main.rs:2613:9:2613:41 | for ... in ... { ... } | | {EXTERNAL LOCATION} | () |
5402-
| main.rs:2613:13:2613:13 | i | | {EXTERNAL LOCATION} | Item |
54035402
| main.rs:2613:13:2613:13 | i | | {EXTERNAL LOCATION} | i32 |
54045403
| main.rs:2613:18:2613:26 | [...] | | {EXTERNAL LOCATION} | [;] |
54055404
| main.rs:2613:18:2613:26 | [...] | [T;...] | {EXTERNAL LOCATION} | i32 |
@@ -5573,7 +5572,6 @@ inferType
55735572
| main.rs:2652:26:2652:26 | c | | main.rs:2596:5:2596:24 | MyCallable |
55745573
| main.rs:2652:26:2652:33 | c.call() | | {EXTERNAL LOCATION} | i64 |
55755574
| main.rs:2657:9:2657:25 | for ... in ... { ... } | | {EXTERNAL LOCATION} | () |
5576-
| main.rs:2657:13:2657:13 | i | | {EXTERNAL LOCATION} | Item |
55775575
| main.rs:2657:13:2657:13 | i | | {EXTERNAL LOCATION} | i32 |
55785576
| main.rs:2657:18:2657:18 | 0 | | {EXTERNAL LOCATION} | i32 |
55795577
| main.rs:2657:18:2657:22 | 0..10 | | {EXTERNAL LOCATION} | Range |
@@ -5602,7 +5600,6 @@ inferType
56025600
| main.rs:2659:21:2659:25 | 0..10 | Idx | {EXTERNAL LOCATION} | i32 |
56035601
| main.rs:2659:24:2659:25 | 10 | | {EXTERNAL LOCATION} | i32 |
56045602
| main.rs:2660:9:2660:25 | for ... in ... { ... } | | {EXTERNAL LOCATION} | () |
5605-
| main.rs:2660:13:2660:13 | i | | {EXTERNAL LOCATION} | Item |
56065603
| main.rs:2660:13:2660:13 | i | | {EXTERNAL LOCATION} | i32 |
56075604
| main.rs:2660:18:2660:22 | range | | {EXTERNAL LOCATION} | Range |
56085605
| main.rs:2660:18:2660:22 | range | Idx | {EXTERNAL LOCATION} | i32 |
@@ -5626,7 +5623,6 @@ inferType
56265623
| main.rs:2666:20:2666:23 | 0u16 | | {EXTERNAL LOCATION} | u16 |
56275624
| main.rs:2667:18:2667:22 | 10u16 | | {EXTERNAL LOCATION} | u16 |
56285625
| main.rs:2669:9:2669:26 | for ... in ... { ... } | | {EXTERNAL LOCATION} | () |
5629-
| main.rs:2669:13:2669:13 | u | | {EXTERNAL LOCATION} | Item |
56305626
| main.rs:2669:13:2669:13 | u | | {EXTERNAL LOCATION} | u16 |
56315627
| main.rs:2669:18:2669:23 | range1 | | {EXTERNAL LOCATION} | Range |
56325628
| main.rs:2669:18:2669:23 | range1 | Idx | {EXTERNAL LOCATION} | u16 |
@@ -5795,7 +5791,6 @@ inferType
57955791
| main.rs:2701:33:2701:37 | "two" | | {EXTERNAL LOCATION} | & |
57965792
| main.rs:2701:33:2701:37 | "two" | &T | {EXTERNAL LOCATION} | str |
57975793
| main.rs:2702:9:2702:33 | for ... in ... { ... } | | {EXTERNAL LOCATION} | () |
5798-
| main.rs:2702:13:2702:15 | key | | {EXTERNAL LOCATION} | Item |
57995794
| main.rs:2702:13:2702:15 | key | | {EXTERNAL LOCATION} | & |
58005795
| main.rs:2702:13:2702:15 | key | &T | {EXTERNAL LOCATION} | i32 |
58015796
| main.rs:2702:20:2702:23 | map1 | | {EXTERNAL LOCATION} | HashMap |
@@ -5813,7 +5808,6 @@ inferType
58135808
| main.rs:2702:20:2702:30 | map1.keys() | V.T.&T | {EXTERNAL LOCATION} | str |
58145809
| main.rs:2702:32:2702:33 | { ... } | | {EXTERNAL LOCATION} | () |
58155810
| main.rs:2703:9:2703:37 | for ... in ... { ... } | | {EXTERNAL LOCATION} | () |
5816-
| main.rs:2703:13:2703:17 | value | | {EXTERNAL LOCATION} | Item |
58175811
| main.rs:2703:13:2703:17 | value | | {EXTERNAL LOCATION} | & |
58185812
| main.rs:2703:13:2703:17 | value | &T | {EXTERNAL LOCATION} | Box |
58195813
| main.rs:2703:13:2703:17 | value | &T.A | {EXTERNAL LOCATION} | Global |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
992992
TypeMention constraintMention
993993
) {
994994
exists(Type type | hasTypeConstraint(tt, type, constraint) |
995-
useUniversalConditions() and
995+
useUniversalConditions() and // todo: remove, and instead check constraints
996996
not exists(countConstraintImplementations(type, constraint)) and
997997
conditionSatisfiesConstraintTypeAt(abs, condition, constraintMention, _, _) and
998998
resolveTypeMentionRoot(condition) = abs.getATypeParameter() and

0 commit comments

Comments
 (0)