diff --git a/rust/ql/src/queries/diagnostics/UnextractedElements.ql b/rust/ql/src/queries/diagnostics/UnextractedElements.ql index ae368aac677f..dccf7d2ab09f 100644 --- a/rust/ql/src/queries/diagnostics/UnextractedElements.ql +++ b/rust/ql/src/queries/diagnostics/UnextractedElements.ql @@ -7,27 +7,8 @@ import rust /** - * Gets a location for an `Unimplemented` node. - */ -Location getUnimplementedLocation(Unimplemented node) { - result = node.(Locatable).getLocation() - or - not node instanceof Locatable and - result instanceof EmptyLocation -} - -/** - * Gets `l.toString()`, but with any locations outside of the source location prefix cleaned up. - */ -bindingset[l] -string cleanLocationString(Location l) { - if exists(l.getFile().getRelativePath()) or l instanceof EmptyLocation - then result = l.toString() - else l.getFile().getParentContainer().getAbsolutePath() + result = l.toString() // remove the directory from the string -} - -/** - * Gets a string along the lines of " (x2)", corresponding to the number `i`. For `i = 1`, the result is the empty string. + * Gets a string along the lines of " (x2)", corresponding to the number `i`. + * For `i = 1`, the result is the empty string. */ bindingset[i] string multipleString(int i) { @@ -36,26 +17,8 @@ string multipleString(int i) { i > 1 and result = " (x" + i.toString() + ")" } -query predicate listUnimplemented(string location, string msg) { - // something that is not extracted yet - exists(int c | - c = strictcount(Unimplemented n | cleanLocationString(getUnimplementedLocation(n)) = location) and - msg = "Not yet implemented" + multipleString(c) + "." - ) -} - -query predicate listMissingExpr(string location, string msg) { - // gaps in the AST due to parse errors - exists(int c | - c = strictcount(MissingExpr e | cleanLocationString(e.getLocation()) = location) and - msg = "Missing expression" + multipleString(c) + "." - ) -} - -query predicate listMissingPat(string location, string msg) { - // gaps in the AST due to parse errors - exists(int c | - c = strictcount(MissingPat p | cleanLocationString(p.getLocation()) = location) and - msg = "Missing pattern" + multipleString(c) + "." - ) -} +from string name, int c +where c = strictcount(Unextracted e | e.toString() = name) +// we don't have locations, so just list the number of each type of +// `Unextracted` element. +select name + multipleString(c) diff --git a/rust/ql/test/query-tests/diagnostics/UnextractedElements.expected b/rust/ql/test/query-tests/diagnostics/UnextractedElements.expected index 5ed70660c2b4..e69de29bb2d1 100644 --- a/rust/ql/test/query-tests/diagnostics/UnextractedElements.expected +++ b/rust/ql/test/query-tests/diagnostics/UnextractedElements.expected @@ -1,16 +0,0 @@ -listUnimplemented -| @0:0:0:0 | Not yet implemented (x14). | -| does_not_compile.rs@2:2:2:5 | Not yet implemented. | -| does_not_compile.rs@2:7:2:8 | Not yet implemented. | -| does_not_compile.rs@2:10:2:12 | Not yet implemented. | -| does_not_compile.rs@2:14:2:20 | Not yet implemented. | -| does_not_compile.rs@2:22:2:25 | Not yet implemented. | -| does_not_compile.rs@2:27:2:30 | Not yet implemented. | -| main.rs@16:5:16:22 | Not yet implemented. | -| main.rs@17:5:17:21 | Not yet implemented. | -| my_struct.rs@2:1:13:1 | Not yet implemented. | -| my_struct.rs@24:9:27:9 | Not yet implemented. | -| my_struct.rs@25:19:25:30 | Not yet implemented. | -| my_struct.rs@29:5:29:5 | Not yet implemented. | -listMissingExpr -listMissingPat