From 86a31b413906a4353208f861b277624f295a2c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 28 Feb 2019 10:54:32 +0200 Subject: [PATCH] Silence/fix various clippy warnings --- examples/src/bin/decodebin.rs | 2 +- examples/src/bin/discoverer.rs | 5 +- examples/src/bin/encodebin.rs | 2 +- examples/src/bin/glupload.rs | 17 +++--- examples/src/bin/pango-cairo.rs | 11 ++-- examples/src/bin/rtpfecclient.rs | 7 ++- examples/src/bin/rtpfecserver.rs | 7 ++- gstreamer-app/src/app_sink.rs | 1 + gstreamer-app/src/app_src.rs | 1 + gstreamer-base/src/flow_combiner.rs | 8 +-- gstreamer-base/src/lib.rs | 2 +- gstreamer-pbutils/src/encoding_profile.rs | 6 +++ gstreamer-video/src/video_meta.rs | 1 + gstreamer-video/src/video_time_code.rs | 2 + gstreamer/src/caps_features_serde.rs | 2 +- gstreamer/src/caps_serde.rs | 2 +- gstreamer/src/date_time_serde.rs | 3 +- gstreamer/src/error.rs | 12 ++--- gstreamer/src/iterator.rs | 1 + gstreamer/src/log.rs | 53 +++++++++---------- gstreamer/src/subclass/bin.rs | 6 +-- tutorials/src/bin/basic-tutorial-5.rs | 64 +++++++++++++---------- tutorials/src/bin/basic-tutorial-8.rs | 1 + 23 files changed, 117 insertions(+), 99 deletions(-) diff --git a/examples/src/bin/decodebin.rs b/examples/src/bin/decodebin.rs index 2b528ad40..0e8dd357e 100644 --- a/examples/src/bin/decodebin.rs +++ b/examples/src/bin/decodebin.rs @@ -33,7 +33,7 @@ extern crate gstreamer as gst; use gst::prelude::*; -#[macro_use] +#[cfg_attr(feature = "v1_10", macro_use)] extern crate glib; use std::env; diff --git a/examples/src/bin/discoverer.rs b/examples/src/bin/discoverer.rs index ab4cef969..332292cf9 100644 --- a/examples/src/bin/discoverer.rs +++ b/examples/src/bin/discoverer.rs @@ -49,9 +49,8 @@ fn print_tags(info: &DiscovererInfo) { fn print_stream_info(stream: &DiscovererStreamInfo) { println!("Stream: "); - match stream.get_stream_id() { - Some(id) => println!(" Stream id: {}", id), - None => {} + if let Some(id) = stream.get_stream_id() { + println!(" Stream id: {}", id); } let caps_str = match stream.get_caps() { Some(caps) => caps.to_string(), diff --git a/examples/src/bin/encodebin.rs b/examples/src/bin/encodebin.rs index 43af237f9..daedfd705 100644 --- a/examples/src/bin/encodebin.rs +++ b/examples/src/bin/encodebin.rs @@ -19,7 +19,7 @@ use gst::prelude::*; extern crate gstreamer_pbutils as gst_pbutils; use gst_pbutils::prelude::*; -#[macro_use] +#[cfg_attr(feature = "v1_10", macro_use)] extern crate glib; use std::env; diff --git a/examples/src/bin/glupload.rs b/examples/src/bin/glupload.rs index 0bc5debe6..685fc316b 100644 --- a/examples/src/bin/glupload.rs +++ b/examples/src/bin/glupload.rs @@ -51,10 +51,6 @@ struct ErrorMessage { cause: glib::Error, } -#[derive(Debug, Fail)] -#[fail(display = "Glutin error")] -struct GlutinError(); - #[rustfmt::skip] static VERTICES: [f32; 20] = [ 1.0, 1.0, 0.0, 1.0, 0.0, @@ -73,7 +69,7 @@ static IDENTITY: [f32; 16] = [ 0.0, 0.0, 0.0, 1.0, ]; -const VS_SRC: &'static [u8] = b" +const VS_SRC: &[u8] = b" uniform mat4 u_transformation; attribute vec4 a_position; attribute vec2 a_texcoord; @@ -85,7 +81,7 @@ void main() { } \0"; -const FS_SRC: &'static [u8] = b" +const FS_SRC: &[u8] = b" #ifdef GL_ES precision mediump float; #endif @@ -97,6 +93,9 @@ void main() { } \0"; +#[allow(clippy::unreadable_literal)] +#[allow(clippy::unused_unit)] +#[allow(clippy::too_many_arguments)] mod gl { pub use self::Gles2 as Gl; include!(concat!(env!("OUT_DIR"), "/test_gl_bindings.rs")); @@ -315,7 +314,7 @@ fn load(gl_context: &glutin::Context) -> Gl { }; Gl { - gl: gl, + gl, program, attr_position, attr_texture, @@ -374,6 +373,7 @@ impl App { unsafe { gst_gl::GLContext::new_wrapped(&gl_display, egl_context, platform, api) } .unwrap(); + #[allow(clippy::single_match)] bus.set_sync_handler(move |_, msg| { use gst::MessageView; @@ -417,7 +417,7 @@ impl App { appsink, bus, events_loop: Arc::new(events_loop), - combined_context: combined_context, + combined_context, }) } @@ -556,6 +556,7 @@ fn main_loop(mut app: App) -> Result<(), Error> { let events_loop = Arc::get_mut(&mut app.events_loop).unwrap(); let combined_context = app.combined_context.clone(); while running { + #[allow(clippy::single_match)] events_loop.poll_events(|event| match event { glutin::Event::WindowEvent { event, .. } => match event { glutin::WindowEvent::CloseRequested => running = false, diff --git a/examples/src/bin/pango-cairo.rs b/examples/src/bin/pango-cairo.rs index 11e5a99e8..0bc5bd7f1 100644 --- a/examples/src/bin/pango-cairo.rs +++ b/examples/src/bin/pango-cairo.rs @@ -170,7 +170,10 @@ fn create_pipeline() -> Result { // Calling multiple transformation methods after each other will apply the // new transformation on top. If you repeat the cr.rotate(angle) line below // this a second time, everything in the canvas will rotate twice as fast. - cr.translate(info.width() as f64 / 2.0, info.height() as f64 / 2.0); + cr.translate( + f64::from(info.width()) / 2.0, + f64::from(info.height()) / 2.0, + ); cr.rotate(angle); // This loop will render 10 times the string "GStreamer" in a circle @@ -181,7 +184,7 @@ fn create_pipeline() -> Result { // previous transformations. cr.save(); - let angle = (360. * i as f64) / 10.0; + let angle = (360. * f64::from(i)) / 10.0; let red = (1.0 + f64::cos((angle - 60.0) * PI / 180.0)) / 2.0; cr.set_source_rgb(red, 0.0, 1.0 - red); cr.rotate(angle * PI / 180.0); @@ -194,8 +197,8 @@ fn create_pipeline() -> Result { // Using width and height of the text, we can properly possition it within // our canvas. cr.move_to( - -(width as f64 / pango::SCALE as f64) / 2.0, - -(info.height() as f64) / 2.0, + -(f64::from(width) / f64::from(pango::SCALE)) / 2.0, + -(f64::from(info.height())) / 2.0, ); // After telling the layout object where to draw itself, we actually tell // it to draw itself into our cairo context. diff --git a/examples/src/bin/rtpfecclient.rs b/examples/src/bin/rtpfecclient.rs index 6211202d1..e989e89d4 100644 --- a/examples/src/bin/rtpfecclient.rs +++ b/examples/src/bin/rtpfecclient.rs @@ -270,8 +270,8 @@ fn example_main() -> Result<(), Error> { } .into()); } - MessageView::StateChanged(s) => match msg.get_src() { - Some(element) => { + MessageView::StateChanged(s) => { + if let Some(element) = msg.get_src() { if element == pipeline && s.get_current() == gst::State::Playing { eprintln!("PLAYING"); gst::debug_bin_to_dot_file( @@ -281,8 +281,7 @@ fn example_main() -> Result<(), Error> { ); } } - None => (), - }, + } _ => (), } } diff --git a/examples/src/bin/rtpfecserver.rs b/examples/src/bin/rtpfecserver.rs index 2ae6a9e20..1cc78de64 100644 --- a/examples/src/bin/rtpfecserver.rs +++ b/examples/src/bin/rtpfecserver.rs @@ -201,8 +201,8 @@ fn example_main() -> Result<(), Error> { } .into()); } - MessageView::StateChanged(s) => match msg.get_src() { - Some(element) => { + MessageView::StateChanged(s) => { + if let Some(element) = msg.get_src() { if element == pipeline && s.get_current() == gst::State::Playing { eprintln!("PLAYING"); gst::debug_bin_to_dot_file( @@ -212,8 +212,7 @@ fn example_main() -> Result<(), Error> { ); } } - None => (), - }, + } _ => (), } } diff --git a/gstreamer-app/src/app_sink.rs b/gstreamer-app/src/app_sink.rs index deb4c3361..c90393d7d 100644 --- a/gstreamer-app/src/app_sink.rs +++ b/gstreamer-app/src/app_sink.rs @@ -36,6 +36,7 @@ unsafe impl Send for AppSinkCallbacks {} unsafe impl Sync for AppSinkCallbacks {} impl AppSinkCallbacks { + #[allow(clippy::new_ret_no_self)] pub fn new() -> AppSinkCallbacksBuilder { skip_assert_initialized!(); AppSinkCallbacksBuilder { diff --git a/gstreamer-app/src/app_src.rs b/gstreamer-app/src/app_src.rs index 1574cc058..3abc11e24 100644 --- a/gstreamer-app/src/app_src.rs +++ b/gstreamer-app/src/app_src.rs @@ -27,6 +27,7 @@ unsafe impl Send for AppSrcCallbacks {} unsafe impl Sync for AppSrcCallbacks {} impl AppSrcCallbacks { + #[allow(clippy::new_ret_no_self)] pub fn new() -> AppSrcCallbacksBuilder { skip_assert_initialized!(); diff --git a/gstreamer-base/src/flow_combiner.rs b/gstreamer-base/src/flow_combiner.rs index 1f021c6bb..2b63686d5 100644 --- a/gstreamer-base/src/flow_combiner.rs +++ b/gstreamer-base/src/flow_combiner.rs @@ -17,12 +17,8 @@ glib_wrapper! { pub struct FlowCombiner(Shared); match fn { - ref => |ptr| { - 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 _) - }, + ref => |ptr| 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 _), get_type => || ffi::gst_flow_combiner_get_type(), } } diff --git a/gstreamer-base/src/lib.rs b/gstreamer-base/src/lib.rs index dd0677f2e..4c6c6176a 100644 --- a/gstreamer-base/src/lib.rs +++ b/gstreamer-base/src/lib.rs @@ -8,7 +8,7 @@ extern crate glib_sys as glib_ffi; extern crate gobject_sys as gobject_ffi; -#[macro_use] +#[cfg_attr(feature = "subclassing", macro_use)] extern crate gstreamer as gst; extern crate gstreamer_base_sys as ffi; extern crate gstreamer_sys as gst_ffi; diff --git a/gstreamer-pbutils/src/encoding_profile.rs b/gstreamer-pbutils/src/encoding_profile.rs index 5b7ff28cb..f587deadd 100644 --- a/gstreamer-pbutils/src/encoding_profile.rs +++ b/gstreamer-pbutils/src/encoding_profile.rs @@ -298,6 +298,12 @@ pub trait EncodingProfileBuilder<'a>: Sized { macro_rules! declare_encoding_profile_builder_common( ($name:ident) => { + impl<'a> Default for $name<'a> { + fn default() -> Self { + Self::new() + } + } + impl<'a> EncodingProfileBuilder<'a> for $name<'a> { fn name(mut self, name: &'a str) -> $name<'a> { self.base.name = Some(name); diff --git a/gstreamer-video/src/video_meta.rs b/gstreamer-video/src/video_meta.rs index 03a925696..8682b4c59 100644 --- a/gstreamer-video/src/video_meta.rs +++ b/gstreamer-video/src/video_meta.rs @@ -42,6 +42,7 @@ impl VideoMeta { } } + #[allow(clippy::too_many_arguments)] pub fn add_full<'a>( buffer: &'a mut gst::BufferRef, flags: ::VideoFrameFlags, diff --git a/gstreamer-video/src/video_time_code.rs b/gstreamer-video/src/video_time_code.rs index 36850d3ed..6b8e242ac 100644 --- a/gstreamer-video/src/video_time_code.rs +++ b/gstreamer-video/src/video_time_code.rs @@ -39,6 +39,7 @@ impl VideoTimeCode { } } + #[allow(clippy::too_many_arguments)] pub fn new( fps: gst::Fraction, latest_daily_jam: Option<&glib::DateTime>, @@ -153,6 +154,7 @@ impl VideoTimeCode { } impl ValidVideoTimeCode { + #[allow(clippy::too_many_arguments)] pub fn new( fps: gst::Fraction, latest_daily_jam: Option<&glib::DateTime>, diff --git a/gstreamer/src/caps_features_serde.rs b/gstreamer/src/caps_features_serde.rs index 83d32d096..b60d2f292 100644 --- a/gstreamer/src/caps_features_serde.rs +++ b/gstreamer/src/caps_features_serde.rs @@ -111,7 +111,7 @@ impl<'de> Visitor<'de> for CapsFeaturesVariantKindsVisitor { CAPS_FEATURES_VARIANT_ANY_ID => Ok(CapsFeaturesVariantKinds::Any), CAPS_FEATURES_VARIANT_SOME_ID => Ok(CapsFeaturesVariantKinds::Some), _ => Err(de::Error::invalid_value( - de::Unexpected::Unsigned(value as u64), + de::Unexpected::Unsigned(u64::from(value)), &self, )), } diff --git a/gstreamer/src/caps_serde.rs b/gstreamer/src/caps_serde.rs index 14c491873..d9b16b48f 100644 --- a/gstreamer/src/caps_serde.rs +++ b/gstreamer/src/caps_serde.rs @@ -174,7 +174,7 @@ impl<'de> Visitor<'de> for CapsVariantKindsVisitor { CAPS_VARIANT_EMPTY_ID => Ok(CapsVariantKinds::Empty), CAPS_VARIANT_SOME_ID => Ok(CapsVariantKinds::Some), _ => Err(de::Error::invalid_value( - de::Unexpected::Unsigned(value as u64), + de::Unexpected::Unsigned(u64::from(value)), &self, )), } diff --git a/gstreamer/src/date_time_serde.rs b/gstreamer/src/date_time_serde.rs index 5806529b8..24a68a3b7 100644 --- a/gstreamer/src/date_time_serde.rs +++ b/gstreamer/src/date_time_serde.rs @@ -29,7 +29,7 @@ impl<'a> Serialize for DateTime { self.get_day(), self.get_hour(), self.get_minute(), - (self.get_second() as f64) + (self.get_microsecond() as f64) / 1_000_000f64, + f64::from(self.get_second()) + f64::from(self.get_microsecond()) / 1_000_000f64, self.get_time_zone_offset(), ) } else if self.has_time() { @@ -58,6 +58,7 @@ impl<'a> Serialize for DateTime { } } +#[allow(clippy::many_single_char_names)] impl From for DateTime { fn from(dt_variant: DateTimeVariants) -> Self { match dt_variant { diff --git a/gstreamer/src/error.rs b/gstreamer/src/error.rs index cc0cde037..d384e31e8 100644 --- a/gstreamer/src/error.rs +++ b/gstreamer/src/error.rs @@ -113,12 +113,12 @@ impl Error for ErrorMessage { macro_rules! gst_loggable_error( // Plain strings ($cat:expr, $msg:expr) => { - $crate::LoggableError::new(&$cat, glib_bool_error!($msg)) + $crate::LoggableError::new($cat.clone(), glib_bool_error!($msg)) }; // Format strings ($cat:expr, $($msg:tt)*) => { { - $crate::LoggableError::new(&$cat, glib_bool_error!($($msg)*)) + $crate::LoggableError::new($cat.clone(), glib_bool_error!($($msg)*)) }}; ); @@ -127,13 +127,13 @@ macro_rules! gst_result_from_gboolean( // Plain strings ($ffi_bool:expr, $cat:expr, $msg:expr) => { glib_result_from_gboolean!($ffi_bool, $msg) - .map_err(|bool_err| $crate::LoggableError::new(&$cat, bool_err)) + .map_err(|bool_err| $crate::LoggableError::new($cat.clone(), bool_err)) }; // Format strings ($ffi_bool:expr, $cat:expr, $($msg:tt)*) => { { glib_result_from_gboolean!($ffi_bool, $($msg)*) - .map_err(|bool_err| $crate::LoggableError::new(&$cat, bool_err)) + .map_err(|bool_err| $crate::LoggableError::new($cat.clone(), bool_err)) }}; ); @@ -144,9 +144,9 @@ pub struct LoggableError { } impl LoggableError { - pub fn new(category: &::DebugCategory, bool_error: glib::BoolError) -> LoggableError { + pub fn new(category: ::DebugCategory, bool_error: glib::BoolError) -> LoggableError { LoggableError { - category: *category, + category, bool_error, } } diff --git a/gstreamer/src/iterator.rs b/gstreamer/src/iterator.rs index 280293476..59e04e257 100644 --- a/gstreamer/src/iterator.rs +++ b/gstreamer/src/iterator.rs @@ -59,6 +59,7 @@ impl Iterator where for<'a> T: FromValueOptional<'a> + 'static, { + #[allow(clippy::should_implement_trait)] pub fn next(&mut self) -> Result, IteratorError> { unsafe { let mut value = Value::uninitialized(); diff --git a/gstreamer/src/log.rs b/gstreamer/src/log.rs index 7d5a02a83..e07a47d67 100644 --- a/gstreamer/src/log.rs +++ b/gstreamer/src/log.rs @@ -20,7 +20,6 @@ use glib::IsA; #[derive(PartialEq, Eq, Clone, Copy)] pub struct DebugCategory(ptr::NonNull); -#[allow(clippy::trivially_copy_pass_by_ref)] impl DebugCategory { pub fn new<'a, P: Into>>( name: &str, @@ -64,23 +63,23 @@ impl DebugCategory { } } - pub fn get_threshold(&self) -> ::DebugLevel { + pub fn get_threshold(self) -> ::DebugLevel { from_glib(unsafe { ffi::gst_debug_category_get_threshold(self.0.as_ptr()) }) } - pub fn set_threshold(&self, threshold: ::DebugLevel) { + pub fn set_threshold(self, threshold: ::DebugLevel) { unsafe { ffi::gst_debug_category_set_threshold(self.0.as_ptr(), threshold.to_glib()) } } - pub fn reset_threshold(&self) { + pub fn reset_threshold(self) { unsafe { ffi::gst_debug_category_reset_threshold(self.0.as_ptr()) } } - pub fn get_color(&self) -> ::DebugColorFlags { + pub fn get_color(self) -> ::DebugColorFlags { unsafe { from_glib(ffi::gst_debug_category_get_color(self.0.as_ptr())) } } - pub fn get_name(&self) -> &str { + pub fn get_name<'a>(self) -> &'a str { unsafe { CStr::from_ptr(ffi::gst_debug_category_get_name(self.0.as_ptr())) .to_str() @@ -88,9 +87,9 @@ impl DebugCategory { } } - pub fn get_description(&self) -> Option<&str> { + pub fn get_description<'a>(self) -> Option<&'a str> { unsafe { - let ptr = ffi::gst_debug_category_get_name(self.0.as_ptr()); + let ptr = ffi::gst_debug_category_get_description(self.0.as_ptr()); if ptr.is_null() { None @@ -102,7 +101,7 @@ impl DebugCategory { #[inline] pub fn log>( - &self, + self, obj: Option<&O>, level: ::DebugLevel, file: &str, @@ -199,91 +198,91 @@ declare_debug_category_from_name!(CAT_CONTEXT, "GST_CONTEXT"); #[macro_export] macro_rules! gst_error( ($cat:expr, obj: $obj:expr, $($args:tt)*) => { { - gst_log_with_level!($cat, level: $crate::DebugLevel::Error, obj: $obj, $($args)*) + gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Error, obj: $obj, $($args)*) }}; ($cat:expr, $($args:tt)*) => { { - gst_log_with_level!($cat, level: $crate::DebugLevel::Error, $($args)*) + gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Error, $($args)*) }}; ); #[macro_export] macro_rules! gst_warning( ($cat:expr, obj: $obj:expr, $($args:tt)*) => { { - gst_log_with_level!($cat, level: $crate::DebugLevel::Warning, obj: $obj, $($args)*) + gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Warning, obj: $obj, $($args)*) }}; ($cat:expr, $($args:tt)*) => { { - gst_log_with_level!($cat, level: $crate::DebugLevel::Warning, $($args)*) + gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Warning, $($args)*) }}; ); #[macro_export] macro_rules! gst_fixme( ($cat:expr, obj: $obj:expr, $($args:tt)*) => { { - gst_log_with_level!($cat, level: $crate::DebugLevel::Fixme, obj: $obj, $($args)*) + gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Fixme, obj: $obj, $($args)*) }}; ($cat:expr, $($args:tt)*) => { { - gst_log_with_level!($cat, level: $crate::DebugLevel::Fixme, $($args)*) + gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Fixme, $($args)*) }}; ); #[macro_export] macro_rules! gst_info( ($cat:expr, obj: $obj:expr, $($args:tt)*) => { { - gst_log_with_level!($cat, level: $crate::DebugLevel::Info, obj: $obj, $($args)*) + gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Info, obj: $obj, $($args)*) }}; ($cat:expr, $($args:tt)*) => { { - gst_log_with_level!($cat, level: $crate::DebugLevel::Info, $($args)*) + gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Info, $($args)*) }}; ); #[macro_export] macro_rules! gst_debug( ($cat:expr, obj: $obj:expr, $($args:tt)*) => { { - gst_log_with_level!($cat, level: $crate::DebugLevel::Debug, obj: $obj, $($args)*) + gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Debug, obj: $obj, $($args)*) }}; ($cat:expr, $($args:tt)*) => { { - gst_log_with_level!($cat, level: $crate::DebugLevel::Debug, $($args)*) + gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Debug, $($args)*) }}; ); #[macro_export] macro_rules! gst_log( ($cat:expr, obj: $obj:expr, $($args:tt)*) => { { - gst_log_with_level!($cat, level: $crate::DebugLevel::Log, obj: $obj, $($args)*) + gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Log, obj: $obj, $($args)*) }}; ($cat:expr, $($args:tt)*) => { { - gst_log_with_level!($cat, level: $crate::DebugLevel::Log, $($args)*) + gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Log, $($args)*) }}; ); #[macro_export] macro_rules! gst_trace( ($cat:expr, obj: $obj:expr, $($args:tt)*) => { { - gst_log_with_level!($cat, level: $crate::DebugLevel::Trace, obj: $obj, $($args)*) + gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Trace, obj: $obj, $($args)*) }}; ($cat:expr, $($args:tt)*) => { { - gst_log_with_level!($cat, level: $crate::DebugLevel::Trace, $($args)*) + gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Trace, $($args)*) }}; ); #[macro_export] macro_rules! gst_memdump( ($cat:expr, obj: $obj:expr, $($args:tt)*) => { { - gst_log_with_level!($cat, level: $crate::DebugLevel::Memdump, obj: $obj, $($args)*) + gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Memdump, obj: $obj, $($args)*) }}; ($cat:expr, $($args:tt)*) => { { - gst_log_with_level!($cat, level: $crate::DebugLevel::Memdump, $($args)*) + gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Memdump, $($args)*) }}; ); #[macro_export] macro_rules! gst_log_with_level( ($cat:expr, level: $level:expr, obj: $obj:expr, $($args:tt)*) => { { - $crate::DebugCategory::log(&$cat, Some($obj), $level, file!(), + $crate::DebugCategory::log($cat.clone(), Some($obj), $level, file!(), module_path!(), line!(), format_args!($($args)*)) }}; ($cat:expr, level: $level:expr, $($args:tt)*) => { { - $crate::DebugCategory::log(&$cat, None as Option<&$crate::Object>, $level, file!(), + $crate::DebugCategory::log($cat.clone(), None as Option<&$crate::Object>, $level, file!(), module_path!(), line!(), format_args!($($args)*)) }}; ); diff --git a/gstreamer/src/subclass/bin.rs b/gstreamer/src/subclass/bin.rs index 478c7e197..9d9086498 100644 --- a/gstreamer/src/subclass/bin.rs +++ b/gstreamer/src/subclass/bin.rs @@ -80,9 +80,9 @@ impl BinImplExt for T { unsafe { let data = self.get_type_data(); let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBinClass; - (*parent_class) - .handle_message - .map(move |f| f(bin.to_glib_none().0, message.into_ptr())); + if let Some(ref f) = (*parent_class).handle_message { + f(bin.to_glib_none().0, message.into_ptr()); + } } } } diff --git a/tutorials/src/bin/basic-tutorial-5.rs b/tutorials/src/bin/basic-tutorial-5.rs index 9669c3f95..a34bb96ae 100644 --- a/tutorials/src/bin/basic-tutorial-5.rs +++ b/tutorials/src/bin/basic-tutorial-5.rs @@ -158,10 +158,13 @@ mod tutorial5 { let slider_update_signal_id = slider.connect_value_changed(move |slider| { let pipeline = &pipeline; let value = slider.get_value() as u64; - if let Err(_) = pipeline.seek_simple( - gst::SeekFlags::FLUSH | gst::SeekFlags::KEY_UNIT, - value * gst::SECOND, - ) { + if pipeline + .seek_simple( + gst::SeekFlags::FLUSH | gst::SeekFlags::KEY_UNIT, + value * gst::SECOND, + ) + .is_err() + { eprintln!("Seeking to {} failed", value); } }); @@ -257,30 +260,30 @@ mod tutorial5 { streams_list.set_editable(false); let pipeline_weak = playbin.downgrade(); let streams_list_weak = glib::SendWeakRef::from(streams_list.downgrade()); - playbin - .get_bus() - .unwrap() - .connect_message(move |_, msg| match msg.view() { - gst::MessageView::Application(application) => { - let pipeline = match pipeline_weak.upgrade() { - Some(pipeline) => pipeline, - None => return, - }; + let bus = playbin.get_bus().unwrap(); - let streams_list = match streams_list_weak.upgrade() { - Some(streams_list) => streams_list, - None => return, - }; + #[allow(clippy::single_match)] + bus.connect_message(move |_, msg| match msg.view() { + gst::MessageView::Application(application) => { + let pipeline = match pipeline_weak.upgrade() { + Some(pipeline) => pipeline, + None => return, + }; - if application.get_structure().map(|s| s.get_name()) == Some("tags-changed") { - let textbuf = streams_list - .get_buffer() - .expect("Couldn't get buffer from text_view"); - analyze_streams(&pipeline, &textbuf); - } + let streams_list = match streams_list_weak.upgrade() { + Some(streams_list) => streams_list, + None => return, + }; + + if application.get_structure().map(|s| s.get_name()) == Some("tags-changed") { + let textbuf = streams_list + .get_buffer() + .expect("Couldn't get buffer from text_view"); + analyze_streams(&pipeline, &textbuf); } - _ => (), - }); + } + _ => (), + }); let vbox = Box::new(Orientation::Horizontal, 0); vbox.pack_start(&video_window, true, true, 0); @@ -309,10 +312,15 @@ mod tutorial5 { pub fn run() { // Make sure the right features were activated - if !cfg!(feature = "tutorial5-x11") && !cfg!(feature = "tutorial5-quartz") { - eprintln!("No Gdk backend selected, compile with --features tutorial5[-x11][-quartz]."); + #[allow(clippy::eq_op)] + { + if !cfg!(feature = "tutorial5-x11") && !cfg!(feature = "tutorial5-quartz") { + eprintln!( + "No Gdk backend selected, compile with --features tutorial5[-x11][-quartz]." + ); - return; + return; + } } // Initialize GTK diff --git a/tutorials/src/bin/basic-tutorial-8.rs b/tutorials/src/bin/basic-tutorial-8.rs index 05166e21d..dfb782fd7 100644 --- a/tutorials/src/bin/basic-tutorial-8.rs +++ b/tutorials/src/bin/basic-tutorial-8.rs @@ -243,6 +243,7 @@ fn main() { let main_loop = glib::MainLoop::new(None, false); let main_loop_clone = main_loop.clone(); let bus = pipeline.get_bus().unwrap(); + #[allow(clippy::single_match)] bus.connect_message(move |_, msg| match msg.view() { gst::MessageView::Error(err) => { let main_loop = &main_loop_clone;