Skip to content

Commit b4aac68

Browse files
committed
Fix clippy warnings
1 parent ce2d819 commit b4aac68

File tree

7 files changed

+17
-19
lines changed

7 files changed

+17
-19
lines changed

gio/src/desktop_app_info.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

3-
#[cfg(any(all(feature = "v2_58", unix), all(unix, docsrs)))]
3+
#[cfg(all(unix, feature = "v2_58"))]
44
use std::boxed::Box as Box_;
5-
#[cfg(any(all(feature = "v2_58", unix), all(unix, docsrs)))]
5+
#[cfg(all(unix, feature = "v2_58"))]
66
use std::os::unix::io::AsRawFd;
7-
#[cfg(any(all(feature = "v2_58", unix), all(unix, docsrs)))]
7+
#[cfg(all(unix, feature = "v2_58"))]
88
use std::ptr;
99

10-
#[cfg(any(all(feature = "v2_58", unix), all(unix, docsrs)))]
10+
#[cfg(all(feature = "v2_58", unix))]
1111
use glib::Error;
1212
use glib::{prelude::*, translate::*, GString};
1313

14-
#[cfg(any(all(feature = "v2_58", unix), all(unix, docsrs)))]
14+
#[cfg(all(feature = "v2_58", unix))]
1515
use crate::AppLaunchContext;
1616
use crate::DesktopAppInfo;
1717

@@ -45,7 +45,7 @@ impl DesktopAppInfo {
4545
}
4646

4747
pub trait DesktopAppInfoExtManual {
48-
#[cfg(any(all(feature = "v2_58", unix), all(unix, docsrs)))]
48+
#[cfg(all(feature = "v2_58", unix))]
4949
#[cfg_attr(docsrs, doc(cfg(all(feature = "v2_58", unix))))]
5050
#[doc(alias = "g_desktop_app_info_launch_uris_as_manager_with_fds")]
5151
fn launch_uris_as_manager_with_fds<
@@ -67,7 +67,7 @@ pub trait DesktopAppInfoExtManual {
6767
}
6868

6969
impl<O: IsA<DesktopAppInfo>> DesktopAppInfoExtManual for O {
70-
#[cfg(any(all(feature = "v2_58", unix), all(unix, docsrs)))]
70+
#[cfg(all(feature = "v2_58", unix))]
7171
#[cfg_attr(docsrs, doc(cfg(all(feature = "v2_58", unix))))]
7272
fn launch_uris_as_manager_with_fds<
7373
P: IsA<AppLaunchContext>,

gio/src/socket.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
#[cfg(not(unix))]
44
use std::os::raw::c_int;
5-
#[cfg(not(windows))]
6-
#[cfg_attr(docsrs, doc(cfg(not(windows))))]
7-
use std::os::raw::c_void;
85
#[cfg(unix)]
96
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
107
#[cfg(windows)]
@@ -49,15 +46,15 @@ impl Socket {
4946
}
5047
}
5148

52-
#[cfg(unix)]
49+
#[cfg(any(unix, docsrs))]
5350
#[cfg_attr(docsrs, doc(cfg(unix)))]
5451
impl AsRawFd for Socket {
5552
fn as_raw_fd(&self) -> RawFd {
5653
unsafe { ffi::g_socket_get_fd(self.to_glib_none().0) as _ }
5754
}
5855
}
5956

60-
#[cfg(windows)]
57+
#[cfg(any(windows, docsrs))]
6158
#[cfg_attr(docsrs, doc(cfg(windows)))]
6259
impl AsRawSocket for Socket {
6360
fn as_raw_socket(&self) -> RawSocket {
@@ -916,7 +913,7 @@ pub trait AsRawSocket {
916913
}
917914

918915
#[cfg(all(docsrs, not(windows)))]
919-
pub type RawSocket = *mut c_void;
916+
pub type RawSocket = *mut std::os::raw::c_void;
920917

921918
#[cfg(test)]
922919
mod tests {

glib/src/bridged_logging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl GlibLogger {
142142
message: &str,
143143
) {
144144
let line = line.map(|l| l.to_string());
145-
let line = line.as_ref().map(|s| s.as_str());
145+
let line = line.as_deref();
146146

147147
crate::log_structured!(
148148
domain.unwrap_or("default"),

glib/src/collections/list.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ impl<T: TransparentPtrType> List<T> {
385385
/// Consumes the list and returns the underlying pointer.
386386
#[inline]
387387
pub fn into_raw(mut self) -> *mut ffi::GList {
388-
mem::replace(&mut self.ptr, None)
388+
self.ptr
389+
.take()
389390
.map(|p| p.as_ptr())
390391
.unwrap_or(ptr::null_mut())
391392
}

glib/src/collections/slist.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ impl<T: TransparentPtrType> SList<T> {
380380
/// Consumes the list and returns the underlying pointer.
381381
#[inline]
382382
pub fn into_raw(mut self) -> *mut ffi::GSList {
383-
mem::replace(&mut self.ptr, None)
383+
self.ptr
384+
.take()
384385
.map(|p| p.as_ptr())
385386
.unwrap_or(ptr::null_mut())
386387
}

glib/src/main_context_futures.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,11 +620,10 @@ impl MainContext {
620620
pub fn block_on<F: Future>(&self, f: F) -> F::Output {
621621
let mut res = None;
622622
let l = MainLoop::new(Some(self), false);
623-
let l_clone = l.clone();
624623

625624
let f = async {
626625
res = Some(panic::AssertUnwindSafe(f).catch_unwind().await);
627-
l_clone.quit();
626+
l.quit();
628627
};
629628

630629
let f = unsafe {

glib/src/variant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,7 @@ impl<A: AsRef<[T]>, T: FixedSizeVariantType> From<FixedSizeVariantArray<A, T>> f
19581958
let data = Box::new(a.0);
19591959
let (data_ptr, len) = {
19601960
let data = (*data).as_ref();
1961-
(data.as_ptr(), data.len() * mem::size_of::<T>())
1961+
(data.as_ptr(), mem::size_of_val(data))
19621962
};
19631963

19641964
unsafe extern "C" fn free_data<A: AsRef<[T]>, T: FixedSizeVariantType>(

0 commit comments

Comments
 (0)