Fix clippy warnings after upgrade to Rust 1.77

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1512>
This commit is contained in:
Philippe Normand 2024-03-21 16:57:47 +00:00
parent 317f46ad97
commit be12c0a5f7
15 changed files with 33 additions and 59 deletions

View file

@ -57,7 +57,7 @@ const READ: usize = 0;
const WRITE: usize = 1; const WRITE: usize = 1;
thread_local! { thread_local! {
static CURRENT_REACTOR: RefCell<Option<Reactor>> = RefCell::new(None); static CURRENT_REACTOR: RefCell<Option<Reactor>> = const { RefCell::new(None) };
} }
#[derive(Debug)] #[derive(Debug)]

View file

@ -27,7 +27,7 @@ use super::{CallOnDrop, JoinHandle, Reactor};
use crate::runtime::RUNTIME_CAT; use crate::runtime::RUNTIME_CAT;
thread_local! { thread_local! {
static CURRENT_SCHEDULER: RefCell<Option<HandleWeak>> = RefCell::new(None); static CURRENT_SCHEDULER: RefCell<Option<HandleWeak>> = const { RefCell::new(None) };
} }
#[derive(Debug)] #[derive(Debug)]

View file

@ -24,7 +24,7 @@ use super::CallOnDrop;
use crate::runtime::RUNTIME_CAT; use crate::runtime::RUNTIME_CAT;
thread_local! { thread_local! {
static CURRENT_TASK_ID: Cell<Option<TaskId>> = Cell::new(None); static CURRENT_TASK_ID: Cell<Option<TaskId>> = const { Cell::new(None) };
} }
#[derive(Clone, Copy, Eq, PartialEq, Hash, Debug)] #[derive(Clone, Copy, Eq, PartialEq, Hash, Debug)]

View file

@ -642,10 +642,7 @@ impl ObjectImpl for S3HlsSink {
self.hlssink.connect("get-playlist-stream", false, { self.hlssink.connect("get-playlist-stream", false, {
let self_weak = self.downgrade(); let self_weak = self.downgrade();
move |args| -> Option<glib::Value> { move |args| -> Option<glib::Value> {
let Some(self_) = self_weak.upgrade() else { let self_ = self_weak.upgrade()?;
return None;
};
let s3client = self_.s3client_from_settings(); let s3client = self_.s3client_from_settings();
let settings = self_.settings.lock().unwrap(); let settings = self_.settings.lock().unwrap();
let mut state = self_.state.lock().unwrap(); let mut state = self_.state.lock().unwrap();
@ -676,10 +673,7 @@ impl ObjectImpl for S3HlsSink {
self.hlssink.connect("get-fragment-stream", false, { self.hlssink.connect("get-fragment-stream", false, {
let self_weak = self.downgrade(); let self_weak = self.downgrade();
move |args| -> Option<glib::Value> { move |args| -> Option<glib::Value> {
let Some(self_) = self_weak.upgrade() else { let self_ = self_weak.upgrade()?;
return None;
};
let s3client = self_.s3client_from_settings(); let s3client = self_.s3client_from_settings();
let settings = self_.settings.lock().unwrap(); let settings = self_.settings.lock().unwrap();
let mut state = self_.state.lock().unwrap(); let mut state = self_.state.lock().unwrap();
@ -710,10 +704,7 @@ impl ObjectImpl for S3HlsSink {
self.hlssink.connect("delete-fragment", false, { self.hlssink.connect("delete-fragment", false, {
let self_weak = self.downgrade(); let self_weak = self.downgrade();
move |args| -> Option<glib::Value> { move |args| -> Option<glib::Value> {
let Some(self_) = self_weak.upgrade() else { let self_ = self_weak.upgrade()?;
return None;
};
let s3_client = self_.s3client_from_settings(); let s3_client = self_.s3client_from_settings();
let settings = self_.settings.lock().unwrap(); let settings = self_.settings.lock().unwrap();

View file

@ -1045,7 +1045,7 @@ impl BaseSrcImpl for ReqwestHttpSrc {
.ok_or_else(|| { .ok_or_else(|| {
gst::error_msg!(gst::CoreError::StateChange, ["Can't start without an URI"]) 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); gst::debug!(CAT, imp: self, "Starting for URI {}", uri);

View file

@ -1040,10 +1040,7 @@ impl RtpBaseDepay2 {
// If npt-start is set, all the other values are also valid. // If npt-start is set, all the other values are also valid.
if let Some(npt_start) = state.npt_start { if let Some(npt_start) = state.npt_start {
let Some((mut npt_start_pts, npt_start_ext_rtptime)) = state.npt_start_times else { let (mut npt_start_pts, npt_start_ext_rtptime) = state.npt_start_times?;
return None;
};
let clock_rate = state.clock_rate.unwrap(); let clock_rate = state.clock_rate.unwrap();
let mut start = segment.start().unwrap(); let mut start = segment.start().unwrap();

View file

@ -1140,9 +1140,7 @@ impl RtspManager {
if !rtpbin2 { if !rtpbin2 {
let on_bye = |args: &[glib::Value]| { let on_bye = |args: &[glib::Value]| {
let m = args[0].get::<gst::Element>().unwrap(); let m = args[0].get::<gst::Element>().unwrap();
let Some(obj) = m.parent() else { let obj = m.parent()?;
return None;
};
let bin = obj.downcast::<gst::Bin>().unwrap(); let bin = obj.downcast::<gst::Bin>().unwrap();
bin.send_event(gst::event::Eos::new()); bin.send_event(gst::event::Eos::new());
None None

View file

@ -483,6 +483,7 @@ struct PipelineWrapper(gst::Pipeline);
// Structure to generate GstNavigation event from a WebRTCDataChannel // Structure to generate GstNavigation event from a WebRTCDataChannel
// This is simply used to hold references to the inner items. // This is simply used to hold references to the inner items.
#[allow(dead_code)]
#[derive(Debug)] #[derive(Debug)]
struct NavigationEventHandler((glib::SignalHandlerId, WebRTCDataChannel)); struct NavigationEventHandler((glib::SignalHandlerId, WebRTCDataChannel));

View file

@ -548,10 +548,7 @@ impl WhepSrc {
let self_weak = self.downgrade(); let self_weak = self.downgrade();
self.webrtcbin.connect("on-negotiation-needed", false, { self.webrtcbin.connect("on-negotiation-needed", false, {
move |_| { move |_| {
let Some(self_) = self_weak.upgrade() else { let self_ = self_weak.upgrade()?;
return None;
};
let settings = self_.settings.lock().unwrap(); let settings = self_.settings.lock().unwrap();
let endpoint = let endpoint =

View file

@ -534,7 +534,7 @@ impl ObjectImpl for FallbackSrc {
// Called whenever a value of a property is read. It can be called // Called whenever a value of a property is read. It can be called
// at any time from any thread. // 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 { fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
match pspec.name() { match pspec.name() {
"enable-audio" => { "enable-audio" => {
@ -3237,7 +3237,7 @@ impl FallbackSrc {
}); });
} }
#[allow(clippy::block_in_conditions)] #[allow(clippy::blocks_in_conditions)]
fn schedule_source_restart_timeout( fn schedule_source_restart_timeout(
&self, &self,
state: &mut State, state: &mut State,
@ -3400,7 +3400,7 @@ impl FallbackSrc {
source.restart_timeout = Some(timeout); source.restart_timeout = Some(timeout);
} }
#[allow(clippy::block_in_conditions)] #[allow(clippy::blocks_in_conditions)]
fn have_fallback_activated(&self, state: &State) -> bool { fn have_fallback_activated(&self, state: &State) -> bool {
let mut have_audio = false; let mut have_audio = false;
let mut have_video = false; let mut have_video = false;

View file

@ -771,7 +771,7 @@ impl FallbackSwitch {
is_active is_active
); );
#[allow(clippy::block_in_conditions)] #[allow(clippy::blocks_in_conditions)]
let output_clockid = if is_active { let output_clockid = if is_active {
pad_state.schedule_clock( pad_state.schedule_clock(
self, self,

View file

@ -693,7 +693,7 @@ impl ToggleRecord {
} }
} }
#[allow(clippy::block_in_conditions)] #[allow(clippy::blocks_in_conditions)]
fn handle_secondary_stream<T: HandleData>( fn handle_secondary_stream<T: HandleData>(
&self, &self,
pad: &gst::Pad, pad: &gst::Pad,

View file

@ -505,9 +505,7 @@ impl UriPlaylistBin {
let bin_weak = self.obj().downgrade(); let bin_weak = self.obj().downgrade();
uridecodebin.connect("about-to-finish", false, move |_args| { uridecodebin.connect("about-to-finish", false, move |_args| {
let Some(bin) = bin_weak.upgrade() else { let bin = bin_weak.upgrade()?;
return None;
};
let self_ = bin.imp(); let self_ = bin.imp();
gst::debug!(CAT, obj: bin, "current URI about to finish"); gst::debug!(CAT, obj: bin, "current URI about to finish");

View file

@ -174,19 +174,15 @@ impl State {
match parse_timecode(framerate, drop_frame, tc) { match parse_timecode(framerate, drop_frame, tc) {
Ok(timecode) => Ok(timecode), Ok(timecode) => Ok(timecode),
Err(timecode) => { Err(timecode) => {
let last_timecode = let last_timecode = self.last_timecode.clone().ok_or_else(|| {
self.last_timecode gst::element_imp_error!(
.as_ref() imp,
.map(Clone::clone) gst::StreamError::Decode,
.ok_or_else(|| { ["Invalid first timecode {:?}", timecode]
gst::element_imp_error!( );
imp,
gst::StreamError::Decode,
["Invalid first timecode {:?}", timecode]
);
gst::FlowError::Error gst::FlowError::Error
})?; })?;
gst::warning!( gst::warning!(
CAT, CAT,

View file

@ -149,19 +149,15 @@ impl State {
match parse_timecode(framerate, tc) { match parse_timecode(framerate, tc) {
Ok(timecode) => Ok(timecode), Ok(timecode) => Ok(timecode),
Err(err) => { Err(err) => {
let last_timecode = let last_timecode = self.last_timecode.clone().ok_or_else(|| {
self.last_timecode gst::element_imp_error!(
.as_ref() imp,
.map(Clone::clone) gst::StreamError::Decode,
.ok_or_else(|| { ["Invalid first timecode {:?}", err]
gst::element_imp_error!( );
imp,
gst::StreamError::Decode,
["Invalid first timecode {:?}", err]
);
gst::FlowError::Error gst::FlowError::Error
})?; })?;
gst::warning!( gst::warning!(
CAT, CAT,