From 6c4d5164d9d1c6751f2c63612ad5f68f1eef3a1b Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 8 Dec 2020 19:43:58 +0100 Subject: [PATCH] Better error when a proc macro panics --- crates/proc_macro_srv/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/proc_macro_srv/src/lib.rs b/crates/proc_macro_srv/src/lib.rs index 6e890f8e28..9cca969944 100644 --- a/crates/proc_macro_srv/src/lib.rs +++ b/crates/proc_macro_srv/src/lib.rs @@ -40,7 +40,8 @@ impl ProcMacroSrv { match expander.expand(&task.macro_name, &task.macro_body, task.attributes.as_ref()) { Ok(expansion) => Ok(ExpansionResult { expansion }), Err(msg) => { - Err(format!("Cannot perform expansion for {}: error {:?}", &task.macro_name, msg)) + let msg = msg.as_str().unwrap_or(""); + Err(format!("proc-macro panicked: {}", msg)) } } }