Skip to content

Commit 63a635c

Browse files
committed
Revert "Rust: Restrict the query to user code."
This reverts commit aed44ba.
1 parent aed44ba commit 63a635c

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @name Missing Elements
3-
* @description List all elements in the source code directory that weren't extracted due to unimplemented features or parse errors.
3+
* @description List all elements that weren't extracted due to unimplemented features or parse errors.
44
* @id rust/diagnostics/missing-elements
55
*/
66

@@ -16,6 +16,16 @@ Location getUnimplementedLocation(Unimplemented node) {
1616
result instanceof EmptyLocation
1717
}
1818

19+
/**
20+
* Gets `l.toString()`, but with any locations outside of the source location prefix cleaned up.
21+
*/
22+
bindingset[l]
23+
string cleanLocationString(Location l) {
24+
if exists(l.getFile().getRelativePath()) or l instanceof EmptyLocation
25+
then result = l.toString()
26+
else l.getFile().getParentContainer().getAbsolutePath() + result = l.toString() // remove the directory from the string
27+
}
28+
1929
/**
2030
* Gets a string along the lines of " (x2)", corresponding to the number `i`. For `i = 1`, the result is the empty string.
2131
*/
@@ -29,33 +39,23 @@ string multipleString(int i) {
2939
query predicate listUnimplemented(string location, string msg) {
3040
// something that is not extracted yet
3141
exists(int c |
32-
c =
33-
strictcount(Unimplemented n |
34-
exists(getUnimplementedLocation(n).getFile().getRelativePath()) and
35-
getUnimplementedLocation(n).toString() = location
36-
) and
42+
c = strictcount(Unimplemented n | cleanLocationString(getUnimplementedLocation(n)) = location) and
3743
msg = "Not yet implemented" + multipleString(c) + "."
3844
)
3945
}
4046

4147
query predicate listMissingExpr(string location, string msg) {
4248
// gaps in the AST due to parse errors
4349
exists(int c |
44-
c =
45-
strictcount(MissingExpr e |
46-
exists(e.getFile().getRelativePath()) and e.getLocation().toString() = location
47-
) and
50+
c = strictcount(MissingExpr e | cleanLocationString(e.getLocation()) = location) and
4851
msg = "Missing expression" + multipleString(c) + "."
4952
)
5053
}
5154

5255
query predicate listMissingPat(string location, string msg) {
5356
// gaps in the AST due to parse errors
5457
exists(int c |
55-
c =
56-
strictcount(MissingPat p |
57-
exists(p.getFile().getRelativePath()) and p.getLocation().toString() = location
58-
) and
58+
c = strictcount(MissingPat p | cleanLocationString(p.getLocation()) = location) and
5959
msg = "Missing pattern" + multipleString(c) + "."
6060
)
6161
}

rust/ql/test/query-tests/diagnostics/MissingElements.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
listUnimplemented
2+
| @0:0:0:0 | Not yet implemented (x20). |
23
| does_not_compile.rs@2:2:2:5 | Not yet implemented. |
34
| does_not_compile.rs@2:7:2:8 | Not yet implemented. |
45
| does_not_compile.rs@2:10:2:12 | Not yet implemented. |

0 commit comments

Comments
 (0)