Skip to content

Commit

Permalink
Fix nightly clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bilelmoussaoui authored and sdroege committed Apr 8, 2024
1 parent b2d5b35 commit 691e46a
Show file tree
Hide file tree
Showing 34 changed files with 38 additions and 50 deletions.
2 changes: 1 addition & 1 deletion cairo/src/font/font_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#[cfg(feature = "v1_16")]
use std::ffi::CString;
use std::hash;
#[cfg(not(feature = "use_glib"))]
use std::ptr;
use std::{cmp::PartialEq, hash};

#[cfg(feature = "use_glib")]
use glib::translate::*;
Expand Down
1 change: 0 additions & 1 deletion cairo/src/image_surface.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use std::{
convert::TryFrom,
ops::{Deref, DerefMut},
rc::Rc,
slice,
Expand Down
2 changes: 1 addition & 1 deletion cairo/src/patterns.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use std::{convert::TryFrom, ops::Deref, ptr};
use std::{ops::Deref, ptr};

use libc::{c_double, c_int, c_uint};

Expand Down
1 change: 0 additions & 1 deletion cairo/src/pdf.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use std::{
convert::TryFrom,
ffi::{CStr, CString},
io, mem,
ops::Deref,
Expand Down
1 change: 0 additions & 1 deletion cairo/src/ps.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use std::{
convert::TryFrom,
ffi::{CStr, CString},
io, mem,
ops::Deref,
Expand Down
2 changes: 1 addition & 1 deletion cairo/src/quartz_surface.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use std::{convert::TryFrom, fmt, ops::Deref};
use std::{fmt, ops::Deref};

use ffi::CGContextRef;
#[cfg(feature = "use_glib")]
Expand Down
2 changes: 1 addition & 1 deletion cairo/src/recording_surface.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use std::{convert::TryFrom, ops::Deref};
use std::ops::Deref;

#[cfg(feature = "use_glib")]
use glib::translate::*;
Expand Down
1 change: 0 additions & 1 deletion cairo/src/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#[cfg(not(windows))]
use std::os::unix::prelude::*;
use std::{
convert::TryFrom,
ffi::{CStr, CString},
io, mem,
ops::Deref,
Expand Down
6 changes: 6 additions & 0 deletions cairo/src/user_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ impl<T> UserDataKey<T> {
}
}

impl<T> Default for UserDataKey<T> {
fn default() -> Self {
Self::new()
}
}

// In a safe API for user data we can’t make `get_user_data`
// transfer full ownership of the value to the caller (e.g. by returning `Box<T>`)
// because `self` still has a pointer to that value
Expand Down
2 changes: 1 addition & 1 deletion cairo/src/win32_surface.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use std::{convert::TryFrom, ops::Deref};
use std::ops::Deref;

pub use ffi::windows;
#[cfg(feature = "use_glib")]
Expand Down
2 changes: 1 addition & 1 deletion cairo/src/xcb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#[cfg(feature = "use_glib")]
use std::marker::PhantomData;
use std::{convert::TryFrom, ops::Deref, ptr};
use std::{ops::Deref, ptr};

#[cfg(feature = "use_glib")]
use glib::translate::*;
Expand Down
2 changes: 1 addition & 1 deletion examples/gio_futures_await/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::str;

use futures::prelude::*;
use gio::prelude::*;
use glib::{self, clone};
use glib::clone;

fn main() {
let c = glib::MainContext::default();
Expand Down
4 changes: 2 additions & 2 deletions examples/gio_task/file_size/ffi.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use gio::{self, prelude::*};
use glib::{self, subclass::prelude::*, translate::*};
use gio::prelude::*;
use glib::{subclass::prelude::*, translate::*};

pub type FileSize = <super::imp::FileSize as ObjectSubclass>::Instance;

Expand Down
2 changes: 1 addition & 1 deletion examples/gio_task/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod file_size;

use file_size::FileSize;
use futures_channel::oneshot;
use glib::{self, clone, translate::*};
use glib::{clone, translate::*};

fn main() {
let main_context = glib::MainContext::default();
Expand Down
2 changes: 1 addition & 1 deletion gio/src/file_attribute_matcher.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use std::iter::{FusedIterator, IntoIterator};
use std::iter::FusedIterator;

use glib::{translate::*, GString};

Expand Down
2 changes: 1 addition & 1 deletion gio/src/io_extension_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::{marker::PhantomData, ptr};

use glib::{translate::*, GString, IntoGStr, Type};
use glib::{translate::*, GString, Type};

use crate::IOExtension;

Expand Down
1 change: 0 additions & 1 deletion gio/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
value::ValueType,
};

use futures_channel::oneshot;
Expand Down
2 changes: 1 addition & 1 deletion glib/src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::{
borrow::Borrow,
cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd},
cmp::Ordering,
fmt,
hash::{Hash, Hasher},
ops::Deref,
Expand Down
2 changes: 1 addition & 1 deletion glib/src/char.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use std::{convert::TryFrom, num::TryFromIntError};
use std::num::TryFromIntError;

use libc::{c_char, c_uchar};

Expand Down
2 changes: 0 additions & 2 deletions glib/src/checksum.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use std::vec::Vec;

use libc::size_t;

use crate::{translate::*, Checksum};
Expand Down
8 changes: 4 additions & 4 deletions glib/src/main_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ impl MainContext {
///
/// This will fail if the main context is owned already by another thread.
#[doc(alias = "g_main_context_push_thread_default")]
pub fn with_thread_default<R, F: Sized>(&self, func: F) -> Result<R, crate::BoolError>
where
F: FnOnce() -> R,
{
pub fn with_thread_default<R, F: FnOnce() -> R + Sized>(
&self,
func: F,
) -> Result<R, crate::BoolError> {
let _acquire = self.acquire()?;
let _thread_default = ThreadDefaultContext::new(self);
Ok(func())
Expand Down
10 changes: 2 additions & 8 deletions glib/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3900,10 +3900,7 @@ impl<T: IsClass> Class<T> {
/// Casts this class to a reference to a child type's class or
/// fails if this class is not implementing the child class.
#[inline]
pub fn downcast_ref<U: IsClass>(&self) -> Option<&Class<U>>
where
U: IsA<T>,
{
pub fn downcast_ref<U: IsClass + IsA<T>>(&self) -> Option<&Class<U>> {
if !self.type_().is_a(U::static_type()) {
return None;
}
Expand All @@ -3918,10 +3915,7 @@ impl<T: IsClass> Class<T> {
/// Casts this class to a mutable reference to a child type's class or
/// fails if this class is not implementing the child class.
#[inline]
pub fn downcast_ref_mut<U: IsClass>(&mut self) -> Option<&mut Class<U>>
where
U: IsA<T>,
{
pub fn downcast_ref_mut<U: IsClass + IsA<T>>(&mut self) -> Option<&mut Class<U>> {
if !self.type_().is_a(U::static_type()) {
return None;
}
Expand Down
1 change: 0 additions & 1 deletion glib/src/param_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use std::{
char::CharTryFromError,
convert::TryFrom,
ffi::CStr,
num::{NonZeroI32, NonZeroI64, NonZeroI8, NonZeroU32, NonZeroU64, NonZeroU8},
path::{Path, PathBuf},
Expand Down
3 changes: 1 addition & 2 deletions glib/src/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
//! compatibility with GLib.Regex based APIs.
use crate::{
translate::*, GStr, GStringPtr, IntoGStr, MatchInfo, PtrSlice, Regex, RegexCompileFlags,
RegexMatchFlags,
translate::*, GStr, GStringPtr, MatchInfo, PtrSlice, Regex, RegexCompileFlags, RegexMatchFlags,
};
use std::{mem, ptr};

Expand Down
2 changes: 1 addition & 1 deletion glib/src/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use std::{mem, num::NonZeroU64};

use ffi::gpointer;
use gobject_ffi::{self, GCallback};
use gobject_ffi::GCallback;
use libc::{c_char, c_ulong, c_void};

use crate::{prelude::*, translate::*};
Expand Down
2 changes: 1 addition & 1 deletion glib/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::os::unix::io::RawFd;
use std::{cell::RefCell, mem::transmute, num::NonZeroU32, time::Duration};

use ffi::{self, gboolean, gpointer};
use ffi::{gboolean, gpointer};
#[cfg(all(not(unix), docsrs))]
use libc::c_int as RawFd;

Expand Down
2 changes: 1 addition & 1 deletion glib/src/source_futures.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use std::{marker::Unpin, pin, pin::Pin, time::Duration};
use std::{pin, pin::Pin, time::Duration};

use futures_channel::{mpsc, oneshot};
use futures_core::{
Expand Down
3 changes: 1 addition & 2 deletions glib/src/subclass/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
use std::{fmt, num::NonZeroU32, ptr, sync::Mutex};

use crate::{
prelude::*, translate::*, utils::is_canonical_pspec_name, Closure, IntoGStr, SignalFlags, Type,
Value,
prelude::*, translate::*, utils::is_canonical_pspec_name, Closure, SignalFlags, Type, Value,
};

// rustdoc-stripper-ignore-next
Expand Down
1 change: 0 additions & 1 deletion glib/src/subclass/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::{any::Any, collections::BTreeMap, marker, mem, ptr};

use super::SignalId;
use crate::{
gobject::traits::DynamicObjectRegisterExt,
object::{IsClass, IsInterface, ObjectSubclassIs, ParentClassIs},
prelude::*,
translate::*,
Expand Down
6 changes: 3 additions & 3 deletions glib/src/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ use std::os::unix::prelude::*;
use std::{
borrow::Cow,
char,
cmp::{Eq, Ordering, PartialEq},
cmp::Ordering,
collections::HashMap,
error::Error,
ffi::{CStr, CString, OsStr, OsString},
Expand Down Expand Up @@ -2891,7 +2891,7 @@ mod tests {

#[test]
fn invalid_value() {
use std::{convert::TryFrom, num::TryFromIntError};
use std::num::TryFromIntError;

#[derive(Debug, PartialEq, Eq)]
struct U32(u32);
Expand All @@ -2911,7 +2911,7 @@ mod tests {

#[test]
fn none_or_invalid_value() {
use std::{convert::TryFrom, num::TryFromIntError};
use std::num::TryFromIntError;

#[derive(Debug, PartialEq, Eq)]
struct SpecialU32(u32);
Expand Down
2 changes: 1 addition & 1 deletion glib/src/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
use std::{
borrow::Cow,
cmp::{Eq, Ordering, PartialEq, PartialOrd},
cmp::Ordering,
collections::{BTreeMap, HashMap},
fmt,
hash::{BuildHasher, Hash, Hasher},
Expand Down
2 changes: 1 addition & 1 deletion glib/src/variant_dict.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use std::{borrow::Cow, default::Default};
use std::borrow::Cow;

use crate::{translate::*, variant::*, variant_type::*};

Expand Down
2 changes: 1 addition & 1 deletion glib/src/variant_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// introduce a heap allocation and doesn't provide a way to determine how
// many items are left in the iterator.

use std::iter::{DoubleEndedIterator, ExactSizeIterator, FusedIterator};
use std::iter::FusedIterator;

use crate::{translate::*, Variant};

Expand Down
3 changes: 1 addition & 2 deletions glib/src/variant_type.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Take a look at the license at the top of the repository in the LICENSE file.

use std::{
borrow::{Borrow, Cow, ToOwned},
cmp::{Eq, PartialEq},
borrow::{Borrow, Cow},
fmt,
hash::{Hash, Hasher},
iter,
Expand Down

0 comments on commit 691e46a

Please sign in to comment.