Repartition source roots after running build scripts#22176
Open
jnkr-ifx wants to merge 1 commit intorust-lang:masterfrom
Open
Repartition source roots after running build scripts#22176jnkr-ifx wants to merge 1 commit intorust-lang:masterfrom
jnkr-ifx wants to merge 1 commit intorust-lang:masterfrom
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I ran into the following issue:
I have a library crate which contains an (example) application crate in a subdirectory. The application depends on the library using a
pathdependency, and the library contains abuild.rswhich generates some code that isinclude!'d by the library.Minimal reproduction
library/Cargo.toml:library/build.rs:library/src/lib.rs:library/application/Cargo.toml:library/application/src/main.rs:When running
rust-analyzerwithin the application, theinclude!fails with the error "failed to load file/path/to/target/.../out/include.rs", despite the path being present on the disk; and definitions within the generated code are unavailable to RA.I debugged the issue and found it to be a problem with VFS source root partitioning:
include.rswas missing fromlibrary's source root.Normally, when loading a workspace, RA:
target/directory, and partitions them into the appropriate source rootsThe discovery of the new files then causes the VFS to be repartitioned, ensuring the build script outputs are placed into the appropriate source roots.
However, this fails when crates are placed in this nested folder structure. Step 1 finds the build script outputs early (I think they're found when scanning the
library/crate, sincelibrary/application/targetis notlibrary's target directory and so is not skipped). By the time we get to step 3, all the files have already been discovered, and so we don't notice a change in the project structure and source root repartitioning does not get a chance to run with the configuration from step 2.This PR fixes the issue by explicitly repartitioning source roots after changing the source root configuration.