diff --git a/examples/src/bin/rtpfecclient.rs b/examples/src/bin/rtpfecclient.rs index ac8da9f9d..aabd961b7 100644 --- a/examples/src/bin/rtpfecclient.rs +++ b/examples/src/bin/rtpfecclient.rs @@ -74,7 +74,7 @@ fn get_request_pad(element: &gst::Element, pad_name: &'static str) -> Result Result<(), Error> { let name = src_pad.get_name(); - let split_name = name.split("_"); + let split_name = name.split('_'); let split_name = split_name.collect::>(); let pt = split_name[5].parse::()?; @@ -248,7 +248,7 @@ fn example_main() -> Result<(), Error> { return Err(ErrorMessage { src: msg.get_src() .map(|s| s.get_path_string()) - .unwrap_or(String::from("None")), + .unwrap_or_else(|| String::from("None")), error: err.get_error().description().into(), debug: err.get_debug(), cause: err.get_error(), diff --git a/examples/src/bin/rtpfecserver.rs b/examples/src/bin/rtpfecserver.rs index e35451de4..61cf3664a 100644 --- a/examples/src/bin/rtpfecserver.rs +++ b/examples/src/bin/rtpfecserver.rs @@ -186,7 +186,7 @@ fn example_main() -> Result<(), Error> { return Err(ErrorMessage { src: msg.get_src() .map(|s| s.get_path_string()) - .unwrap_or(String::from("None")), + .unwrap_or_else(|| String::from("None")), error: err.get_error().description().into(), debug: err.get_debug(), cause: err.get_error(), diff --git a/examples/src/bin/rtsp-server-record.rs b/examples/src/bin/rtsp-server-record.rs index d95b17076..70973c08b 100644 --- a/examples/src/bin/rtsp-server-record.rs +++ b/examples/src/bin/rtsp-server-record.rs @@ -42,7 +42,7 @@ fn main_loop() -> Result<(), Error> { let factory = RTSPMediaFactory::new(); let mounts = server.get_mount_points().ok_or(NoMountPoints)?; let auth = RTSPAuth::new(); - let mut token = RTSPToken::new(&[(*RTSP_TOKEN_MEDIA_FACTORY_ROLE, &"user")]); + let token = RTSPToken::new(&[(*RTSP_TOKEN_MEDIA_FACTORY_ROLE, &"user")]); let basic = RTSPAuth::make_basic("user", "password"); let cert = gio::TlsCertificate::new_from_pem( "-----BEGIN CERTIFICATE-----\ @@ -86,7 +86,7 @@ fn main_loop() -> Result<(), Error> { } auth.set_tls_certificate(&cert); - auth.add_basic(basic.as_str(), &mut token); + auth.add_basic(basic.as_str(), &token); server.set_auth(&auth); factory.set_launch(args[1].as_str()); factory.set_transport_mode(RTSPTransportMode::RECORD); diff --git a/examples/src/bin/tagsetter.rs b/examples/src/bin/tagsetter.rs index 91d0d725b..1e4d12b76 100644 --- a/examples/src/bin/tagsetter.rs +++ b/examples/src/bin/tagsetter.rs @@ -53,7 +53,7 @@ fn example_main() -> Result<(), Error> { let tagsetter = pipeline .get_by_interface(gst::TagSetter::static_type()) - .ok_or(failure::err_msg("No TagSetter found"))?; + .ok_or_else(|| failure::err_msg("No TagSetter found"))?; let tagsetter = tagsetter .dynamic_cast::() .map_err(|_| failure::err_msg("No TagSetter found"))?; diff --git a/gstreamer-app/src/app_sink.rs b/gstreamer-app/src/app_sink.rs index 46b3a0677..0561d764c 100644 --- a/gstreamer-app/src/app_sink.rs +++ b/gstreamer-app/src/app_sink.rs @@ -15,6 +15,7 @@ use std::cell::RefCell; use std::ptr; use AppSink; +#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] pub struct AppSinkCallbacks { eos: Option>>, new_preroll: Option gst::FlowReturn + Send + 'static>>>, @@ -36,6 +37,7 @@ impl AppSinkCallbacks { } } +#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] pub struct AppSinkCallbacksBuilder { eos: Option>>, new_preroll: Option gst::FlowReturn + Send + 'static>>>, @@ -105,10 +107,9 @@ impl AppSinkCallbacksBuilder { unsafe extern "C" fn trampoline_eos(appsink: *mut ffi::GstAppSink, callbacks: gpointer) { let callbacks = &*(callbacks as *const AppSinkCallbacks); - callbacks - .eos - .as_ref() - .map(|f| (&mut *f.borrow_mut())(&from_glib_borrow(appsink))); + if let Some(ref eos) = callbacks.eos { + (&mut *eos.borrow_mut())(&from_glib_borrow(appsink)) + } } unsafe extern "C" fn trampoline_new_preroll( @@ -117,12 +118,13 @@ unsafe extern "C" fn trampoline_new_preroll( ) -> gst_ffi::GstFlowReturn { let callbacks = &*(callbacks as *const AppSinkCallbacks); - callbacks - .new_preroll - .as_ref() - .map(|f| (&mut *f.borrow_mut())(&from_glib_borrow(appsink))) - .unwrap_or(gst::FlowReturn::Error) - .to_glib() + let ret = if let Some(ref new_preroll) = callbacks.new_preroll { + (&mut *new_preroll.borrow_mut())(&from_glib_borrow(appsink)) + } else { + gst::FlowReturn::Error + }; + + ret.to_glib() } unsafe extern "C" fn trampoline_new_sample( @@ -131,12 +133,13 @@ unsafe extern "C" fn trampoline_new_sample( ) -> gst_ffi::GstFlowReturn { let callbacks = &*(callbacks as *const AppSinkCallbacks); - callbacks - .new_sample - .as_ref() - .map(|f| (&mut *f.borrow_mut())(&from_glib_borrow(appsink))) - .unwrap_or(gst::FlowReturn::Error) - .to_glib() + let ret = if let Some(ref new_sample) = callbacks.new_sample { + (&mut *new_sample.borrow_mut())(&from_glib_borrow(appsink)) + } else { + gst::FlowReturn::Error + }; + + ret.to_glib() } unsafe extern "C" fn destroy_callbacks(ptr: gpointer) { diff --git a/gstreamer-app/src/app_src.rs b/gstreamer-app/src/app_src.rs index d6eeff46b..46e84f874 100644 --- a/gstreamer-app/src/app_src.rs +++ b/gstreamer-app/src/app_src.rs @@ -15,6 +15,7 @@ use std::mem; use std::ptr; use AppSrc; +#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] pub struct AppSrcCallbacks { need_data: Option>>, enough_data: Option>, @@ -37,6 +38,7 @@ impl AppSrcCallbacks { } } +#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] pub struct AppSrcCallbacksBuilder { need_data: Option>>, enough_data: Option>, @@ -111,19 +113,17 @@ unsafe extern "C" fn trampoline_need_data( ) { let callbacks = &*(callbacks as *const AppSrcCallbacks); - callbacks - .need_data - .as_ref() - .map(|f| (&mut *f.borrow_mut())(&from_glib_borrow(appsrc), length)); + if let Some(ref need_data) = callbacks.need_data { + (&mut *need_data.borrow_mut())(&from_glib_borrow(appsrc), length); + } } unsafe extern "C" fn trampoline_enough_data(appsrc: *mut ffi::GstAppSrc, callbacks: gpointer) { let callbacks = &*(callbacks as *const AppSrcCallbacks); - callbacks - .enough_data - .as_ref() - .map(|f| f(&from_glib_borrow(appsrc))); + if let Some(ref enough_data) = callbacks.enough_data { + (*enough_data)(&from_glib_borrow(appsrc)); + } } unsafe extern "C" fn trampoline_seek_data( @@ -133,12 +133,13 @@ unsafe extern "C" fn trampoline_seek_data( ) -> gboolean { let callbacks = &*(callbacks as *const AppSrcCallbacks); - callbacks - .seek_data - .as_ref() - .map(|f| f(&from_glib_borrow(appsrc), offset)) - .unwrap_or(false) - .to_glib() + let ret = if let Some(ref seek_data) = callbacks.seek_data { + (*seek_data)(&from_glib_borrow(appsrc), offset) + } else { + false + }; + + ret.to_glib() } unsafe extern "C" fn destroy_callbacks(ptr: gpointer) { diff --git a/gstreamer-audio/src/audio_channel_position.rs b/gstreamer-audio/src/audio_channel_position.rs index ceaec1369..9a6b4625f 100644 --- a/gstreamer-audio/src/audio_channel_position.rs +++ b/gstreamer-audio/src/audio_channel_position.rs @@ -19,7 +19,7 @@ use gst::MiniObject; use array_init; impl AudioChannelPosition { - pub fn to_mask(&self) -> u64 { + pub fn to_mask(self) -> u64 { unsafe { let val = mem::transmute::(self.to_glib()); 1 << val diff --git a/gstreamer-audio/src/audio_format.rs b/gstreamer-audio/src/audio_format.rs index ff6e65b75..16df3ae43 100644 --- a/gstreamer-audio/src/audio_format.rs +++ b/gstreamer-audio/src/audio_format.rs @@ -39,8 +39,8 @@ impl ::AudioFormat { unsafe { from_glib(ffi::gst_audio_format_from_string(s.to_glib_none().0)) } } - pub fn to_string<'a>(&self) -> &'a str { - if *self == ::AudioFormat::Unknown { + pub fn to_string<'a>(self) -> &'a str { + if self == ::AudioFormat::Unknown { return "UNKNOWN"; } @@ -69,7 +69,7 @@ impl str::FromStr for ::AudioFormat { impl fmt::Display for ::AudioFormat { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - f.write_str(self.to_string()) + f.write_str(self.to_string().as_str()) } } diff --git a/gstreamer-audio/src/audio_info.rs b/gstreamer-audio/src/audio_info.rs index 119929539..6fbebf98c 100644 --- a/gstreamer-audio/src/audio_info.rs +++ b/gstreamer-audio/src/audio_info.rs @@ -131,13 +131,14 @@ impl<'a> AudioInfoBuilder<'a> { } impl AudioInfo { + #[cfg_attr(feature = "cargo-clippy", allow(new_ret_no_self))] pub fn new<'a>(format: ::AudioFormat, rate: u32, channels: u32) -> AudioInfoBuilder<'a> { assert_initialized_main_thread!(); AudioInfoBuilder { - format: format, - rate: rate, - channels: channels, + format, + rate, + channels, positions: None, flags: None, layout: None, diff --git a/gstreamer-base/src/flow_combiner.rs b/gstreamer-base/src/flow_combiner.rs index 38909e014..e9a7f1493 100644 --- a/gstreamer-base/src/flow_combiner.rs +++ b/gstreamer-base/src/flow_combiner.rs @@ -20,7 +20,7 @@ glib_wrapper! { match fn { ref => |ptr| { - gobject_ffi::g_boxed_copy(ffi::gst_flow_combiner_get_type(), ptr as *mut _) as *mut ffi::GstFlowCombiner + gobject_ffi::g_boxed_copy(ffi::gst_flow_combiner_get_type(), ptr as *mut _) }, unref => |ptr| { gobject_ffi::g_boxed_free(ffi::gst_flow_combiner_get_type(), ptr as *mut _) diff --git a/gstreamer-base/src/lib.rs b/gstreamer-base/src/lib.rs index b6658f721..415b1d588 100644 --- a/gstreamer-base/src/lib.rs +++ b/gstreamer-base/src/lib.rs @@ -29,6 +29,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] #[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))] +#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] mod auto; pub use auto::functions::*; pub use auto::*; diff --git a/gstreamer-base/src/utils.rs b/gstreamer-base/src/utils.rs index f4b3a292d..a7ef46a0d 100644 --- a/gstreamer-base/src/utils.rs +++ b/gstreamer-base/src/utils.rs @@ -12,6 +12,7 @@ use glib_ffi; pub struct MutexGuard<'a>(&'a glib_ffi::GMutex); impl<'a> MutexGuard<'a> { + #[cfg_attr(feature = "cargo-clippy", allow(trivially_copy_pass_by_ref))] pub fn lock(mutex: &'a glib_ffi::GMutex) -> Self { unsafe { glib_ffi::g_mutex_lock(mut_override(mutex)); diff --git a/gstreamer-pbutils/src/discoverer.rs b/gstreamer-pbutils/src/discoverer.rs index 08e466bea..f2a8395ab 100644 --- a/gstreamer-pbutils/src/discoverer.rs +++ b/gstreamer-pbutils/src/discoverer.rs @@ -71,6 +71,7 @@ unsafe extern "C" fn notify_timeout_trampoline

( ) where P: IsA, { + #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f); f(&Discoverer::from_glib_borrow(this).downcast_unchecked()) } diff --git a/gstreamer-pbutils/src/discoverer_stream_info.rs b/gstreamer-pbutils/src/discoverer_stream_info.rs index 38334a582..81a002340 100644 --- a/gstreamer-pbutils/src/discoverer_stream_info.rs +++ b/gstreamer-pbutils/src/discoverer_stream_info.rs @@ -20,8 +20,8 @@ impl Iterator for Iter { fn next(&mut self) -> Option { let current = self.stream_info.take(); - self.stream_info = match ¤t { - &Some(ref c) => { + self.stream_info = match current { + Some(ref c) => { // Decide on the direction if self.direction_forward { c.get_next() @@ -29,7 +29,7 @@ impl Iterator for Iter { c.get_previous() } } - &None => None, + None => None, }; current } diff --git a/gstreamer-pbutils/src/lib.rs b/gstreamer-pbutils/src/lib.rs index 8d6fd9253..9457bf36e 100644 --- a/gstreamer-pbutils/src/lib.rs +++ b/gstreamer-pbutils/src/lib.rs @@ -43,6 +43,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] #[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))] +#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] mod auto; pub use auto::*; diff --git a/gstreamer-player/src/player.rs b/gstreamer-player/src/player.rs index 306eb90b7..99090b2a3 100644 --- a/gstreamer-player/src/player.rs +++ b/gstreamer-player/src/player.rs @@ -105,6 +105,7 @@ unsafe extern "C" fn duration_changed_trampoline( object: u64, f: glib_ffi::gpointer, ) { + #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] let f: &&(Fn(&Player, gst::ClockTime) + Send + 'static) = transmute(f); f(&from_glib_borrow(this), gst::ClockTime(Some(object))) } @@ -114,6 +115,7 @@ unsafe extern "C" fn position_updated_trampoline( object: u64, f: glib_ffi::gpointer, ) { + #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] let f: &&(Fn(&Player, gst::ClockTime) + Send + Sync + 'static) = transmute(f); f(&from_glib_borrow(this), gst::ClockTime(Some(object))) } @@ -123,6 +125,7 @@ unsafe extern "C" fn seek_done_trampoline( object: u64, f: glib_ffi::gpointer, ) { + #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] let f: &&(Fn(&Player, gst::ClockTime) + Send + 'static) = transmute(f); f(&from_glib_borrow(this), gst::ClockTime(Some(object))) } diff --git a/gstreamer-rtsp-server/src/lib.rs b/gstreamer-rtsp-server/src/lib.rs index 3ace9ca16..e38a3cb1f 100644 --- a/gstreamer-rtsp-server/src/lib.rs +++ b/gstreamer-rtsp-server/src/lib.rs @@ -45,6 +45,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] #[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))] +#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] mod auto; pub use auto::*; diff --git a/gstreamer-rtsp-server/src/rtsp_token.rs b/gstreamer-rtsp-server/src/rtsp_token.rs index 5d03752e7..a25ed1db6 100644 --- a/gstreamer-rtsp-server/src/rtsp_token.rs +++ b/gstreamer-rtsp-server/src/rtsp_token.rs @@ -27,10 +27,11 @@ impl GstRcRTSPTokenExt for GstRc { } fn new(values: &[(&str, &ToSendValue)]) -> Self { - let token = RTSPToken::new_empty(); + let mut token = RTSPToken::new_empty(); { - let structure = token.writable_structure().unwrap(); + let token = token.get_mut().unwrap(); + let structure = token.get_mut_structure().unwrap(); for &(f, v) in values { structure.set_value(f, v.to_send_value()); @@ -64,7 +65,7 @@ impl RTSPTokenRef { } } - pub fn writable_structure(&self) -> Option<&mut gst::StructureRef> { + pub fn get_mut_structure(&mut self) -> Option<&mut gst::StructureRef> { unsafe { let structure = ffi::gst_rtsp_token_writable_structure(self.as_mut_ptr()); if structure.is_null() { diff --git a/gstreamer-sdp/src/lib.rs b/gstreamer-sdp/src/lib.rs index 2ed6e76fa..2c67f49f6 100644 --- a/gstreamer-sdp/src/lib.rs +++ b/gstreamer-sdp/src/lib.rs @@ -35,7 +35,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] #[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))] -#[cfg_attr(feature = "cargo-clippy", allow(non_snake_case))] +#[allow(non_snake_case)] mod auto; pub use auto::*; diff --git a/gstreamer-sdp/src/mikey_map_s_r_t_p.rs b/gstreamer-sdp/src/mikey_map_s_r_t_p.rs index 4c69f884c..eef91c70e 100644 --- a/gstreamer-sdp/src/mikey_map_s_r_t_p.rs +++ b/gstreamer-sdp/src/mikey_map_s_r_t_p.rs @@ -14,9 +14,9 @@ pub struct MIKEYMapSRTP(ffi::GstMIKEYMapSRTP); impl MIKEYMapSRTP { pub fn new(policy: u8, ssrc: u32, roc: u32) -> MIKEYMapSRTP { MIKEYMapSRTP(ffi::GstMIKEYMapSRTP { - policy: policy, - ssrc: ssrc, - roc: roc, + policy, + ssrc, + roc, }) } diff --git a/gstreamer-sdp/src/mikey_payload_s_p_param.rs b/gstreamer-sdp/src/mikey_payload_s_p_param.rs index 8d39ba5c5..125e112d3 100644 --- a/gstreamer-sdp/src/mikey_payload_s_p_param.rs +++ b/gstreamer-sdp/src/mikey_payload_s_p_param.rs @@ -22,6 +22,10 @@ impl MIKEYPayloadSPParam { self.0.len } + pub fn is_empty(&self) -> bool { + self.0.len == 0 + } + pub fn val(&self) -> &[u8] { unsafe { slice::from_raw_parts(self.0.val as *const u8, self.0.len as usize) } } diff --git a/gstreamer-sdp/src/sdp_media.rs b/gstreamer-sdp/src/sdp_media.rs index f3f1a13c2..9205de8a1 100644 --- a/gstreamer-sdp/src/sdp_media.rs +++ b/gstreamer-sdp/src/sdp_media.rs @@ -508,7 +508,6 @@ impl SDPMedia { media.to_glib_none_mut().0, ) }; - mem::forget(media); match result { ffi::GST_SDP_OK => Ok(()), _ => Err(()), diff --git a/gstreamer-sdp/src/sdp_message.rs b/gstreamer-sdp/src/sdp_message.rs index 000f0c739..b397fc688 100644 --- a/gstreamer-sdp/src/sdp_message.rs +++ b/gstreamer-sdp/src/sdp_message.rs @@ -709,12 +709,12 @@ impl SDPMessage { unsafe { ffi::gst_sdp_message_zones_len(self.to_glib_none().0) } } - pub fn as_uri(scheme: &str, msg: &SDPMessage) -> Option { + pub fn as_uri(&self, scheme: &str) -> Option { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::gst_sdp_message_as_uri( scheme.to_glib_none().0, - msg.to_glib_none().0, + self.to_glib_none().0, )) } } @@ -753,4 +753,10 @@ impl SDPMessage { } } +impl Default for SDPMessage { + fn default() -> Self { + Self::new() + } +} + unsafe impl Send for SDPMessage {} diff --git a/gstreamer-sdp/src/sdp_time.rs b/gstreamer-sdp/src/sdp_time.rs index e58ecac2f..91cbfd435 100644 --- a/gstreamer-sdp/src/sdp_time.rs +++ b/gstreamer-sdp/src/sdp_time.rs @@ -43,6 +43,7 @@ impl SDPTime { } pub fn repeat(&self) -> Vec<&str> { + #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] unsafe { let arr = (*self.0.repeat).data as *const *const c_char; let len = (*self.0.repeat).len as usize; diff --git a/gstreamer-video/src/functions.rs b/gstreamer-video/src/functions.rs index 880aeec2c..ead7dc9ca 100644 --- a/gstreamer-video/src/functions.rs +++ b/gstreamer-video/src/functions.rs @@ -54,6 +54,7 @@ pub fn convert_sample_async( ) where F: FnOnce(Result) + Send + 'static, { + #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] let callback: &mut Option> = mem::transmute(user_data); let callback = callback.take().unwrap(); diff --git a/gstreamer-video/src/video_event.rs b/gstreamer-video/src/video_event.rs index fc0675f1b..6f261a242 100644 --- a/gstreamer-video/src/video_event.rs +++ b/gstreamer-video/src/video_event.rs @@ -105,35 +105,35 @@ impl<'a> DownstreamForceKeyUnitEventBuilder<'a> { pub fn timestamp(self, timestamp: gst::ClockTime) -> Self { Self { - timestamp: timestamp, + timestamp, ..self } } pub fn stream_time(self, stream_time: gst::ClockTime) -> Self { Self { - stream_time: stream_time, + stream_time, ..self } } pub fn running_time(self, running_time: gst::ClockTime) -> Self { Self { - running_time: running_time, + running_time, ..self } } pub fn all_headers(self, all_headers: bool) -> Self { Self { - all_headers: all_headers, + all_headers, ..self } } pub fn count(self, count: u32) -> Self { Self { - count: count, + count, ..self } } @@ -182,7 +182,7 @@ pub fn parse_downstream_force_key_unit_event( stream_time: from_glib(stream_time), running_time: from_glib(running_time), all_headers: from_glib(all_headers), - count: count, + count, }) } else { None @@ -218,21 +218,21 @@ impl<'a> UpstreamForceKeyUnitEventBuilder<'a> { pub fn running_time(self, running_time: gst::ClockTime) -> Self { Self { - running_time: running_time, + running_time, ..self } } pub fn all_headers(self, all_headers: bool) -> Self { Self { - all_headers: all_headers, + all_headers, ..self } } pub fn count(self, count: u32) -> Self { Self { - count: count, + count, ..self } } @@ -271,7 +271,7 @@ pub fn parse_upstream_force_key_unit_event( Some(UpstreamForceKeyUnitEvent { running_time: from_glib(running_time), all_headers: from_glib(all_headers), - count: count, + count, }) } else { None @@ -311,7 +311,7 @@ impl<'a> StillFrameEventBuilder<'a> { seqnum: None, running_time_offset: None, other_fields: Vec::new(), - in_still: in_still, + in_still, } } diff --git a/gstreamer-video/src/video_format.rs b/gstreamer-video/src/video_format.rs index 7a7a3ce08..44feda1eb 100644 --- a/gstreamer-video/src/video_format.rs +++ b/gstreamer-video/src/video_format.rs @@ -82,8 +82,8 @@ impl ::VideoFormat { } } - pub fn to_string<'a>(&self) -> &'a str { - if *self == ::VideoFormat::Unknown { + pub fn to_string<'a>(self) -> &'a str { + if self == ::VideoFormat::Unknown { return "UNKNOWN"; } @@ -112,6 +112,6 @@ impl str::FromStr for ::VideoFormat { impl fmt::Display for ::VideoFormat { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - f.write_str(self.to_string()) + f.write_str(self.to_string().as_str()) } } diff --git a/gstreamer-video/src/video_frame.rs b/gstreamer-video/src/video_frame.rs index 046ef9877..5adfa28bd 100644 --- a/gstreamer-video/src/video_frame.rs +++ b/gstreamer-video/src/video_frame.rs @@ -179,7 +179,7 @@ impl VideoFrame { &mut frame, info.to_glib_none().0 as *mut _, buffer.to_glib_none().0, - mem::transmute(ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ), + ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ, )); if !res { @@ -205,7 +205,7 @@ impl VideoFrame { info.to_glib_none().0 as *mut _, buffer.to_glib_none().0, id, - mem::transmute(ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ), + ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ, )); if !res { @@ -237,10 +237,8 @@ impl VideoFrame { &mut frame, info.to_glib_none().0 as *mut _, buffer.to_glib_none().0, - mem::transmute( - ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ - | gst_ffi::GST_MAP_WRITE, - ), + ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ + | gst_ffi::GST_MAP_WRITE, )); if !res { @@ -266,10 +264,8 @@ impl VideoFrame { info.to_glib_none().0 as *mut _, buffer.to_glib_none().0, id, - mem::transmute( - ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ - | gst_ffi::GST_MAP_WRITE, - ), + ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ + | gst_ffi::GST_MAP_WRITE, )); if !res { @@ -337,7 +333,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> { &mut frame, info.to_glib_none().0 as *mut _, buffer.as_mut_ptr(), - mem::transmute(ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ), + ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ, )); if !res { @@ -363,7 +359,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> { info.to_glib_none().0 as *mut _, buffer.as_mut_ptr(), id, - mem::transmute(ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ), + ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ, )); if !res { @@ -515,10 +511,8 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> { &mut frame, info.to_glib_none().0 as *mut _, buffer.as_mut_ptr(), - mem::transmute( - ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ - | gst_ffi::GST_MAP_WRITE, - ), + ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ + | gst_ffi::GST_MAP_WRITE, )); if !res { @@ -544,10 +538,8 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> { info.to_glib_none().0 as *mut _, buffer.as_mut_ptr(), id, - mem::transmute( - ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ - | gst_ffi::GST_MAP_WRITE, - ), + ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ + | gst_ffi::GST_MAP_WRITE, )); if !res { @@ -598,8 +590,7 @@ impl<'a> ops::Deref for VideoFrameRef<&'a mut gst::BufferRef> { type Target = VideoFrameRef<&'a gst::BufferRef>; fn deref(&self) -> &Self::Target { - use std::mem; - unsafe { mem::transmute(self) } + unsafe { &*(self as *const VideoFrameRef<&'a mut gst::BufferRef> as *const VideoFrameRef<&'a gst::BufferRef>) } } } diff --git a/gstreamer-video/src/video_info.rs b/gstreamer-video/src/video_info.rs index 0ec43e081..c8067544e 100644 --- a/gstreamer-video/src/video_info.rs +++ b/gstreamer-video/src/video_info.rs @@ -251,7 +251,7 @@ impl<'a> VideoInfoBuilder<'a> { self.height, ); - if info.finfo.is_null() || info.width <= 0 || info.width <= 0 { + if info.finfo.is_null() || info.width <= 0 || info.height <= 0 { return None; } @@ -423,6 +423,7 @@ impl<'a> VideoInfoBuilder<'a> { } impl VideoInfo { + #[cfg_attr(feature = "cargo-clippy", allow(new_ret_no_self))] pub fn new<'a>(format: ::VideoFormat, width: u32, height: u32) -> VideoInfoBuilder<'a> { assert_initialized_main_thread!(); @@ -449,9 +450,9 @@ impl VideoInfo { #[cfg(any(feature = "v1_12", feature = "dox"))] { VideoInfoBuilder { - format: format, - width: width, - height: height, + format, + width, + height, interlace_mode: None, flags: None, size: None, @@ -736,7 +737,7 @@ impl glib::translate::FromGlibPtrFull<*mut ffi::GstVideoInfo> for VideoInfo { #[cfg(any(feature = "v1_12", feature = "dox"))] impl ::VideoFieldOrder { - pub fn to_string(&self) -> String { + pub fn to_string(self) -> String { unsafe { from_glib_full(ffi::gst_video_field_order_to_string(self.to_glib())) } } @@ -765,7 +766,7 @@ impl fmt::Display for ::VideoFieldOrder { } impl ::VideoInterlaceMode { - pub fn to_string(&self) -> String { + pub fn to_string(self) -> String { unsafe { from_glib_full(ffi::gst_video_interlace_mode_to_string(self.to_glib())) } } diff --git a/gstreamer/src/buffer.rs b/gstreamer/src/buffer.rs index cfa6adda1..b67442bd9 100644 --- a/gstreamer/src/buffer.rs +++ b/gstreamer/src/buffer.rs @@ -127,7 +127,7 @@ impl GstRc { if res { Ok(MappedBuffer { buffer: Some(self), - map_info: map_info, + map_info, phantom: PhantomData, }) } else { @@ -147,7 +147,7 @@ impl GstRc { if res { Ok(MappedBuffer { buffer: Some(self), - map_info: map_info, + map_info, phantom: PhantomData, }) } else { @@ -175,7 +175,7 @@ impl BufferRef { if res == glib_ffi::GTRUE { Some(BufferMap { buffer: self, - map_info: map_info, + map_info, phantom: PhantomData, }) } else { @@ -191,7 +191,7 @@ impl BufferRef { if res == glib_ffi::GTRUE { Some(BufferMap { buffer: self, - map_info: map_info, + map_info, phantom: PhantomData, }) } else { diff --git a/gstreamer/src/bufferlist.rs b/gstreamer/src/bufferlist.rs index b7c6ee7c7..2f53e1691 100644 --- a/gstreamer/src/bufferlist.rs +++ b/gstreamer/src/bufferlist.rs @@ -105,6 +105,7 @@ impl ToOwned for BufferListRef { type Owned = GstRc; fn to_owned(&self) -> GstRc { + #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) } } } @@ -145,7 +146,7 @@ impl<'a> Iter<'a> { fn new(list: &'a BufferListRef) -> Iter<'a> { skip_assert_initialized!(); Iter { - list: list, + list, idx: 0, size: list.len() as u32, } diff --git a/gstreamer/src/clock_time.rs b/gstreamer/src/clock_time.rs index 07afdae4f..158393534 100644 --- a/gstreamer/src/clock_time.rs +++ b/gstreamer/src/clock_time.rs @@ -65,6 +65,7 @@ impl ClockTime { } impl fmt::Display for ClockTime { + #[cfg_attr(feature = "cargo-clippy", allow(many_single_char_names))] fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { let precision = f.precision().unwrap_or(9); // TODO: Could also check width and pad the hours as needed diff --git a/gstreamer/src/context.rs b/gstreamer/src/context.rs index 1ab248df3..531d4f29c 100644 --- a/gstreamer/src/context.rs +++ b/gstreamer/src/context.rs @@ -90,6 +90,7 @@ impl ToOwned for ContextRef { type Owned = GstRc; fn to_owned(&self) -> GstRc { + #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) } } } diff --git a/gstreamer/src/element.rs b/gstreamer/src/element.rs index 20cf06584..42b40742f 100644 --- a/gstreamer/src/element.rs +++ b/gstreamer/src/element.rs @@ -100,6 +100,7 @@ pub trait ElementExtManual { fn get_pad_template(&self, name: &str) -> Option; fn get_pad_template_list(&self) -> Vec; + #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] fn message_full( &self, type_: ElementMessageType, @@ -110,7 +111,9 @@ pub trait ElementExtManual { function: &str, line: u32, ); + #[cfg(any(feature = "v1_10", feature = "dox"))] + #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] fn message_full_with_details( &self, type_: ElementMessageType, diff --git a/gstreamer/src/error.rs b/gstreamer/src/error.rs index 51b902bf7..098714674 100644 --- a/gstreamer/src/error.rs +++ b/gstreamer/src/error.rs @@ -75,19 +75,19 @@ impl ErrorMessage { function: &'static str, line: u32, ) -> ErrorMessage { - let domain = T::domain(); - let code = error.code(); + let error_domain = T::domain(); + let error_code = error.code(); let message = message.into(); let debug = debug.into(); ErrorMessage { - error_domain: domain, - error_code: code, + error_domain, + error_code, message: message.map(String::from), debug: debug.map(String::from), - filename: filename, - function: function, - line: line, + filename, + function, + line, } } } diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index 67794732e..d7e0d1aab 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -102,23 +102,23 @@ unsafe impl MiniObject for EventRef { } impl EventType { - pub fn is_upstream(&self) -> bool { + pub fn is_upstream(self) -> bool { (self.to_glib() as u32) & ffi::GST_EVENT_TYPE_UPSTREAM != 0 } - pub fn is_downstream(&self) -> bool { + pub fn is_downstream(self) -> bool { (self.to_glib() as u32) & ffi::GST_EVENT_TYPE_DOWNSTREAM != 0 } - pub fn is_serialized(&self) -> bool { + pub fn is_serialized(self) -> bool { (self.to_glib() as u32) & ffi::GST_EVENT_TYPE_SERIALIZED != 0 } - pub fn is_sticky(&self) -> bool { + pub fn is_sticky(self) -> bool { (self.to_glib() as u32) & ffi::GST_EVENT_TYPE_STICKY != 0 } - pub fn is_sticky_multi(&self) -> bool { + pub fn is_sticky_multi(self) -> bool { (self.to_glib() as u32) & ffi::GST_EVENT_TYPE_STICKY_MULTI != 0 } } @@ -914,6 +914,7 @@ impl<'a> EventBuilder<'a> { macro_rules! event_builder_generic_impl { ($new_fn:expr) => { + #[cfg_attr(feature = "cargo-clippy", allow(needless_update))] pub fn seqnum(self, seqnum: Seqnum) -> Self { Self { builder: self.builder.seqnum(seqnum), @@ -921,6 +922,7 @@ macro_rules! event_builder_generic_impl { } } + #[cfg_attr(feature = "cargo-clippy", allow(needless_update))] pub fn running_time_offset(self, running_time_offset: i64) -> Self { Self { builder: self.builder.running_time_offset(running_time_offset), @@ -928,6 +930,7 @@ macro_rules! event_builder_generic_impl { } } + #[cfg_attr(feature = "cargo-clippy", allow(needless_update))] pub fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self { Self { builder: self.builder.other_fields(other_fields), @@ -986,7 +989,7 @@ impl<'a> FlushStopBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - reset_time: reset_time, + reset_time, } } @@ -1004,7 +1007,7 @@ impl<'a> StreamStartBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - stream_id: stream_id, + stream_id, flags: None, group_id: None, } @@ -1045,7 +1048,7 @@ impl<'a> CapsBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - caps: caps, + caps, } } @@ -1061,7 +1064,7 @@ impl<'a> SegmentBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - segment: segment, + segment, } } @@ -1079,7 +1082,7 @@ impl<'a> StreamCollectionBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - stream_collection: stream_collection, + stream_collection, } } @@ -1118,9 +1121,9 @@ impl<'a> BufferSizeBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - minsize: minsize, - maxsize: maxsize, - async: async, + minsize, + maxsize, + async, } } @@ -1142,8 +1145,8 @@ impl<'a> SinkMessageBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - name: name, - msg: msg, + name, + msg, } } @@ -1164,7 +1167,7 @@ impl<'a> StreamGroupDoneBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - group_id: group_id, + group_id, } } @@ -1197,8 +1200,8 @@ impl<'a> TocBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - toc: toc, - updated: updated, + toc, + updated, } } @@ -1219,8 +1222,8 @@ impl<'a> ProtectionBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - system_id: system_id, - data: data, + system_id, + data, origin: None, } } @@ -1248,7 +1251,7 @@ impl<'a> SegmentDoneBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - position: position, + position, } } @@ -1268,8 +1271,8 @@ impl<'a> GapBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - timestamp: timestamp, - duration: duration, + timestamp, + duration, } } @@ -1291,10 +1294,10 @@ impl<'a> QosBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - type_: type_, - proportion: proportion, - diff: diff, - timestamp: timestamp, + type_, + proportion, + diff, + timestamp, } } @@ -1327,8 +1330,8 @@ impl<'a> SeekBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - rate: rate, - flags: flags, + rate, + flags, start_type, start, stop_type, @@ -1378,7 +1381,7 @@ impl<'a> LatencyBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - latency: latency, + latency, } } @@ -1397,10 +1400,10 @@ impl<'a> StepBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - amount: amount, - rate: rate, - flush: flush, - intermediate: intermediate, + amount, + rate, + flush, + intermediate, } } @@ -1436,7 +1439,7 @@ impl<'a> TocSelectBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - uid: uid, + uid, } } @@ -1454,7 +1457,7 @@ impl<'a> SelectStreamsBuilder<'a> { skip_assert_initialized!(); Self { builder: EventBuilder::new(), - streams: streams, + streams, } } diff --git a/gstreamer/src/format.rs b/gstreamer/src/format.rs index 693372a1a..58a551710 100644 --- a/gstreamer/src/format.rs +++ b/gstreamer/src/format.rs @@ -144,7 +144,7 @@ impl GenericFormattedValue { GenericFormattedValue::Bytes(v) => v.map(|v| v as i64).unwrap_or(-1), GenericFormattedValue::Time(v) => v.map(|v| v as i64).unwrap_or(-1), GenericFormattedValue::Buffers(v) => v.map(|v| v as i64).unwrap_or(-1), - GenericFormattedValue::Percent(v) => v.map(|v| v as i64).unwrap_or(-1), + GenericFormattedValue::Percent(v) => v.map(i64::from).unwrap_or(-1), GenericFormattedValue::Other(_, v) => v, } } diff --git a/gstreamer/src/iterator.rs b/gstreamer/src/iterator.rs index 094a2395e..c1846cfe4 100644 --- a/gstreamer/src/iterator.rs +++ b/gstreamer/src/iterator.rs @@ -319,7 +319,7 @@ where fn new(items: Vec) -> Self { Self { pos: 0, - items: items, + items, } } } diff --git a/gstreamer/src/log.rs b/gstreamer/src/log.rs index 1a45f6253..f1009b589 100644 --- a/gstreamer/src/log.rs +++ b/gstreamer/src/log.rs @@ -9,7 +9,6 @@ use libc::c_char; use std::ffi::CStr; use std::fmt; -use std::mem; use std::ptr; use ffi; @@ -18,9 +17,11 @@ use gobject_ffi; use glib::translate::{from_glib, ToGlib, ToGlibPtr}; use glib::IsA; + #[derive(PartialEq, Eq, Clone, Copy)] pub struct DebugCategory(ptr::NonNull); +#[cfg_attr(feature = "cargo-clippy", allow(trivially_copy_pass_by_ref))] impl DebugCategory { pub fn new<'a, P: Into>>( name: &str, @@ -78,9 +79,9 @@ impl DebugCategory { pub fn get_color(&self) -> ::DebugColorFlags { unsafe { - from_glib(mem::transmute::( + from_glib( ffi::gst_debug_category_get_color(self.0.as_ptr()), - )) + ) } } diff --git a/gstreamer/src/message.rs b/gstreamer/src/message.rs index 1d27597f2..fce2c323e 100644 --- a/gstreamer/src/message.rs +++ b/gstreamer/src/message.rs @@ -1206,6 +1206,7 @@ impl<'a> MessageBuilder<'a> { macro_rules! message_builder_generic_impl { ($new_fn:expr) => { + #[cfg_attr(feature = "cargo-clippy", allow(needless_update))] pub fn src + Cast + Clone>(self, src: Option<&O>) -> Self { Self { builder: self.builder.src(src), @@ -1213,6 +1214,7 @@ macro_rules! message_builder_generic_impl { } } + #[cfg_attr(feature = "cargo-clippy", allow(needless_update))] pub fn seqnum(self, seqnum: Seqnum) -> Self { Self { builder: self.builder.seqnum(seqnum), @@ -1221,6 +1223,7 @@ macro_rules! message_builder_generic_impl { } #[cfg(any(feature = "v1_14", feature = "dox"))] + #[cfg_attr(feature = "cargo-clippy", allow(needless_update))] pub fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self { Self { builder: self.builder.other_fields(other_fields), @@ -1292,8 +1295,8 @@ impl<'a, T: MessageErrorDomain> ErrorBuilder<'a, T> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - error: error, - message: message, + error, + message, debug: None, details: None, } @@ -1357,8 +1360,8 @@ impl<'a, T: MessageErrorDomain> WarningBuilder<'a, T> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - error: error, - message: message, + error, + message, debug: None, details: None, } @@ -1422,8 +1425,8 @@ impl<'a, T: MessageErrorDomain> InfoBuilder<'a, T> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - error: error, - message: message, + error, + message, debug: None, details: None, } @@ -1483,7 +1486,7 @@ impl<'a> TagBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - tags: tags, + tags, } } @@ -1503,7 +1506,7 @@ impl<'a> BufferingBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - percent: percent, + percent, stats: None, } } @@ -1550,9 +1553,9 @@ impl<'a> StateChangedBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - old: old, - new: new, - pending: pending, + old, + new, + pending, } } @@ -1600,12 +1603,12 @@ impl<'a> StepDoneBuilder<'a> { assert_eq!(amount.get_format(), duration.get_format()); Self { builder: MessageBuilder::new(), - amount: amount, - rate: rate, - flush: flush, - intermediate: intermediate, - duration: duration, - eos: eos, + amount, + rate, + flush, + intermediate, + duration, + eos, } } @@ -1631,8 +1634,8 @@ impl<'a> ClockProvideBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - clock: clock, - ready: ready, + clock, + ready, } } @@ -1652,7 +1655,7 @@ impl<'a> ClockLostBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - clock: clock, + clock, } } @@ -1671,7 +1674,7 @@ impl<'a> NewClockBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - clock: clock, + clock, } } @@ -1692,9 +1695,9 @@ impl<'a> StructureChangeBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - type_: type_, - owner: owner, - busy: busy, + type_, + owner, + busy, } } @@ -1717,8 +1720,8 @@ impl<'a> StreamStatusBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - type_: type_, - owner: owner, + type_, + owner, status_object: None, } } @@ -1790,7 +1793,7 @@ impl<'a> SegmentStartBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - position: position, + position, } } @@ -1810,7 +1813,7 @@ impl<'a> SegmentDoneBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - position: position, + position, } } @@ -1872,7 +1875,7 @@ impl<'a> AsyncDoneBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - running_time: running_time, + running_time, } } @@ -1891,7 +1894,7 @@ impl<'a> RequestStateBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - state: state, + state, } } @@ -1920,11 +1923,11 @@ impl<'a> StepStartBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - active: active, - amount: amount, - rate: rate, - flush: flush, - intermediate: intermediate, + active, + amount, + rate, + flush, + intermediate, } } @@ -1960,11 +1963,11 @@ impl<'a> QosBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - live: live, - running_time: running_time, - stream_time: stream_time, - timestamp: timestamp, - duration: duration, + live, + running_time, + stream_time, + timestamp, + duration, values: None, stats: None, } @@ -2022,9 +2025,9 @@ impl<'a> ProgressBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - type_: type_, - code: code, - text: text, + type_, + code, + text, } } @@ -2046,8 +2049,8 @@ impl<'a> TocBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - toc: toc, - updated: updated, + toc, + updated, } } @@ -2067,7 +2070,7 @@ impl<'a> ResetTimeBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - running_time: running_time, + running_time, } } @@ -2115,7 +2118,7 @@ impl<'a> NeedContextBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - context_type: context_type, + context_type, } } @@ -2153,7 +2156,7 @@ impl<'a> DeviceAddedBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - device: device, + device, } } @@ -2172,7 +2175,7 @@ impl<'a> DeviceRemovedBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - device: device, + device, } } @@ -2194,7 +2197,7 @@ impl<'a> PropertyNotifyBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - property_name: property_name, + property_name, value: None, } } @@ -2231,7 +2234,7 @@ impl<'a> StreamCollectionBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - collection: collection, + collection, } } @@ -2255,7 +2258,7 @@ impl<'a> StreamsSelectedBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - collection: collection, + collection, streams: None, } } @@ -2293,7 +2296,7 @@ impl<'a> RedirectBuilder<'a> { skip_assert_initialized!(); Self { builder: MessageBuilder::new(), - location: location, + location, tag_list: None, entry_struct: None, entries: None, diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index 03f0485cb..b1479b01b 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -432,6 +432,7 @@ impl> PadExtManual for O { where F: Fn(&Pad, &Option<::Object>) -> bool + Send + Sync + 'static, { + #[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] unsafe { let func_box: Box< Fn(&Pad, &Option<::Object>) -> bool + Send + Sync + 'static, @@ -449,6 +450,7 @@ impl> PadExtManual for O { where F: Fn(&Pad, &Option<::Object>, ::PadMode, bool) -> bool + Send + Sync + 'static, { + #[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] unsafe { let func_box: Box< Fn(&Pad, &Option<::Object>, ::PadMode, bool) -> bool + Send + Sync + 'static, diff --git a/gstreamer/src/promise.rs b/gstreamer/src/promise.rs index 076d09f56..63322109d 100644 --- a/gstreamer/src/promise.rs +++ b/gstreamer/src/promise.rs @@ -20,7 +20,7 @@ glib_wrapper! { pub struct Promise(Shared); match fn { - ref => |ptr| ffi::gst_mini_object_ref(ptr as *mut _) as *mut ffi::GstPromise, + ref => |ptr| ffi::gst_mini_object_ref(ptr as *mut _), unref => |ptr| ffi::gst_mini_object_unref(ptr as *mut _), get_type => || ffi::gst_promise_get_type(), } diff --git a/gstreamer/src/query.rs b/gstreamer/src/query.rs index 37b03a6e2..55af11a3c 100644 --- a/gstreamer/src/query.rs +++ b/gstreamer/src/query.rs @@ -304,7 +304,7 @@ macro_rules! declare_concrete_query( fn deref(&self) -> &Self::Target { unsafe { - mem::transmute(self) + &*(self as *const $name<&'a mut QueryRef> as *const $name<&'a QueryRef>) } } } diff --git a/gstreamer/src/sample.rs b/gstreamer/src/sample.rs index 07f8f7286..6986794c0 100644 --- a/gstreamer/src/sample.rs +++ b/gstreamer/src/sample.rs @@ -106,6 +106,7 @@ impl ToOwned for SampleRef { type Owned = GstRc; fn to_owned(&self) -> GstRc { + #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) } } } diff --git a/gstreamer/src/segment.rs b/gstreamer/src/segment.rs index 75d5389ea..31ebdbca3 100644 --- a/gstreamer/src/segment.rs +++ b/gstreamer/src/segment.rs @@ -50,7 +50,7 @@ impl Segment { if T::get_default_format() == Format::Undefined || T::get_default_format() == self.get_format() { - Some(unsafe { mem::transmute(self) }) + Some(unsafe { &*(self as *const FormattedSegment as *const FormattedSegment) }) } else { None } @@ -60,7 +60,7 @@ impl Segment { if T::get_default_format() == Format::Undefined || T::get_default_format() == self.get_format() { - Some(unsafe { mem::transmute(self) }) + Some(unsafe { &mut *(self as *mut FormattedSegment as *mut FormattedSegment) }) } else { None } @@ -83,7 +83,7 @@ impl FormattedSegment { } pub fn upcast_ref(&self) -> &Segment { - unsafe { mem::transmute(self) } + unsafe { &*(self as *const FormattedSegment as *const FormattedSegment) } } pub fn reset(&mut self) { @@ -353,6 +353,7 @@ impl FormattedSegment { self.0.rate } + #[cfg_attr(feature = "cargo-clippy", allow(float_cmp))] pub fn set_rate(&mut self, rate: f64) { assert_ne!(rate, 0.0); self.0.rate = rate; @@ -362,6 +363,7 @@ impl FormattedSegment { self.0.applied_rate } + #[cfg_attr(feature = "cargo-clippy", allow(float_cmp))] pub fn set_applied_rate(&mut self, applied_rate: f64) { assert_ne!(applied_rate, 0.0); self.0.applied_rate = applied_rate; @@ -489,7 +491,7 @@ impl Clone for FormattedSegment { impl AsRef for FormattedSegment { fn as_ref(&self) -> &Segment { - unsafe { mem::transmute(self) } + unsafe { &*(self as *const FormattedSegment as *const FormattedSegment) } } } diff --git a/gstreamer/src/stream_collection.rs b/gstreamer/src/stream_collection.rs index c0e1a44db..dd24f4cf5 100644 --- a/gstreamer/src/stream_collection.rs +++ b/gstreamer/src/stream_collection.rs @@ -21,7 +21,7 @@ impl<'a> Iter<'a> { fn new(collection: &'a StreamCollection) -> Iter<'a> { skip_assert_initialized!(); Iter { - collection: collection, + collection, idx: 0, size: collection.len() as u32, } diff --git a/gstreamer/src/structure.rs b/gstreamer/src/structure.rs index 6e39bb183..469e7a8a9 100644 --- a/gstreamer/src/structure.rs +++ b/gstreamer/src/structure.rs @@ -538,9 +538,9 @@ impl<'a> FieldIterator<'a> { let n_fields = structure.n_fields(); FieldIterator { - structure: structure, + structure, idx: 0, - n_fields: n_fields, + n_fields, } } } diff --git a/gstreamer/src/tags.rs b/gstreamer/src/tags.rs index 687c51ce9..6ec7272d1 100644 --- a/gstreamer/src/tags.rs +++ b/gstreamer/src/tags.rs @@ -238,7 +238,7 @@ impl TagListRef { unsafe { ffi::gst_tag_list_n_tags(self.as_ptr()) } } - pub fn nth_tag_name<'a>(&'a self, idx: u32) -> &'a str { + pub fn nth_tag_name(&self, idx: u32) -> &str { unsafe { CStr::from_ptr(ffi::gst_tag_list_nth_tag_name(self.as_ptr(), idx)).to_str().unwrap() } } @@ -279,7 +279,7 @@ impl TagListRef { GenericTagIterator::new(self, tag_name) } - pub fn iter_tag_list<'a>(&'a self) -> TagListIterator<'a> { + pub fn iter_tag_list(&self) -> TagListIterator { TagListIterator::new(self) } @@ -350,7 +350,7 @@ impl<'a, T: Tag<'a>> TagIterator<'a, T> { fn new(taglist: &'a TagListRef) -> TagIterator<'a, T> { skip_assert_initialized!(); TagIterator { - taglist: taglist, + taglist, idx: 0, size: taglist.get_size::(), phantom: PhantomData, @@ -420,7 +420,7 @@ impl<'a> GenericTagIterator<'a> { fn new(taglist: &'a TagListRef, name: &'a str) -> GenericTagIterator<'a> { skip_assert_initialized!(); GenericTagIterator { - taglist: taglist, + taglist, name, idx: 0, size: taglist.get_size_by_name(name), @@ -478,7 +478,7 @@ impl<'a> TagListIterator<'a> { skip_assert_initialized!(); let size = taglist.n_tags(); TagListIterator { - taglist: taglist, + taglist, idx: 0, size: if size > 0 { size as u32 diff --git a/gstreamer/src/toc.rs b/gstreamer/src/toc.rs index f413a89c2..58134aa7f 100644 --- a/gstreamer/src/toc.rs +++ b/gstreamer/src/toc.rs @@ -89,6 +89,7 @@ impl ToOwned for TocRef { type Owned = GstRc; fn to_owned(&self) -> GstRc { + #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) } } } @@ -234,6 +235,7 @@ impl ToOwned for TocEntryRef { type Owned = GstRc; fn to_owned(&self) -> GstRc { + #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) } } } diff --git a/gstreamer/src/typefind.rs b/gstreamer/src/typefind.rs index 3cc82ed11..5dba7c82e 100644 --- a/gstreamer/src/typefind.rs +++ b/gstreamer/src/typefind.rs @@ -116,6 +116,7 @@ unsafe extern "C" fn type_find_trampoline( find: *mut ffi::GstTypeFind, user_data: glib_ffi::gpointer, ) { + #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] let func: &&(Fn(&mut TypeFind) + Send + Sync + 'static) = mem::transmute(user_data); func(&mut *(find as *mut TypeFind)); } @@ -159,7 +160,7 @@ impl> SliceTypeFind { SliceTypeFind { probability: None, caps: None, - data: data, + data, } } @@ -180,7 +181,7 @@ impl> SliceTypeFind { let mut t = SliceTypeFind { probability: None, caps: None, - data: data, + data, }; t.run(); diff --git a/gstreamer/src/utils.rs b/gstreamer/src/utils.rs index f4b3a292d..a7ef46a0d 100644 --- a/gstreamer/src/utils.rs +++ b/gstreamer/src/utils.rs @@ -12,6 +12,7 @@ use glib_ffi; pub struct MutexGuard<'a>(&'a glib_ffi::GMutex); impl<'a> MutexGuard<'a> { + #[cfg_attr(feature = "cargo-clippy", allow(trivially_copy_pass_by_ref))] pub fn lock(mutex: &'a glib_ffi::GMutex) -> Self { unsafe { glib_ffi::g_mutex_lock(mut_override(mutex)); diff --git a/gstreamer/src/value.rs b/gstreamer/src/value.rs index 7c7d3218a..08c08e0eb 100644 --- a/gstreamer/src/value.rs +++ b/gstreamer/src/value.rs @@ -249,9 +249,9 @@ impl IntRange { assert!(step > 0); Self { - min: min, - max: max, - step: step, + min, + max, + step, } } } @@ -269,9 +269,9 @@ impl IntRange { assert!(step > 0); Self { - min: min, - max: max, - step: step, + min, + max, + step, } } } @@ -375,7 +375,7 @@ impl FractionRange { assert!(min <= max); - FractionRange { min: min, max: max } + FractionRange { min, max } } pub fn min(&self) -> Fraction { @@ -564,6 +564,7 @@ impl<'a> FromValue<'a> for Array<'a> { if arr.is_null() { Array(Cow::Borrowed(&[])) } else { + #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] Array(Cow::Borrowed(slice::from_raw_parts( (*arr).data as *const glib::SendValue, (*arr).len as usize, @@ -635,6 +636,7 @@ impl<'a> FromValue<'a> for List<'a> { if arr.is_null() { List(Cow::Borrowed(&[])) } else { + #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] List(Cow::Borrowed(slice::from_raw_parts( (*arr).data as *const glib::SendValue, (*arr).len as usize, diff --git a/tutorials/src/bin/basic-tutorial-4.rs b/tutorials/src/bin/basic-tutorial-4.rs index e2772cd2b..a0fa5301e 100644 --- a/tutorials/src/bin/basic-tutorial-4.rs +++ b/tutorials/src/bin/basic-tutorial-4.rs @@ -38,7 +38,7 @@ fn tutorial_main() { // Listen to the bus let bus = playbin.get_bus().unwrap(); let mut custom_data = CustomData { - playbin: playbin, + playbin, playing: false, terminate: false, seek_enabled: false, diff --git a/tutorials/src/bin/basic-tutorial-8.rs b/tutorials/src/bin/basic-tutorial-8.rs index be655ec81..5478ff300 100644 --- a/tutorials/src/bin/basic-tutorial-8.rs +++ b/tutorials/src/bin/basic-tutorial-8.rs @@ -157,10 +157,10 @@ fn main() { let mut buffer = gst::Buffer::with_size(CHUNK_SIZE).unwrap(); let num_samples = CHUNK_SIZE / 2; /* Each sample is 16 bits */ let pts = gst::SECOND - .mul_div_floor(data.num_samples, SAMPLE_RATE as u64) + .mul_div_floor(data.num_samples, u64::from(SAMPLE_RATE)) .expect("u64 overflow"); let duration = gst::SECOND - .mul_div_floor(num_samples as u64, SAMPLE_RATE as u64) + .mul_div_floor(num_samples as u64, u64::from(SAMPLE_RATE)) .expect("u64 overflow"); {