aboutsummaryrefslogtreecommitdiff
path: root/crates/proc_macro_srv/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/proc_macro_srv/src')
-rw-r--r--crates/proc_macro_srv/src/cli.rs7
-rw-r--r--crates/proc_macro_srv/src/rustc_server.rs9
2 files changed, 13 insertions, 3 deletions
diff --git a/crates/proc_macro_srv/src/cli.rs b/crates/proc_macro_srv/src/cli.rs
index d428b9567..bc48f1c43 100644
--- a/crates/proc_macro_srv/src/cli.rs
+++ b/crates/proc_macro_srv/src/cli.rs
@@ -6,8 +6,9 @@ use std::io;
6 6
7pub fn run() -> io::Result<()> { 7pub fn run() -> io::Result<()> {
8 let mut srv = ProcMacroSrv::default(); 8 let mut srv = ProcMacroSrv::default();
9 let mut buf = String::new();
9 10
10 while let Some(req) = read_request()? { 11 while let Some(req) = read_request(&mut buf)? {
11 let res = match req { 12 let res = match req {
12 msg::Request::ListMacro(task) => srv.list_macros(&task).map(msg::Response::ListMacro), 13 msg::Request::ListMacro(task) => srv.list_macros(&task).map(msg::Response::ListMacro),
13 msg::Request::ExpansionMacro(task) => { 14 msg::Request::ExpansionMacro(task) => {
@@ -30,8 +31,8 @@ pub fn run() -> io::Result<()> {
30 Ok(()) 31 Ok(())
31} 32}
32 33
33fn read_request() -> io::Result<Option<msg::Request>> { 34fn read_request(buf: &mut String) -> io::Result<Option<msg::Request>> {
34 msg::Request::read(&mut io::stdin().lock()) 35 msg::Request::read(&mut io::stdin().lock(), buf)
35} 36}
36 37
37fn write_response(msg: msg::Response) -> io::Result<()> { 38fn write_response(msg: msg::Response) -> io::Result<()> {
diff --git a/crates/proc_macro_srv/src/rustc_server.rs b/crates/proc_macro_srv/src/rustc_server.rs
index ceefd187d..c147484c0 100644
--- a/crates/proc_macro_srv/src/rustc_server.rs
+++ b/crates/proc_macro_srv/src/rustc_server.rs
@@ -805,5 +805,14 @@ mod tests {
805 let t2 = TokenStream::from_str("(a);").unwrap(); 805 let t2 = TokenStream::from_str("(a);").unwrap();
806 assert_eq!(t2.token_trees.len(), 2); 806 assert_eq!(t2.token_trees.len(), 2);
807 assert_eq!(t2.token_trees[0], subtree_paren_a); 807 assert_eq!(t2.token_trees[0], subtree_paren_a);
808
809 let underscore = TokenStream::from_str("_").unwrap();
810 assert_eq!(
811 underscore.token_trees[0],
812 tt::TokenTree::Leaf(tt::Leaf::Ident(tt::Ident {
813 text: "_".into(),
814 id: tt::TokenId::unspecified(),
815 }))
816 );
808 } 817 }
809} 818}