Skip to content

Commit 19ac581

Browse files
committed
dbg2
1 parent 3a959e0 commit 19ac581

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -826,8 +826,9 @@ private Type inferCallExprBaseType(AstNode n, TypePath path) {
826826
TypePath path0
827827
|
828828
n = a.getNodeAt(apos) and
829-
result = CallExprBaseMatching::inferAccessType(a, apos, path0)
829+
result = CallExprBaseMatching::inferAccessType(a, apos, path0) //and
830830
|
831+
// not apos.getArgumentPosition().isSelf()
831832
if
832833
apos.isBorrowed(true)
833834
or
@@ -1608,8 +1609,10 @@ private module Debug {
16081609
private Locatable getRelevantLocatable() {
16091610
exists(string filepath, int startline, int startcolumn, int endline, int endcolumn |
16101611
result.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) and
1611-
filepath.matches("%/sqlx.rs") and
1612-
startline = [56 .. 60]
1612+
filepath.matches("%/src/solve/inspect/build.rs") and
1613+
startline = [107, 117, 103]
1614+
// filepath.matches("%/main.rs") and
1615+
// startline = 2218
16131616
)
16141617
}
16151618

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,32 @@ abstract class TypeMention extends AstNode {
1313
/** Gets the type that this node resolves to, if any. */
1414
abstract Type resolveType();
1515

16-
/** Gets the sub mention at `path`. */
17-
pragma[nomagic]
18-
private TypeMention getMentionAt(TypePath path) {
16+
// /** Gets the sub mention at `path`. */
17+
// pragma[nomagic]
18+
// private TypeMention getMentionAt(TypePath path) {
19+
// path.isEmpty() and
20+
// result = this
21+
// or
22+
// exists(int i, TypeParameter tp, TypeMention arg, TypePath suffix |
23+
// arg = this.getTypeArgument(pragma[only_bind_into](i)) and
24+
// result = arg.getMentionAt(suffix) and
25+
// path = TypePath::cons(tp, suffix) and
26+
// tp = this.resolveType().getTypeParameter(pragma[only_bind_into](i))
27+
// )
28+
// }
29+
/** Gets the type that the sub mention at `path` resolves to, if any. */
30+
Type resolveTypeAt(TypePath path) {
1931
path.isEmpty() and
20-
result = this
32+
result = this.resolveType()
2133
or
2234
exists(int i, TypeParameter tp, TypeMention arg, TypePath suffix |
2335
arg = this.getTypeArgument(pragma[only_bind_into](i)) and
24-
result = arg.getMentionAt(suffix) and
36+
result = arg.resolveTypeAt(suffix) and
2537
path = TypePath::cons(tp, suffix) and
2638
tp = this.resolveType().getTypeParameter(pragma[only_bind_into](i))
2739
)
2840
}
29-
30-
/** Gets the type that the sub mention at `path` resolves to, if any. */
31-
Type resolveTypeAt(TypePath path) { result = this.getMentionAt(path).resolveType() }
41+
// result = this.getMentionAt(path).resolveType() }
3242
}
3343

3444
class ArrayTypeReprMention extends TypeMention instanceof ArrayTypeRepr {

rust/ql/test/library-tests/type-inference/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ mod type_aliases {
10571057

10581058
g(PairOption::PairSnd(PairOption::PairSnd(S3)));
10591059

1060-
let x: S7<S2>; // $ type=x:Result $ type=x:E.S1 $ type=x:T.S4 $ type=x:T.T41.S2 $ MISSING: type=x:T.T42.S5 $ MISSING: type=x:T.T42.T5.S2
1060+
let x: S7<S2>; // $ type=x:Result $ type=x:E.S1 $ type=x:T.S4 $ type=x:T.T41.S2 $ type=x:T.T42.S5 $ type=x:T.T42.T5.S2
10611061
}
10621062
}
10631063

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,8 @@ inferType
13751375
| main.rs:1060:13:1060:13 | x | E | main.rs:1007:5:1008:14 | S1 |
13761376
| main.rs:1060:13:1060:13 | x | T | main.rs:1033:5:1033:34 | S4 |
13771377
| main.rs:1060:13:1060:13 | x | T.T41 | main.rs:1010:5:1011:14 | S2 |
1378+
| main.rs:1060:13:1060:13 | x | T.T42 | main.rs:1035:5:1035:22 | S5 |
1379+
| main.rs:1060:13:1060:13 | x | T.T42.T5 | main.rs:1010:5:1011:14 | S2 |
13781380
| main.rs:1073:16:1073:24 | SelfParam | | file://:0:0:0:0 | & |
13791381
| main.rs:1073:16:1073:24 | SelfParam | &T | main.rs:1071:5:1078:5 | Self [trait MyTrait] |
13801382
| main.rs:1073:27:1073:31 | value | | main.rs:1071:19:1071:19 | S |

0 commit comments

Comments
 (0)