Skip to content

Commit b27ae98

Browse files
committed
Rust: normalize paths in the rustup folder
1 parent 662e963 commit b27ae98

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Diff for: rust/ql/test/library-tests/path-resolution/path-resolution.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ resolvePath
319319
| my.rs:18:9:18:11 | my4 | my.rs:14:1:16:1 | mod my4 |
320320
| my.rs:18:9:18:16 | ...::my5 | my.rs:15:5:15:16 | mod my5 |
321321
| my.rs:18:9:18:19 | ...::f | my/my4/my5/mod.rs:1:1:3:1 | fn f |
322-
| my.rs:22:5:22:9 | std | file:///Users/arthur/.rustup/toolchains/1.85-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/lib.rs:0:0:0:0 | Crate(std@0.0.0) |
322+
| my.rs:22:5:22:9 | std | file:///RUSTUP_HOME/toolchain/lib/rustlib/src/rust/library/std/src/lib.rs:0:0:0:0 | Crate(std@0.0.0) |
323323
| my.rs:22:5:22:17 | ...::result | file://:0:0:0:0 | mod result |
324324
| my.rs:22:5:25:1 | ...::Result::<...> | file://:0:0:0:0 | enum Result |
325325
| my.rs:23:5:23:5 | T | my.rs:21:5:21:5 | T |

Diff for: rust/ql/test/library-tests/path-resolution/path-resolution.ql

+12-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ import TestUtils
55

66
query predicate mod(Module m) { toBeTested(m) }
77

8-
query predicate resolvePath(Path p, ItemNode i) {
8+
class ItemNodeLoc extends Locatable instanceof ItemNode {
9+
predicate hasLocationInfo(
10+
string filepath, int startline, int startcolumn, int endline, int endcolumn
11+
) {
12+
exists(string file |
13+
super.getLocation().hasLocationInfo(file, startline, startcolumn, endline, endcolumn) and
14+
filepath = file.regexpReplaceAll("^/.*/.rustup/toolchains/[^/]+/", "/RUSTUP_HOME/toolchain/")
15+
)
16+
}
17+
}
18+
19+
query predicate resolvePath(Path p, ItemNodeLoc i) {
920
toBeTested(p) and not p.isInMacroExpansion() and i = resolvePath(p)
1021
}

0 commit comments

Comments
 (0)