René's URL Explorer Experiment


Title: Rust: modules declared in a file brought in by `include!` are not resolved (no canonical paths, unresolved calls), e.g. in `windows-sys` and `windows` · Issue #23009 · github/codeql · GitHub

Open Graph Title: Rust: modules declared in a file brought in by `include!` are not resolved (no canonical paths, unresolved calls), e.g. in `windows-sys` and `windows` · Issue #23009 · github/codeql

X Title: Rust: modules declared in a file brought in by `include!` are not resolved (no canonical paths, unresolved calls), e.g. in `windows-sys` and `windows` · Issue #23009 · github/codeql

Description: Description of the issue When a crate's lib.rs brings in part of its module tree with include!("tree/mod.rs"), and that file declares pub mod inner;, CodeQL looks for inner next to lib.rs instead of next to tree/mod.rs, where rustc finds...

Open Graph Description: Description of the issue When a crate's lib.rs brings in part of its module tree with include!("tree/mod.rs"), and that file declares pub mod inner;, CodeQL looks for inner next to lib.rs instead o...

X Description: Description of the issue When a crate's lib.rs brings in part of its module tree with include!("tree/mod.rs"), and that file declares pub mod inner;, CodeQL looks for inner next to li...

Opengraph URL: https://github.com/github/codeql/issues/23009

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Rust: modules declared in a file brought in by `include!` are not resolved (no canonical paths, unresolved calls), e.g. in `windows-sys` and `windows`","articleBody":"**Description of the issue**\n\nWhen a crate's `lib.rs` brings in part of its module tree with `include!(\"tree/mod.rs\")`, and that file declares `pub mod inner;`, CodeQL looks for `inner` next to `lib.rs` instead of next to `tree/mod.rs`, where rustc finds it. As a result, nothing in `inner` gets a canonical path, calls into it have no `getStaticTarget()`, and models-as-data rows for its functions never apply.\n\nThe public `windows-sys` and `windows` crates are built this way (`lib.rs` contains `include!(\"Windows/mod.rs\")`), so Windows API calls made through them are never resolved:\n\n- `windows-sys` 0.61.2: 0 of the 10,661 functions under `src/Windows/Win32` have a canonical path.\n- `windows` 0.62.2: 777 of 130,113 do (with `codeql/rust-all` 0.2.25); `CreateFileW` is not among them.\n- Calls to `CreateFileW`, `ReadFile`, `RegQueryValueExW`, `CreateProcessW`, `ShellExecuteW` and `recv` through `windows-sys`, and to the first four through `windows`, are unresolved.\n\nSeen with CodeQL 2.27.2 (`codeql/rust-all` 0.2.23) and 2.27.4 (`codeql/rust-all` 0.2.25), Rust 1.99.0, Windows x64. Setting `extract_dependencies_as_source=true` does not change it.\n\n**Reproduction**\n\nA two-crate workspace. `toy-include` brings in module `inner` through `include!`; module `direct`, declared normally, has the same contents and serves as a control.\n\n`Cargo.toml`\n```toml\n[workspace]\nmembers = [\"toy-include\", \"toy-user\"]\nresolver = \"2\"\n```\n\n`toy-include/Cargo.toml`\n```toml\n[package]\nname = \"toy-include\"\nversion = \"0.1.0\"\nedition = \"2021\"\n```\n\n`toy-include/src/lib.rs`\n```rust\nmacro_rules! declare {\n    ($name:ident) => {\n        extern \"C\" {\n            pub fn $name() -> u32;\n        }\n    };\n}\n\ninclude!(\"tree/mod.rs\");\n\npub mod direct;\n```\n\n`toy-include/src/tree/mod.rs`\n```rust\npub mod inner;\n```\n\n`toy-include/src/tree/inner/mod.rs`\n```rust\npub fn hidden() -> u32 {\n    1\n}\n\ndeclare!(hidden_extern);\n```\n\n`toy-include/src/direct.rs`\n```rust\npub fn visible() -> u32 {\n    2\n}\n\ndeclare!(visible_extern);\n```\n\n`toy-user/Cargo.toml`\n```toml\n[package]\nname = \"toy-user\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\ntoy-include = { path = \"../toy-include\" }\n```\n\n`toy-user/src/main.rs`\n```rust\nfn main() {\n    let a = toy_include::inner::hidden();\n    let b = toy_include::direct::visible();\n    let c = unsafe { toy_include::inner::hidden_extern() };\n    let d = unsafe { toy_include::direct::visible_extern() };\n    println!(\"{}\", a + b + c + d);\n}\n```\n\nThe workspace builds with `cargo check`. Query (`query/qlpack.yml` depends on `codeql/rust-all: \"*\"`):\n\n`query/include-paths.ql`\n```ql\nimport rust\n\n/** Each function of the `toy-include` crate, with its canonical path (none if CodeQL gives none). */\nquery predicate functions(string file, string name, string canonicalPath) {\n  exists(Function f |\n    f.getFile().getAbsolutePath().matches(\"%toy-include%\") and\n    file = f.getFile().getAbsolutePath().regexpCapture(\".*toy-include[/\\\\\\\\]src[/\\\\\\\\](.*)\", 1) and\n    name = f.getName().getText() and\n    if exists(f.getCanonicalPath()) then canonicalPath = f.getCanonicalPath() else canonicalPath = \"(none)\"\n  )\n}\n\n/** Each call in the program, with the function it resolves to (none if unresolved). */\nquery predicate calls(int line, string call, string target) {\n  exists(Call c | c.getFile().getBaseName() = \"main.rs\" |\n    line = c.getLocation().getStartLine() and\n    call = c.toString() and\n    if exists(c.getStaticTarget())\n    then target = c.getStaticTarget().getCanonicalPath()\n    else target = \"(unresolved)\"\n  )\n}\n\nselect 1\n```\n\nRun:\n```\ncodeql database create db --language=rust --source-root=.\ncodeql query run query/include-paths.ql --database=db --output=out.bqrs\ncodeql bqrs decode out.bqrs --format=csv --result-set=functions\ncodeql bqrs decode out.bqrs --format=csv --result-set=calls\n```\n\n**Expected:** `hidden` and `hidden_extern` have the canonical paths `toy_include::inner::hidden` and `toy_include::inner::hidden_extern`, and the calls on lines 2 and 4 resolve to them, like the control module's.\n\n**Actual:**\n```\n\"file\",\"name\",\"canonicalPath\"\n\"direct.rs\",\"visible\",\"toy_include::direct::visible\"\n\"direct.rs\",\"visible_extern\",\"toy_include::direct::visible_extern\"\n\"tree/inner/mod.rs\",\"hidden\",\"(none)\"\n\"tree/inner/mod.rs\",\"hidden_extern\",\"(none)\"\n\n\"line\",\"call\",\"target\"\n2,\"...::hidden(...)\",\"(unresolved)\"\n3,\"...::visible(...)\",\"toy_include::direct::visible\"\n4,\"...::hidden_extern(...)\",\"(unresolved)\"\n5,\"...::visible_extern(...)\",\"toy_include::direct::visible_extern\"\n```\n\n**Likely cause**\n\n- In the extractor, `text_range_for_node` (`rust/extractor/src/translate/base.rs`) keeps a node's location only if it maps into the file being extracted. Nodes produced by an `include!` map into the included file, so the `inner` module in the expansion reports `lib.rs` as its file.\n- `modImport0` in `codeql/rust/internal/PathResolution.qll` then looks for `mod inner;` relative to `lib.rs` (`src/inner.rs`, `src/inner/mod.rs`) instead of `src/tree/`.\n- `tree/mod.rs` is also extracted on its own, and there `mod inner;` does resolve, but that copy is not part of the crate's module tree.\n\nA possible fix: have the extractor give `include!`d nodes their locations in the included file (or record which file each `include!` includes), so that `mod` files are looked up next to the file that declares them.\n\n","author":{"url":"https://github.com/bdrodes","@type":"Person","name":"bdrodes"},"datePublished":"2026-11-04T01:42:23Z","url":"https://github.com/github/codeql/issues/23009"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:62f011be-573d-9564-ecc2-0762b0859bd8
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idECF8:1672EC:152F95A:1BC99E5:6AF890AC
html-safe-nonce8ab2f9daf2acb40b3e730b359fc8d3c91d95e121b08fa8d691fbab7958a7c775
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQ0Y4OjE2NzJFQzoxNTJGOTVBOjFCQzk5RTU6NkFGODkwQUMiLCJ2aXNpdG9yX2lkIjoiNjU2MjEyMzY0Njc4NzY4NjU3MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaca6e0523f49f48cc33fc0a4dc68f2164123eb3438def4b027d1afc63000e34bb4
hovercard-subject-tagissue:6194559589
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/github/codeql/23009/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7106eed8b2167fff905ea4d5669938c433f33cb9ef6ebc42e8e4e8d42ab136f5/github/codeql/issues/23009
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7106eed8b2167fff905ea4d5669938c433f33cb9ef6ebc42e8e4e8d42ab136f5/github/codeql/issues/23009
og:image:altDescription of the issue When a crate's lib.rs brings in part of its module tree with include!("tree/mod.rs"), and that file declares pub mod inner;, CodeQL looks for inner next to lib.rs instead o...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebdrodes
hostnamegithub.com
expected-hostnamegithub.com
None612d3e6ffd693e7ea8d9fcf452370995872baef31d825b1fedef704cd3d24ac7
turbo-cache-controlno-preview
go-importgithub.com/github/codeql git https://github.com/github/codeql.git
octolytics-dimension-user_id9919
octolytics-dimension-user_logingithub
octolytics-dimension-repository_id143040428
octolytics-dimension-repository_nwogithub/codeql
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id143040428
octolytics-dimension-repository_network_root_nwogithub/codeql
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release072e34035c13c31543fba9f025cbbbda4210dae4
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/github/codeql/issues/23009#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgithub%2Fcodeql%2Fissues%2F23009
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgithub%2Fcodeql%2Fissues%2F23009
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=github%2Fcodeql
Reloadhttps://github.com/github/codeql/issues/23009
Reloadhttps://github.com/github/codeql/issues/23009
Reloadhttps://github.com/github/codeql/issues/23009
githubhttps://github.com/github
codeqlhttps://github.com/github/codeql
Codehttps://github.com/github/codeql
Issues1k (1k)https://github.com/github/codeql/issues
Pull requests516 (516)https://github.com/github/codeql/pulls
Discussionshttps://github.com/github/codeql/discussions
Actionshttps://github.com/github/codeql/actions
Projectshttps://github.com/github/codeql/projects
Security and qualityhttps://github.com/github/codeql/security
Insightshttps://github.com/github/codeql/pulse
https://github.com/github/codeql
New issuehttps://github.com/login?return_to=https://github.com/github/codeql/issues/23009
New issuehttps://github.com/login?return_to=https://github.com/github/codeql/issues/23009
#23113https://github.com/github/codeql/pull/23113
Rust: modules declared in a file brought in by include! are not resolved (no canonical paths, unresolved calls), e.g. in windows-sys and windowshttps://github.com/github/codeql/issues/23009#top
#23113https://github.com/github/codeql/pull/23113
https://github.com/hvitved
RustPull requests that update Rust codehttps://github.com/github/codeql/issues?q=state%3Aopen%20label%3A%22Rust%22
https://github.com/bdrodes
bdrodeshttps://github.com/bdrodes
on Nov 4, 2026https://github.com/github/codeql/issues/23009#issue-6194559589
https://github.com/sam-robson
sam-robsonhttps://github.com/sam-robson
on Nov 4, 2026https://github.com/github/codeql/issues/23009#issuecomment-6628627524
@bdrodeshttps://github.com/bdrodes
sam-robsonhttps://github.com/sam-robson
RustPull requests that update Rust codehttps://github.com/github/codeql/issues?q=state%3Aopen%20label%3A%22Rust%22
on Nov 4, 2026https://github.com/github/codeql/issues/23009#event-35118470653
hvitvedhttps://github.com/hvitved
on Nov 5, 2026https://github.com/github/codeql/issues/23009#event-35226065436
https://github.com/hvitved
hvitvedhttps://github.com/hvitved
on Nov 12, 2026https://github.com/github/codeql/issues/23009#issuecomment-6820932154
Sign up for freehttps://github.com/signup?return_to=https://github.com/github/codeql/issues/23009
Sign in to commenthttps://github.com/login?return_to=https://github.com/github/codeql/issues/23009
hvitvedhttps://github.com/hvitved
RustPull requests that update Rust codehttps://github.com/github/codeql/issues?q=state%3Aopen%20label%3A%22Rust%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.