aboutsummaryrefslogtreecommitdiff
path: root/crates/proc_macro_api/src/msg.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/proc_macro_api/src/msg.rs')
-rw-r--r--crates/proc_macro_api/src/msg.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/proc_macro_api/src/msg.rs b/crates/proc_macro_api/src/msg.rs
index f84ebdbc5..970f165ed 100644
--- a/crates/proc_macro_api/src/msg.rs
+++ b/crates/proc_macro_api/src/msg.rs
@@ -58,7 +58,13 @@ pub trait Message: Serialize + DeserializeOwned {
58 fn read(inp: &mut impl BufRead) -> io::Result<Option<Self>> { 58 fn read(inp: &mut impl BufRead) -> io::Result<Option<Self>> {
59 Ok(match read_json(inp)? { 59 Ok(match read_json(inp)? {
60 None => None, 60 None => None,
61 Some(text) => Some(serde_json::from_str(&text)?), 61 Some(text) => {
62 let mut deserializer = serde_json::Deserializer::from_str(&text);
63 // Note that some proc-macro generate very deep syntax tree
64 // We have to disable the current limit of serde here
65 deserializer.disable_recursion_limit();
66 Some(Self::deserialize(&mut deserializer)?)
67 }
62 }) 68 })
63 } 69 }
64 fn write(self, out: &mut impl Write) -> io::Result<()> { 70 fn write(self, out: &mut impl Write) -> io::Result<()> {
@@ -73,7 +79,7 @@ impl Message for Response {}
73fn read_json(inp: &mut impl BufRead) -> io::Result<Option<String>> { 79fn read_json(inp: &mut impl BufRead) -> io::Result<Option<String>> {
74 let mut buf = String::new(); 80 let mut buf = String::new();
75 inp.read_line(&mut buf)?; 81 inp.read_line(&mut buf)?;
76 buf.pop(); // Remove traling '\n' 82 buf.pop(); // Remove trailing '\n'
77 Ok(match buf.len() { 83 Ok(match buf.len() {
78 0 => None, 84 0 => None,
79 _ => Some(buf), 85 _ => Some(buf),