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' extends: '.tarball_setup'
image: "rust:slim" image: "rust:slim"
stage: 'extras' stage: 'extras'
allow_failure: true
script: script:
- rustup component add clippy-preview - rustup component add clippy-preview
- cargo clippy --version - cargo clippy --version
@ -141,5 +140,9 @@ clippy:
FEATURES=v1_16 FEATURES=v1_16
fi 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 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, gst_gl::GLPlatform::GLX,
) )
} }
#[allow(unreachable_patterns)]
handler => panic!("Unsupported platform: {:?}.", handler), 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::too_many_arguments)]
#[allow(clippy::match_same_arms)] #[allow(clippy::match_same_arms)]
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
#[allow(clippy::let_and_return)]
mod auto; mod auto;
pub use auto::*; pub use auto::*;

View file

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

View file

@ -130,7 +130,7 @@ impl TryFrom<DateTimeVariants> for Date {
impl<'de> Deserialize<'de> for Date { impl<'de> Deserialize<'de> for Date {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
DateTimeVariants::deserialize(deserializer) 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,6 +1410,8 @@ impl<'a> SeekBuilder<'a> {
} }
event_builder_generic_impl!(|s: &Self| { event_builder_generic_impl!(|s: &Self| {
#[allow(clippy::let_and_return)]
{
let ev = gst_sys::gst_event_new_seek( let ev = gst_sys::gst_event_new_seek(
s.rate, s.rate,
s.start.get_format().to_glib(), s.start.get_format().to_glib(),
@ -1423,11 +1425,15 @@ impl<'a> SeekBuilder<'a> {
#[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg(any(feature = "v1_16", feature = "dox"))]
{ {
if let Some(trickmode_interval) = s.trickmode_interval { if let Some(trickmode_interval) = s.trickmode_interval {
gst_sys::gst_event_set_seek_trickmode_interval(ev, trickmode_interval.to_glib()); gst_sys::gst_event_set_seek_trickmode_interval(
ev,
trickmode_interval.to_glib(),
);
} }
} }
ev ev
}
}); });
} }

View file

@ -115,7 +115,12 @@ pub fn calculate_linear_regression(
unsafe { unsafe {
assert_eq!(mem::size_of::<u64>() * 2, mem::size_of::<(u64, u64)>()); assert_eq!(mem::size_of::<u64>() * 2, mem::size_of::<(u64, u64)>());
assert_eq!(mem::align_of::<u64>(), mem::align_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_num = mem::MaybeUninit::uninit();
let mut m_denom = mem::MaybeUninit::uninit(); let mut m_denom = mem::MaybeUninit::uninit();