Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 93d20d1

Browse filesBrowse files
committed
Rust: Also take the std prelude into account when resolving paths
1 parent 6f71e3b commit 93d20d1
Copy full SHA for 93d20d1

File tree

1 file changed

+7
-5
lines changed
Filter options

1 file changed

+7
-5
lines changed

‎rust/ql/lib/codeql/rust/internal/PathResolution.qll

Copy file name to clipboardExpand all lines: rust/ql/lib/codeql/rust/internal/PathResolution.qll
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,18 +1404,20 @@ private predicate useImportEdge(Use use, string name, ItemNode item) {
14041404
}
14051405

14061406
/**
1407-
* Holds if `i` is available inside `f` because it is reexported in [the prelude][1].
1407+
* Holds if `i` is available inside `f` because it is reexported in
1408+
* [the `core` prelude][1] or [the `std` prelude][2].
14081409
*
14091410
* We don't yet have access to prelude information from the extractor, so for now
14101411
* we include all the preludes for Rust: 2015, 2018, 2021, and 2024.
14111412
*
14121413
* [1]: https://doc.rust-lang.org/core/prelude/index.html
1414+
* [2]: https://doc.rust-lang.org/std/prelude/index.html
14131415
*/
14141416
private predicate preludeEdge(SourceFile f, string name, ItemNode i) {
1415-
exists(Crate core, ModuleLikeNode mod, ModuleItemNode prelude, ModuleItemNode rust |
1416-
f = any(Crate c0 | core = c0.getDependency(_) or core = c0).getASourceFile() and
1417-
core.getName() = "core" and
1418-
mod = core.getSourceFile() and
1417+
exists(Crate stdOrCore, ModuleLikeNode mod, ModuleItemNode prelude, ModuleItemNode rust |
1418+
f = any(Crate c0 | stdOrCore = c0.getDependency(_) or stdOrCore = c0).getASourceFile() and
1419+
stdOrCore.getName() = ["std", "core"] and
1420+
mod = stdOrCore.getSourceFile() and
14191421
prelude = mod.getASuccessorRec("prelude") and
14201422
rust = prelude.getASuccessorRec(["rust_2015", "rust_2018", "rust_2021", "rust_2024"]) and
14211423
i = rust.getASuccessorRec(name) and

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.