From 085e9266e3336416cfa0dde2840a2c9afd6fef1c Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Wed, 2 Jan 2019 17:20:12 +0100 Subject: [PATCH] Work around https://github.com/rust-lang/rust/pull/55937 This exchanges a compilation error for a warning-but-future-error but at least it compiles now and I'm not exactly sure how to fix it without cloning those `METHOD` constants on every match (which is less than ideal, to say the least). --- src/server/mod.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index e394da370cd..93cf12ebd98 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -170,7 +170,7 @@ impl LsService { } } - fn dispatch_message(&mut self, msg: &RawMessage) -> Result<(), jsonrpc::Error> { + fn dispatch_message(&mut self, msg: RawMessage) -> Result<(), jsonrpc::Error> { macro_rules! match_action { ( $method: expr; @@ -334,9 +334,12 @@ impl LsService { } } - if let Err(e) = self.dispatch_message(&raw_message) { + // Workaround https://github.com/rust-lang/rust/pull/55937 by moving + // raw_message instead of borrowing. + let id = raw_message.id.clone(); + if let Err(e) = self.dispatch_message(raw_message) { error!("dispatch error: {:?}, message: `{}`", e, msg_string); - self.output.failure(raw_message.id, e); + self.output.failure(id, e); return ServerStateChange::Break { exit_code: 101 }; }