From d8325212f445aed81a0fcc75b300dbb7606813d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 11 Jul 2019 18:50:37 +0300 Subject: [PATCH] Fix various clippy warnings --- examples/src/bin/glupload.rs | 4 ++-- examples/src/bin/rtpfecclient.rs | 2 +- examples/src/bin/rtpfecserver.rs | 2 +- gstreamer-base/src/subclass/aggregator_pad.rs | 1 - gstreamer-sdp/src/sdp_message.rs | 4 ++-- gstreamer-video/src/subclass/mod.rs | 2 +- gstreamer-video/src/subclass/video_decoder.rs | 11 +++++------ gstreamer-video/src/subclass/video_encoder.rs | 4 ++-- gstreamer/src/enums.rs | 1 + 9 files changed, 15 insertions(+), 16 deletions(-) diff --git a/examples/src/bin/glupload.rs b/examples/src/bin/glupload.rs index 6c7420617..d6e72cf0f 100644 --- a/examples/src/bin/glupload.rs +++ b/examples/src/bin/glupload.rs @@ -468,8 +468,8 @@ impl App { appsink, glupload, bus, - events_loop: events_loop, - windowed_context: windowed_context, + events_loop, + windowed_context, shared_context, }) } diff --git a/examples/src/bin/rtpfecclient.rs b/examples/src/bin/rtpfecclient.rs index 0d3f9975d..9d1ded8e4 100644 --- a/examples/src/bin/rtpfecclient.rs +++ b/examples/src/bin/rtpfecclient.rs @@ -49,7 +49,7 @@ fn make_element( factory_name: &'static str, element_name: Option<&str>, ) -> Result { - match gst::ElementFactory::make(factory_name, element_name.into()) { + match gst::ElementFactory::make(factory_name, element_name) { Some(elem) => Ok(elem), None => Err(Error::from(MissingElement(factory_name))), } diff --git a/examples/src/bin/rtpfecserver.rs b/examples/src/bin/rtpfecserver.rs index 2b44fc266..be6cfce2d 100644 --- a/examples/src/bin/rtpfecserver.rs +++ b/examples/src/bin/rtpfecserver.rs @@ -46,7 +46,7 @@ fn make_element( factory_name: &'static str, element_name: Option<&str>, ) -> Result { - match gst::ElementFactory::make(factory_name, element_name.into()) { + match gst::ElementFactory::make(factory_name, element_name) { Some(elem) => Ok(elem), None => Err(Error::from(MissingElement(factory_name))), } diff --git a/gstreamer-base/src/subclass/aggregator_pad.rs b/gstreamer-base/src/subclass/aggregator_pad.rs index b26e55091..6bacb3c32 100644 --- a/gstreamer-base/src/subclass/aggregator_pad.rs +++ b/gstreamer-base/src/subclass/aggregator_pad.rs @@ -12,7 +12,6 @@ use gst_sys; use glib::translate::*; use gst; -use gst::prelude::*; use glib::subclass::prelude::*; use gst::subclass::prelude::*; diff --git a/gstreamer-sdp/src/sdp_message.rs b/gstreamer-sdp/src/sdp_message.rs index 0b5dd7622..935d36cec 100644 --- a/gstreamer-sdp/src/sdp_message.rs +++ b/gstreamer-sdp/src/sdp_message.rs @@ -1016,7 +1016,7 @@ macro_rules! define_iter_mut( // example removes the message that was returned here at an earlier time. The compiler // would be correct to complain in that case, but we don't provide such a function. let message = unsafe { - mem::transmute::<(&mut SDPMessageRef), (&'a mut SDPMessageRef)>(&mut self.message) + &mut *(&mut self.message as *mut &'a mut SDPMessageRef as *mut SDPMessageRef) }; if self.idx >= self.len { return None; @@ -1041,7 +1041,7 @@ macro_rules! define_iter_mut( impl<'a> DoubleEndedIterator for $name<'a> { fn next_back(&mut self) -> Option { let message = unsafe { - mem::transmute::<(&mut SDPMessageRef), (&'a mut SDPMessageRef)>(&mut self.message) + &mut *(&mut self.message as *mut &'a mut SDPMessageRef as *mut SDPMessageRef) }; if self.idx == self.len { return None; diff --git a/gstreamer-video/src/subclass/mod.rs b/gstreamer-video/src/subclass/mod.rs index 2c042a06c..099b1bf1a 100644 --- a/gstreamer-video/src/subclass/mod.rs +++ b/gstreamer-video/src/subclass/mod.rs @@ -5,7 +5,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] +#![allow(clippy::cast_ptr_alignment)] pub mod video_decoder; pub mod video_encoder; diff --git a/gstreamer-video/src/subclass/video_decoder.rs b/gstreamer-video/src/subclass/video_decoder.rs index 95f8f53f6..120bd718f 100644 --- a/gstreamer-video/src/subclass/video_decoder.rs +++ b/gstreamer-video/src/subclass/video_decoder.rs @@ -516,10 +516,10 @@ where let imp = instance.get_impl(); let wrap: VideoDecoder = from_glib_borrow(ptr); gst_video_sys::gst_video_codec_state_ref(state); - let mut wrap_state = VideoCodecState::::new(state); + let wrap_state = VideoCodecState::::new(state); gst_panic_to_error!(&wrap, &instance.panicked(), false, { - match imp.set_format(&wrap, &mut wrap_state) { + match imp.set_format(&wrap, &wrap_state) { Ok(()) => true, Err(err) => { err.log_with_object(&wrap); @@ -545,13 +545,12 @@ where let imp = instance.get_impl(); let wrap: VideoDecoder = from_glib_borrow(ptr); gst_video_sys::gst_video_codec_frame_ref(frame); - let mut wrap_frame = VideoCodecFrame::new(frame, &wrap); - let mut wrap_adapter: gst_base::Adapter = from_glib_borrow(adapter); + let wrap_frame = VideoCodecFrame::new(frame, &wrap); + let wrap_adapter: gst_base::Adapter = from_glib_borrow(adapter); let at_eos: bool = from_glib(at_eos); gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, { - imp.parse(&wrap, &mut wrap_frame, &mut wrap_adapter, at_eos) - .into() + imp.parse(&wrap, &wrap_frame, &wrap_adapter, at_eos).into() }) .to_glib() } diff --git a/gstreamer-video/src/subclass/video_encoder.rs b/gstreamer-video/src/subclass/video_encoder.rs index 949232e79..76e1cac34 100644 --- a/gstreamer-video/src/subclass/video_encoder.rs +++ b/gstreamer-video/src/subclass/video_encoder.rs @@ -470,10 +470,10 @@ where let imp = instance.get_impl(); let wrap: VideoEncoder = from_glib_borrow(ptr); gst_video_sys::gst_video_codec_state_ref(state); - let mut wrap_state = VideoCodecState::::new(state); + let wrap_state = VideoCodecState::::new(state); gst_panic_to_error!(&wrap, &instance.panicked(), false, { - match imp.set_format(&wrap, &mut wrap_state) { + match imp.set_format(&wrap, &wrap_state) { Ok(()) => true, Err(err) => { err.log_with_object(&wrap); diff --git a/gstreamer/src/enums.rs b/gstreamer/src/enums.rs index 28798a890..cd9705272 100644 --- a/gstreamer/src/enums.rs +++ b/gstreamer/src/enums.rs @@ -608,6 +608,7 @@ impl ToGlib for MessageType { #[doc(hidden)] impl FromGlib for MessageType { + #[allow(clippy::unreadable_literal)] fn from_glib(value: gst_sys::GstMessageType) -> Self { skip_assert_initialized!(); match value {