Skip to content

Rust: Fix bad join #20164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions rust/ql/lib/codeql/rust/internal/PathResolution.qll
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,18 @@ private predicate externCrateEdge(ExternCrateItemNode ec, string name, CrateItem
)
}

pragma[nomagic]
private predicate preludeItem(string name, ItemNode i) {
exists(Crate stdOrCore, ModuleLikeNode mod, ModuleItemNode prelude, ModuleItemNode rust |
stdOrCore.getName() = ["std", "core"] and
mod = stdOrCore.getSourceFile() and
prelude = mod.getASuccessorRec("prelude") and
rust = prelude.getASuccessorRec(["rust_2015", "rust_2018", "rust_2021", "rust_2024"]) and
i = rust.getASuccessorRec(name) and
not i instanceof Use
)
}

/**
* Holds if `i` is available inside `f` because it is reexported in
* [the `core` prelude][1] or [the `std` prelude][2].
Expand All @@ -1476,15 +1488,8 @@ private predicate externCrateEdge(ExternCrateItemNode ec, string name, CrateItem
*/
pragma[nomagic]
private predicate preludeEdge(SourceFile f, string name, ItemNode i) {
not declares(f, _, name) and
exists(Crate stdOrCore, ModuleLikeNode mod, ModuleItemNode prelude, ModuleItemNode rust |
stdOrCore.getName() = ["std", "core"] and
mod = stdOrCore.getSourceFile() and
prelude = mod.getASuccessorRec("prelude") and
rust = prelude.getASuccessorRec(["rust_2015", "rust_2018", "rust_2021", "rust_2024"]) and
i = rust.getASuccessorRec(name) and
not i instanceof Use
)
preludeItem(name, i) and
not declares(f, _, name)
}

pragma[nomagic]
Expand Down