Skip to content

feature: Declare proc-macro dependent crates in rust-project.json #9752

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 2 commits into from
Aug 2, 2021
Merged

feature: Declare proc-macro dependent crates in rust-project.json #9752

merged 2 commits into from
Aug 2, 2021

Conversation

tobywf
Copy link
Contributor

@tobywf tobywf commented Aug 1, 2021

This adds the is_proc_macro flag in rust-project.json. By default, this is false 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 the proc_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 empty lib.rs files), and also on env!("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.)

@matklad
Copy link
Member

matklad commented Aug 2, 2021

Excellent, thank you!

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 2, 2021

@bors bors bot merged commit 314e2e7 into rust-lang:master Aug 2, 2021
@tobywf tobywf deleted the rust-project-is-proc-macro branch August 2, 2021 14:28
@lnicola
Copy link
Member

lnicola commented Aug 2, 2021

changelog feature (first contribution) support proc_macro dependencies in project.json

ojeda pushed a commit to Rust-for-Linux/linux that referenced this pull request Aug 26, 2021
…ro field

rust-analyzer now doesn't complain about unresolved imports anymore
inside of the rust/macros crate.

Upstream PR which added the field:
rust-lang/rust-analyzer#9752

Signed-off-by: Boris-Chengbiao Zhou <bobo1239@web.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rust-project.json sysroot crates question
3 participants