Fix or ignore various clippy warnings

And ignore some common warnings we don't care about in general, while
also making clippy errors fail the build.
This commit is contained in:
Sebastian Dröge 2019-09-07 13:08:09 +03:00
parent 105412b5a0
commit ea367bac14
7 changed files with 38 additions and 20 deletions

View file

@ -124,7 +124,6 @@ clippy:
extends: '.tarball_setup'
image: "rust:slim"
stage: 'extras'
allow_failure: true
script:
- rustup component add clippy-preview
- cargo clippy --version
@ -141,5 +140,9 @@ clippy:
FEATURES=v1_16
fi
cargo clippy --color=always --manifest-path $crate/Cargo.toml --features=$FEATURES
cargo clippy --color=always --manifest-path $crate/Cargo.toml --features=$FEATURES -- -A clippy::redundant_pattern_matching -A clippy::single_match -A clippy::cast_lossless
done
# And also run over all the examples/tutorials
- |
cargo clippy --color=always --manifest-path examples/Cargo.toml --bins --examples --all-features -- -A clippy::redundant_pattern_matching -A clippy::single_match -A clippy::cast_lossless
cargo clippy --color=always --manifest-path tutorials/Cargo.toml --bins --examples --all-features -- -A clippy::redundant_pattern_matching -A clippy::single_match -A clippy::cast_lossless

View file

@ -408,6 +408,7 @@ impl App {
gst_gl::GLPlatform::GLX,
)
}
#[allow(unreachable_patterns)]
handler => panic!("Unsupported platform: {:?}.", handler),
};

View file

@ -46,6 +46,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue
#[allow(clippy::too_many_arguments)]
#[allow(clippy::match_same_arms)]
#[allow(clippy::type_complexity)]
#[allow(clippy::let_and_return)]
mod auto;
pub use auto::*;

View file

@ -145,6 +145,7 @@ impl VideoFormatInfo {
(-((-(i64::from(height))) >> self.h_sub()[component as usize])) as u32
}
#[allow(clippy::too_many_arguments)]
pub fn unpack(
&self,
flags: ::VideoPackFlags,
@ -220,6 +221,7 @@ impl VideoFormatInfo {
}
}
#[allow(clippy::too_many_arguments)]
pub fn pack(
&self,
flags: ::VideoPackFlags,

View file

@ -130,7 +130,7 @@ impl TryFrom<DateTimeVariants> for Date {
impl<'de> Deserialize<'de> for Date {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
DateTimeVariants::deserialize(deserializer)
.and_then(|dt_variant| dt_variant.try_into().map_err(|err| D::Error::custom(err)))
.and_then(|dt_variant| dt_variant.try_into().map_err(D::Error::custom))
}
}

View file

@ -1410,24 +1410,30 @@ impl<'a> SeekBuilder<'a> {
}
event_builder_generic_impl!(|s: &Self| {
let ev = gst_sys::gst_event_new_seek(
s.rate,
s.start.get_format().to_glib(),
s.flags.to_glib(),
s.start_type.to_glib(),
s.start.get_value(),
s.stop_type.to_glib(),
s.stop.get_value(),
);
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[allow(clippy::let_and_return)]
{
if let Some(trickmode_interval) = s.trickmode_interval {
gst_sys::gst_event_set_seek_trickmode_interval(ev, trickmode_interval.to_glib());
}
}
let ev = gst_sys::gst_event_new_seek(
s.rate,
s.start.get_format().to_glib(),
s.flags.to_glib(),
s.start_type.to_glib(),
s.start.get_value(),
s.stop_type.to_glib(),
s.stop.get_value(),
);
ev
#[cfg(any(feature = "v1_16", feature = "dox"))]
{
if let Some(trickmode_interval) = s.trickmode_interval {
gst_sys::gst_event_set_seek_trickmode_interval(
ev,
trickmode_interval.to_glib(),
);
}
}
ev
}
});
}

View file

@ -115,7 +115,12 @@ pub fn calculate_linear_regression(
unsafe {
assert_eq!(mem::size_of::<u64>() * 2, mem::size_of::<(u64, u64)>());
assert_eq!(mem::align_of::<u64>(), mem::align_of::<(u64, u64)>());
assert!(temp.as_ref().map(|temp| temp.len()).unwrap_or(xy.len()) >= xy.len());
assert!(
temp.as_ref()
.map(|temp| temp.len())
.unwrap_or_else(|| xy.len())
>= xy.len()
);
let mut m_num = mem::MaybeUninit::uninit();
let mut m_denom = mem::MaybeUninit::uninit();