feature: Declare proc-macro dependent crates in rust-project.json
#9752
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.
This adds the
is_proc_macro
flag inrust-project.json
. By default, this isfalse
and not required, so existing projects won't break/have the same behavior as before this change. If the flag is true, a dependency to theproc_macro
sysroot crate is added (if it exists), so that rust-analyzer can resolve those imports.This fixes #9726 .
I've also added some tests in the second commit. The first is a smoke test for a basic, minimal
rust-project.json
file. The second is a more targeted test for the flag. Both tests depend on the fake sysroot (a bunch of directories in the correct layout with emptylib.rs
files), and also onenv!("CARGO_MANIFEST_DIR")
being an absolute path. I'm not sure if the later assumption is valid on all platforms. I wanted to at least try and add tests, but I'm happy to rework them or remove them if you don't think that's the way to go.(You can license/relicense my contribution in any way you wish without contacting me.)