-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add rust-analyzer-proc-macro-srv
binary, use it if found in sysroot
#12858
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5f54ec0
Add a proc-macro-srv-cli crate
fasterthanlime fba6adf
Add doc comment to pass tidy check
fasterthanlime fd1b64e
Return result directly
fasterthanlime 4364531
Name the binary 'proc-macro-srv'
fasterthanlime dadb832
Remember the difference between 'sysroot root' and 'sysroot src root'…
fasterthanlime 74a2fad
Gate and rename binary, use it if it's in the sysroot
fasterthanlime 6967751
Fix mix up in comments
fasterthanlime 2c2520f
Allow specifying sysroot OR sysroot_src
fasterthanlime File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "proc-macro-srv-cli" | ||
version = "0.0.0" | ||
description = "TBD" | ||
license = "MIT OR Apache-2.0" | ||
edition = "2021" | ||
rust-version = "1.57" | ||
|
||
[dependencies] | ||
proc-macro-srv = { version = "0.0.0", path = "../proc-macro-srv" } | ||
|
||
[features] | ||
sysroot-abi = ["proc-macro-srv/sysroot-abi"] | ||
|
||
[[bin]] | ||
name = "rust-analyzer-proc-macro-srv" | ||
path = "src/main.rs" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//! A standalone binary for `proc-macro-srv`. | ||
|
||
use proc_macro_srv::cli; | ||
|
||
fn main() -> std::io::Result<()> { | ||
let v = std::env::var("RUST_ANALYZER_INTERNALS_DO_NOT_USE"); | ||
match v.as_deref() { | ||
Ok("this is unstable") => { | ||
// very well, if you must | ||
} | ||
_ => { | ||
eprintln!("If you're rust-analyzer, you can use this tool by exporting RUST_ANALYZER_INTERNALS_DO_NOT_USE='this is unstable'."); | ||
eprintln!("If not, you probably shouldn't use this tool. But do what you want: I'm an error message, not a cop."); | ||
std::process::exit(122); | ||
} | ||
} | ||
|
||
cli::run() | ||
} |
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So at this point in time, we don't have any support for
ProjectWorkspace::Json
, even ifsysroot
is set?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did proc-macros ever work for project.json workspaces actually? From the looks of it we never even build build scripts for them since we can't really do that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, proc macros should work with project.json workspaces. We have a field that allows specifying the path of the compiled proc macro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you point me to where the proc-macro-srv is spawned for ProjectWorkspace::Json workspaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rust-analyzer/crates/project-model/src/workspace.rs
Line 484 in b1e9bcd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@woody77 that match is definitely missing an arm I forgot to add when I added the additional field to rust-project.json's schema. I also didn't have any projects to test it with. I encourage you to open the small PR to fix it!