From 52a2d962ee1e5e67314b815ff8840071de0d5a16 Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 25 Dec 2020 02:05:02 +0100 Subject: [PATCH] tokio-xmpp: add build script to work around build fail on rustc 1.48 --- tokio-xmpp/Cargo.toml | 3 +++ tokio-xmpp/build.rs | 11 +++++++++++ tokio-xmpp/src/xmpp_stream.rs | 8 ++++---- 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 tokio-xmpp/build.rs diff --git a/tokio-xmpp/Cargo.toml b/tokio-xmpp/Cargo.toml index c5aa823..6eae375 100644 --- a/tokio-xmpp/Cargo.toml +++ b/tokio-xmpp/Cargo.toml @@ -26,5 +26,8 @@ trust-dns-proto = "0.19" xml5ever = "0.16" xmpp-parsers = "0.17" +[build-dependencies] +rustc_version = "0.3" + [features] serde = ["xmpp-parsers/serde"] diff --git a/tokio-xmpp/build.rs b/tokio-xmpp/build.rs new file mode 100644 index 0000000..6022bd5 --- /dev/null +++ b/tokio-xmpp/build.rs @@ -0,0 +1,11 @@ +use rustc_version::version; + +fn main() { + let version = version().unwrap(); + + for major in 1..=version.major { + for minor in 0..=version.minor { + println!("cargo:rustc-cfg=rustc_least_{}_{}", major, minor); + } + } +} diff --git a/tokio-xmpp/src/xmpp_stream.rs b/tokio-xmpp/src/xmpp_stream.rs index d9553f0..5ed49c8 100644 --- a/tokio-xmpp/src/xmpp_stream.rs +++ b/tokio-xmpp/src/xmpp_stream.rs @@ -88,19 +88,19 @@ impl Sink for XMPPStream { Poll::Ready(Ok(())) } - fn start_send(mut self: Pin<&mut Self>, item: Packet) -> Result<(), Self::Error> { + fn start_send(#[cfg_attr(rustc_least_1_48, allow(unused_mut))] mut self: Pin<&mut Self>, item: Packet) -> Result<(), Self::Error> { Pin::new(&mut self.stream.lock().unwrap().deref_mut()) .start_send(item) .map_err(|e| e.into()) } - fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + fn poll_flush(#[cfg_attr(rustc_least_1_48, allow(unused_mut))] mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { Pin::new(&mut self.stream.lock().unwrap().deref_mut()) .poll_flush(cx) .map_err(|e| e.into()) } - fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + fn poll_close(#[cfg_attr(rustc_least_1_48, allow(unused_mut))] mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { Pin::new(&mut self.stream.lock().unwrap().deref_mut()) .poll_close(cx) .map_err(|e| e.into()) @@ -111,7 +111,7 @@ impl Sink for XMPPStream { impl Stream for XMPPStream { type Item = Result; - fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + fn poll_next(#[cfg_attr(rustc_least_1_48, allow(unused_mut))] mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { Pin::new(&mut self.stream.lock().unwrap().deref_mut()) .poll_next(cx) .map(|result| result.map(|result| result.map_err(|e| e.into())))