Skip to content

Commit bc83106

Browse files
committed
Rust: Repair rust/diagnostics/unextracted-elements.
1 parent 8f1c1a8 commit bc83106

File tree

2 files changed

+7
-60
lines changed

2 files changed

+7
-60
lines changed

rust/ql/src/queries/diagnostics/UnextractedElements.ql

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,8 @@
77
import rust
88

99
/**
10-
* Gets a location for an `Unimplemented` node.
11-
*/
12-
Location getUnimplementedLocation(Unimplemented node) {
13-
result = node.(Locatable).getLocation()
14-
or
15-
not node instanceof Locatable and
16-
result instanceof EmptyLocation
17-
}
18-
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-
29-
/**
30-
* Gets a string along the lines of " (x2)", corresponding to the number `i`. For `i = 1`, the result is the empty string.
10+
* Gets a string along the lines of " (x2)", corresponding to the number `i`.
11+
* For `i = 1`, the result is the empty string.
3112
*/
3213
bindingset[i]
3314
string multipleString(int i) {
@@ -36,26 +17,8 @@ string multipleString(int i) {
3617
i > 1 and result = " (x" + i.toString() + ")"
3718
}
3819

39-
query predicate listUnimplemented(string location, string msg) {
40-
// something that is not extracted yet
41-
exists(int c |
42-
c = strictcount(Unimplemented n | cleanLocationString(getUnimplementedLocation(n)) = location) and
43-
msg = "Not yet implemented" + multipleString(c) + "."
44-
)
45-
}
46-
47-
query predicate listMissingExpr(string location, string msg) {
48-
// gaps in the AST due to parse errors
49-
exists(int c |
50-
c = strictcount(MissingExpr e | cleanLocationString(e.getLocation()) = location) and
51-
msg = "Missing expression" + multipleString(c) + "."
52-
)
53-
}
54-
55-
query predicate listMissingPat(string location, string msg) {
56-
// gaps in the AST due to parse errors
57-
exists(int c |
58-
c = strictcount(MissingPat p | cleanLocationString(p.getLocation()) = location) and
59-
msg = "Missing pattern" + multipleString(c) + "."
60-
)
61-
}
20+
from string name, int c
21+
where c = strictcount(Unextracted e | e.toString() = name)
22+
// we don't have locations, so just list the number of each type of
23+
// `Unextracted` element.
24+
select name + multipleString(c)
Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +0,0 @@
1-
listUnimplemented
2-
| @0:0:0:0 | Not yet implemented (x14). |
3-
| does_not_compile.rs@2:2:2:5 | Not yet implemented. |
4-
| does_not_compile.rs@2:7:2:8 | Not yet implemented. |
5-
| does_not_compile.rs@2:10:2:12 | Not yet implemented. |
6-
| does_not_compile.rs@2:14:2:20 | Not yet implemented. |
7-
| does_not_compile.rs@2:22:2:25 | Not yet implemented. |
8-
| does_not_compile.rs@2:27:2:30 | Not yet implemented. |
9-
| main.rs@16:5:16:22 | Not yet implemented. |
10-
| main.rs@17:5:17:21 | Not yet implemented. |
11-
| my_struct.rs@2:1:13:1 | Not yet implemented. |
12-
| my_struct.rs@24:9:27:9 | Not yet implemented. |
13-
| my_struct.rs@25:19:25:30 | Not yet implemented. |
14-
| my_struct.rs@29:5:29:5 | Not yet implemented. |
15-
listMissingExpr
16-
listMissingPat

0 commit comments

Comments
 (0)