feature: Declare proc-macro dependent crates in rust-project.json#9752
Merged
Conversation
Contributor
|
Excellent, thank you! bors r+ |
Contributor
Member
|
changelog feature (first contribution) support |
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>
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.
This adds the
is_proc_macroflag inrust-project.json. By default, this isfalseand 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_macrosysroot 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.jsonfile. 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.rsfiles), 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.)