You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rust: resolve modules declared in include expansions - #23113
Preserve source locations in item expansions of include! calls, so module declarations resolve relative to the included file rather than the include invocation.
Use rust-analyzer's resolved include targets and source spans instead of parsing arguments or treating expansion offsets as source offsets. Cache each included file's location data, and extend QL crate membership and nested module lookup to follow included files.
Add regressions for nested includes, qualified and shadowed macro names, alternate delimiters, comments, trailing commas, computed include paths, crate-root references, exported macros, and derives in included files. Regenerate the affected location expectations.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Incorrect source-range mapping and resolving nested includes relative to the outer file produce wrong locations and can leave modules unresolved or incorrectly resolved.
This PR updates Rust extraction so item expansions from literal include! calls retain the included file’s location, allowing module declarations to resolve relative to that file rather than the invocation.
Changes:
Adds included-file context and file-aware location emission to the extractor.
Adds a regression for calling a function in a module declared by an included tree/mod.rs.
Updates location expectations and inline path-resolution checks. Computed include paths remain outside scope.
Use rust-analyzer's resolved include targets and source spans, cache file locations, and follow included files during QL crate and module resolution. Cover nested, qualified, delimited, computed, and shadowed includes with regression tests.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
hvitved
changed the title
Rust: resolve modules declared in literal include expansions
Rust: resolve modules declared in include expansions
Nov 13, 2026
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical defects in include handling still cause incorrect module and macro resolution, missing or spurious crate membership, and lost control-flow graphs for generated code.
Map ordinary macros through their include-site invocation, archive included targets and preserve extraction classification, and keep diagnostics file-aware. Track active crate items rather than physical files, and resolve non-mod.rs include modules relative to the included directory. Add regressions for generated output, disabled and duplicate exports, shared library roots, macro-generated modules, and included-file warnings.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Included-source handling incorrectly excludes compiled code from quality analysis and can omit generated sibling modules or their source control-flow graphs.
Attribute include parse errors to the erroneous source line
rust/extractor/src/translate/base.rs:596
For a syntax error directly in the included text, this still passes the outer include! call as the diagnostic owner. emit_macro_expansion_parse_errors then maps the expansion's error range through that call, whose syntax belongs to the invoking file, so the warning is attributed to the include site instead of the erroneous included line. Map include-expansion parse errors through expanded.value and add a direct syntax-error case to the diagnostics fixture.
Track semantic availability for included files and isolate the library-root include regression from its parent test.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved critical regressions bypass source exclusions, overwrite feature-enabled dependency output, and break initializer data flow and macro shadowing for included code.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical include-handling defects can misresolve nested macros, omit source text for valid include targets, and allow excluded files into source analysis.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Preserve source locations in item expansions of
include!calls, so module declarations resolve relative to the included file rather than the include invocation.Use rust-analyzer's resolved include targets and source spans instead of parsing arguments or treating expansion offsets as source offsets. Cache each included file's location data, and extend QL crate membership and nested module lookup to follow included files.
Add regressions for nested includes, qualified and shadowed macro names, alternate delimiters, comments, trailing commas, computed include paths, crate-root references, exported macros, and derives in included files. Regenerate the affected location expectations.
Fixes #23009.