diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-16 21:21:59 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-16 21:21:59 +0100 |
commit | 10d8cb913cb8247ae64b954cf07460f1b6d96ef7 (patch) | |
tree | 976786b86c189d8c03a15378fd62526cbe8eaab7 /crates/ra_proc_macro_srv | |
parent | a4cda3efbbabe4c6129de4dc095953fe858d7d3f (diff) | |
parent | 16a74cfd234e94d383b0ef067fb6a3c651ed9624 (diff) |
Merge #3958
3958: Add proc-macro related config and tests r=matklad a=edwin0cheng
This PR do the following things:
1. Add cli argument `proc-macro` for running proc-macro server.
2. Added support for proc-macro in bench and analysis-stats
3. Added typescript config for proc-macros
4. Added an heavy test for proc-macros.
To test it out:
1. run `cargo xtask install --proc-macro`
2. add `"rust-analyzer.cargo.loadOutDirsFromCheck": true"` and `"rust-analyzer.procMacro.enabled": true"` in vs code config.
[Edit] Change to use `rust-analyzer proc-macro` for running proc-macro standalone process.
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_proc_macro_srv')
-rw-r--r-- | crates/ra_proc_macro_srv/src/cli.rs (renamed from crates/ra_proc_macro_srv/src/main.rs) | 5 | ||||
-rw-r--r-- | crates/ra_proc_macro_srv/src/lib.rs | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/crates/ra_proc_macro_srv/src/main.rs b/crates/ra_proc_macro_srv/src/cli.rs index 70743c1f4..c771f2b38 100644 --- a/crates/ra_proc_macro_srv/src/main.rs +++ b/crates/ra_proc_macro_srv/src/cli.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! Driver for proc macro server | 1 | //! Driver for proc macro server |
2 | 2 | ||
3 | use crate::{expand_task, list_macros}; | ||
3 | use ra_proc_macro::msg::{self, Message}; | 4 | use ra_proc_macro::msg::{self, Message}; |
4 | use ra_proc_macro_srv::{expand_task, list_macros}; | ||
5 | 5 | ||
6 | use std::io; | 6 | use std::io; |
7 | 7 | ||
@@ -24,7 +24,8 @@ fn write_response(res: Result<msg::Response, String>) -> Result<(), io::Error> { | |||
24 | let mut stdout = stdout.lock(); | 24 | let mut stdout = stdout.lock(); |
25 | msg.write(&mut stdout) | 25 | msg.write(&mut stdout) |
26 | } | 26 | } |
27 | fn main() { | 27 | |
28 | pub fn run() { | ||
28 | loop { | 29 | loop { |
29 | let req = match read_request() { | 30 | let req = match read_request() { |
30 | Err(err) => { | 31 | Err(err) => { |
diff --git a/crates/ra_proc_macro_srv/src/lib.rs b/crates/ra_proc_macro_srv/src/lib.rs index 59716cbb3..c62b0ed89 100644 --- a/crates/ra_proc_macro_srv/src/lib.rs +++ b/crates/ra_proc_macro_srv/src/lib.rs | |||
@@ -22,7 +22,7 @@ mod dylib; | |||
22 | use proc_macro::bridge::client::TokenStream; | 22 | use proc_macro::bridge::client::TokenStream; |
23 | use ra_proc_macro::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask}; | 23 | use ra_proc_macro::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask}; |
24 | 24 | ||
25 | pub fn expand_task(task: &ExpansionTask) -> Result<ExpansionResult, String> { | 25 | pub(crate) fn expand_task(task: &ExpansionTask) -> Result<ExpansionResult, String> { |
26 | let expander = dylib::Expander::new(&task.lib) | 26 | let expander = dylib::Expander::new(&task.lib) |
27 | .expect(&format!("Cannot expand with provided libraries: ${:?}", &task.lib)); | 27 | .expect(&format!("Cannot expand with provided libraries: ${:?}", &task.lib)); |
28 | 28 | ||
@@ -39,7 +39,7 @@ pub fn expand_task(task: &ExpansionTask) -> Result<ExpansionResult, String> { | |||
39 | } | 39 | } |
40 | } | 40 | } |
41 | 41 | ||
42 | pub fn list_macros(task: &ListMacrosTask) -> Result<ListMacrosResult, String> { | 42 | pub(crate) fn list_macros(task: &ListMacrosTask) -> Result<ListMacrosResult, String> { |
43 | let expander = dylib::Expander::new(&task.lib) | 43 | let expander = dylib::Expander::new(&task.lib) |
44 | .expect(&format!("Cannot expand with provided libraries: ${:?}", &task.lib)); | 44 | .expect(&format!("Cannot expand with provided libraries: ${:?}", &task.lib)); |
45 | 45 | ||
@@ -53,5 +53,7 @@ pub fn list_macros(task: &ListMacrosTask) -> Result<ListMacrosResult, String> { | |||
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
56 | pub mod cli; | ||
57 | |||
56 | #[cfg(test)] | 58 | #[cfg(test)] |
57 | mod tests; | 59 | mod tests; |