From be12c0a5f72643eeb9a56339e3ebdc047aed169a Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Thu, 21 Mar 2024 16:57:47 +0000 Subject: [PATCH] Fix clippy warnings after upgrade to Rust 1.77 Part-of: --- .../src/runtime/executor/reactor.rs | 2 +- .../src/runtime/executor/scheduler.rs | 2 +- .../threadshare/src/runtime/executor/task.rs | 2 +- net/aws/src/s3hlssink/imp.rs | 15 +++----------- net/reqwest/src/reqwesthttpsrc/imp.rs | 2 +- net/rtp/src/basedepay/imp.rs | 5 +---- net/rtsp/src/rtspsrc/imp.rs | 4 +--- net/webrtc/src/webrtcsink/imp.rs | 1 + net/webrtchttp/src/whepsrc/imp.rs | 5 +---- utils/fallbackswitch/src/fallbacksrc/imp.rs | 6 +++--- .../fallbackswitch/src/fallbackswitch/imp.rs | 2 +- utils/togglerecord/src/togglerecord/imp.rs | 2 +- .../uriplaylistbin/src/uriplaylistbin/imp.rs | 4 +--- video/closedcaption/src/mcc_parse/imp.rs | 20 ++++++++----------- video/closedcaption/src/scc_parse/imp.rs | 20 ++++++++----------- 15 files changed, 33 insertions(+), 59 deletions(-) diff --git a/generic/threadshare/src/runtime/executor/reactor.rs b/generic/threadshare/src/runtime/executor/reactor.rs index e1f2221c..e317a03c 100644 --- a/generic/threadshare/src/runtime/executor/reactor.rs +++ b/generic/threadshare/src/runtime/executor/reactor.rs @@ -57,7 +57,7 @@ const READ: usize = 0; const WRITE: usize = 1; thread_local! { - static CURRENT_REACTOR: RefCell> = RefCell::new(None); + static CURRENT_REACTOR: RefCell> = const { RefCell::new(None) }; } #[derive(Debug)] diff --git a/generic/threadshare/src/runtime/executor/scheduler.rs b/generic/threadshare/src/runtime/executor/scheduler.rs index 583ffa2f..2a8cca7e 100644 --- a/generic/threadshare/src/runtime/executor/scheduler.rs +++ b/generic/threadshare/src/runtime/executor/scheduler.rs @@ -27,7 +27,7 @@ use super::{CallOnDrop, JoinHandle, Reactor}; use crate::runtime::RUNTIME_CAT; thread_local! { - static CURRENT_SCHEDULER: RefCell> = RefCell::new(None); + static CURRENT_SCHEDULER: RefCell> = const { RefCell::new(None) }; } #[derive(Debug)] diff --git a/generic/threadshare/src/runtime/executor/task.rs b/generic/threadshare/src/runtime/executor/task.rs index 4b883ced..aa444455 100644 --- a/generic/threadshare/src/runtime/executor/task.rs +++ b/generic/threadshare/src/runtime/executor/task.rs @@ -24,7 +24,7 @@ use super::CallOnDrop; use crate::runtime::RUNTIME_CAT; thread_local! { - static CURRENT_TASK_ID: Cell> = Cell::new(None); + static CURRENT_TASK_ID: Cell> = const { Cell::new(None) }; } #[derive(Clone, Copy, Eq, PartialEq, Hash, Debug)] diff --git a/net/aws/src/s3hlssink/imp.rs b/net/aws/src/s3hlssink/imp.rs index 6b62d5f7..79fe4db9 100644 --- a/net/aws/src/s3hlssink/imp.rs +++ b/net/aws/src/s3hlssink/imp.rs @@ -642,10 +642,7 @@ impl ObjectImpl for S3HlsSink { self.hlssink.connect("get-playlist-stream", false, { let self_weak = self.downgrade(); move |args| -> Option { - let Some(self_) = self_weak.upgrade() else { - return None; - }; - + let self_ = self_weak.upgrade()?; let s3client = self_.s3client_from_settings(); let settings = self_.settings.lock().unwrap(); let mut state = self_.state.lock().unwrap(); @@ -676,10 +673,7 @@ impl ObjectImpl for S3HlsSink { self.hlssink.connect("get-fragment-stream", false, { let self_weak = self.downgrade(); move |args| -> Option { - let Some(self_) = self_weak.upgrade() else { - return None; - }; - + let self_ = self_weak.upgrade()?; let s3client = self_.s3client_from_settings(); let settings = self_.settings.lock().unwrap(); let mut state = self_.state.lock().unwrap(); @@ -710,10 +704,7 @@ impl ObjectImpl for S3HlsSink { self.hlssink.connect("delete-fragment", false, { let self_weak = self.downgrade(); move |args| -> Option { - let Some(self_) = self_weak.upgrade() else { - return None; - }; - + let self_ = self_weak.upgrade()?; let s3_client = self_.s3client_from_settings(); let settings = self_.settings.lock().unwrap(); diff --git a/net/reqwest/src/reqwesthttpsrc/imp.rs b/net/reqwest/src/reqwesthttpsrc/imp.rs index be9c9605..bdeb6077 100644 --- a/net/reqwest/src/reqwesthttpsrc/imp.rs +++ b/net/reqwest/src/reqwesthttpsrc/imp.rs @@ -1045,7 +1045,7 @@ impl BaseSrcImpl for ReqwestHttpSrc { .ok_or_else(|| { gst::error_msg!(gst::CoreError::StateChange, ["Can't start without an URI"]) }) - .map(|uri| uri.clone())?; + .cloned()?; gst::debug!(CAT, imp: self, "Starting for URI {}", uri); diff --git a/net/rtp/src/basedepay/imp.rs b/net/rtp/src/basedepay/imp.rs index 1c4d7674..d1d6cbb8 100644 --- a/net/rtp/src/basedepay/imp.rs +++ b/net/rtp/src/basedepay/imp.rs @@ -1040,10 +1040,7 @@ impl RtpBaseDepay2 { // If npt-start is set, all the other values are also valid. if let Some(npt_start) = state.npt_start { - let Some((mut npt_start_pts, npt_start_ext_rtptime)) = state.npt_start_times else { - return None; - }; - + let (mut npt_start_pts, npt_start_ext_rtptime) = state.npt_start_times?; let clock_rate = state.clock_rate.unwrap(); let mut start = segment.start().unwrap(); diff --git a/net/rtsp/src/rtspsrc/imp.rs b/net/rtsp/src/rtspsrc/imp.rs index 35cb460e..5ac905e3 100644 --- a/net/rtsp/src/rtspsrc/imp.rs +++ b/net/rtsp/src/rtspsrc/imp.rs @@ -1140,9 +1140,7 @@ impl RtspManager { if !rtpbin2 { let on_bye = |args: &[glib::Value]| { let m = args[0].get::().unwrap(); - let Some(obj) = m.parent() else { - return None; - }; + let obj = m.parent()?; let bin = obj.downcast::().unwrap(); bin.send_event(gst::event::Eos::new()); None diff --git a/net/webrtc/src/webrtcsink/imp.rs b/net/webrtc/src/webrtcsink/imp.rs index 07e62ead..cac00ede 100644 --- a/net/webrtc/src/webrtcsink/imp.rs +++ b/net/webrtc/src/webrtcsink/imp.rs @@ -483,6 +483,7 @@ struct PipelineWrapper(gst::Pipeline); // Structure to generate GstNavigation event from a WebRTCDataChannel // This is simply used to hold references to the inner items. +#[allow(dead_code)] #[derive(Debug)] struct NavigationEventHandler((glib::SignalHandlerId, WebRTCDataChannel)); diff --git a/net/webrtchttp/src/whepsrc/imp.rs b/net/webrtchttp/src/whepsrc/imp.rs index 76d6e992..886c688b 100644 --- a/net/webrtchttp/src/whepsrc/imp.rs +++ b/net/webrtchttp/src/whepsrc/imp.rs @@ -548,10 +548,7 @@ impl WhepSrc { let self_weak = self.downgrade(); self.webrtcbin.connect("on-negotiation-needed", false, { move |_| { - let Some(self_) = self_weak.upgrade() else { - return None; - }; - + let self_ = self_weak.upgrade()?; let settings = self_.settings.lock().unwrap(); let endpoint = diff --git a/utils/fallbackswitch/src/fallbacksrc/imp.rs b/utils/fallbackswitch/src/fallbacksrc/imp.rs index c7b52944..0d906a31 100644 --- a/utils/fallbackswitch/src/fallbacksrc/imp.rs +++ b/utils/fallbackswitch/src/fallbacksrc/imp.rs @@ -534,7 +534,7 @@ impl ObjectImpl for FallbackSrc { // Called whenever a value of a property is read. It can be called // at any time from any thread. - #[allow(clippy::block_in_conditions)] + #[allow(clippy::blocks_in_conditions)] fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value { match pspec.name() { "enable-audio" => { @@ -3237,7 +3237,7 @@ impl FallbackSrc { }); } - #[allow(clippy::block_in_conditions)] + #[allow(clippy::blocks_in_conditions)] fn schedule_source_restart_timeout( &self, state: &mut State, @@ -3400,7 +3400,7 @@ impl FallbackSrc { source.restart_timeout = Some(timeout); } - #[allow(clippy::block_in_conditions)] + #[allow(clippy::blocks_in_conditions)] fn have_fallback_activated(&self, state: &State) -> bool { let mut have_audio = false; let mut have_video = false; diff --git a/utils/fallbackswitch/src/fallbackswitch/imp.rs b/utils/fallbackswitch/src/fallbackswitch/imp.rs index 5b5e4330..5167b545 100644 --- a/utils/fallbackswitch/src/fallbackswitch/imp.rs +++ b/utils/fallbackswitch/src/fallbackswitch/imp.rs @@ -771,7 +771,7 @@ impl FallbackSwitch { is_active ); - #[allow(clippy::block_in_conditions)] + #[allow(clippy::blocks_in_conditions)] let output_clockid = if is_active { pad_state.schedule_clock( self, diff --git a/utils/togglerecord/src/togglerecord/imp.rs b/utils/togglerecord/src/togglerecord/imp.rs index 250bcb39..0be6b335 100644 --- a/utils/togglerecord/src/togglerecord/imp.rs +++ b/utils/togglerecord/src/togglerecord/imp.rs @@ -693,7 +693,7 @@ impl ToggleRecord { } } - #[allow(clippy::block_in_conditions)] + #[allow(clippy::blocks_in_conditions)] fn handle_secondary_stream( &self, pad: &gst::Pad, diff --git a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs index eb42e744..ed29a2d8 100644 --- a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs +++ b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs @@ -505,9 +505,7 @@ impl UriPlaylistBin { let bin_weak = self.obj().downgrade(); uridecodebin.connect("about-to-finish", false, move |_args| { - let Some(bin) = bin_weak.upgrade() else { - return None; - }; + let bin = bin_weak.upgrade()?; let self_ = bin.imp(); gst::debug!(CAT, obj: bin, "current URI about to finish"); diff --git a/video/closedcaption/src/mcc_parse/imp.rs b/video/closedcaption/src/mcc_parse/imp.rs index 0c8611cc..6307d98b 100644 --- a/video/closedcaption/src/mcc_parse/imp.rs +++ b/video/closedcaption/src/mcc_parse/imp.rs @@ -174,19 +174,15 @@ impl State { match parse_timecode(framerate, drop_frame, tc) { Ok(timecode) => Ok(timecode), Err(timecode) => { - let last_timecode = - self.last_timecode - .as_ref() - .map(Clone::clone) - .ok_or_else(|| { - gst::element_imp_error!( - imp, - gst::StreamError::Decode, - ["Invalid first timecode {:?}", timecode] - ); + let last_timecode = self.last_timecode.clone().ok_or_else(|| { + gst::element_imp_error!( + imp, + gst::StreamError::Decode, + ["Invalid first timecode {:?}", timecode] + ); - gst::FlowError::Error - })?; + gst::FlowError::Error + })?; gst::warning!( CAT, diff --git a/video/closedcaption/src/scc_parse/imp.rs b/video/closedcaption/src/scc_parse/imp.rs index 1289bf3e..d6c19f2b 100644 --- a/video/closedcaption/src/scc_parse/imp.rs +++ b/video/closedcaption/src/scc_parse/imp.rs @@ -149,19 +149,15 @@ impl State { match parse_timecode(framerate, tc) { Ok(timecode) => Ok(timecode), Err(err) => { - let last_timecode = - self.last_timecode - .as_ref() - .map(Clone::clone) - .ok_or_else(|| { - gst::element_imp_error!( - imp, - gst::StreamError::Decode, - ["Invalid first timecode {:?}", err] - ); + let last_timecode = self.last_timecode.clone().ok_or_else(|| { + gst::element_imp_error!( + imp, + gst::StreamError::Decode, + ["Invalid first timecode {:?}", err] + ); - gst::FlowError::Error - })?; + gst::FlowError::Error + })?; gst::warning!( CAT,