Skip to content

Commit

Permalink
Fix clippy lints (#299)
Browse files Browse the repository at this point in the history
* Fix clippy lints

- Replace MetricsError::NonExhaustive with #[non_exhaustive]
- Remove some redundant let bindings
- Disconnect rayon::scope from result handling

* Update proc-macro2 to fix compilation on nightly
  • Loading branch information
FreezyLemon committed Mar 29, 2024
1 parent dd256e7 commit f8eb1f0
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions av_metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub mod video;
///
/// This enum may be added to in the future and should not be assumed to be exhaustive.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum MetricsError {
/// Indicates an input file could not be read for some reason.
#[error("Could not read input file: {reason}")]
Expand Down Expand Up @@ -56,8 +57,4 @@ pub enum MetricsError {
#[doc(hidden)]
reason: String,
},
/// Placeholder
#[doc(hidden)]
#[error("Unreachable")]
NonExhaustive,
}
6 changes: 4 additions & 2 deletions av_metrics/src/video/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ trait VideoMetric: Send + Sync {
let (send, recv) = crossbeam::channel::bounded(num_threads);
let vid_info = decoder1.get_video_details();

match crossbeam::scope(|s| {
let scope_result = crossbeam::scope(|s| {
let send_result = s.spawn(move |_| {
let mut decoded = 0;
while frame_limit.map(|limit| limit > decoded).unwrap_or(true) {
Expand Down Expand Up @@ -224,7 +224,9 @@ trait VideoMetric: Send + Sync {
.unwrap_or_else(|_| Err("Failed joining the sender thread".to_owned())),
process_error,
)
}) {
});

match scope_result {
Ok((send_error, process_error)) => {
if let Err(error) = send_error {
return Err(MetricsError::SendError { reason: error }.into());
Expand Down
1 change: 0 additions & 1 deletion av_metrics/src/video/psnr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ impl VideoMetric for Psnr {

frame1.can_compare(frame2)?;

let bit_depth = bit_depth;
let mut y = Default::default();
let mut u = Default::default();
let mut v = Default::default();
Expand Down
1 change: 0 additions & 1 deletion av_metrics/src/video/psnr_hvs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ impl VideoMetric for PsnrHvs {

frame1.can_compare(frame2)?;

let bit_depth = bit_depth;
let mut y = 0.0;
let mut u = 0.0;
let mut v = 0.0;
Expand Down
1 change: 0 additions & 1 deletion av_metrics/src/video/ssim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ impl VideoMetric for MsSsim {

frame1.can_compare(frame2)?;

let bit_depth = bit_depth;
let mut y = 0.0;
let mut u = 0.0;
let mut v = 0.0;
Expand Down

0 comments on commit f8eb1f0

Please sign in to comment.