Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit 92b365b

Browse files
authored
Merge pull request #468 from EPashkin/clippy
Fix some clippy warnings
2 parents 9a9dd5c + 781a66a commit 92b365b

21 files changed

+70
-81
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ before_install:
5555
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig; fi
5656
- if [[ "$ARM" == "1" ]]; then rustup target add armv7-unknown-linux-gnueabihf; fi
5757
script:
58+
- if [ "$TRAVIS_RUST_VERSION" == "beta" ]; then
59+
rustup component add clippy;
60+
cargo clippy --release;
61+
fi
5862
- if [ "$TRAVIS_RUST_VERSION" == "nightly" ] && [ "$GTK" == "3.14" ] && ! [ "$ARM" == "1" ]; then
5963
make regen_check;
6064
fi

src/closure.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ impl Closure {
8282
from_glib_none(closure)
8383
}
8484

85+
#[allow(clippy::redundant_closure)]
8586
pub fn invoke(&self, values: &[&ToValue]) -> Option<Value> {
8687
let mut result = unsafe { Value::uninitialized() };
8788

src/error.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,6 @@ impl Error {
8383
})
8484
}
8585
}
86-
87-
// backcompat shim
88-
#[cfg_attr(feature = "cargo-clippy", allow(not_unsafe_ptr_arg_deref))]
89-
pub fn wrap(ptr: *mut glib_ffi::GError) -> Error {
90-
unsafe { from_glib_full(ptr) }
91-
}
9286
}
9387

9488
impl fmt::Display for Error {

src/file_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl ErrorDomain for FileError {
7272
}
7373
}
7474

75-
#[cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))]
75+
#[allow(clippy::cyclomatic_complexity)]
7676
fn from(code: i32) -> Option<Self> {
7777
use self::FileError::*;
7878
match code {

src/gobject/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
//! GObject bindings
66
7-
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
87
pub mod auto;
98

109
pub use self::auto::*;

src/key_file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl KeyFile {
4848
pub fn load_from_dirs<T: AsRef<std::path::Path>, U: AsRef<std::path::Path>>(&self, file: T, search_dirs: &[U],
4949
flags: KeyFileFlags) -> Result<path::PathBuf, Error> {
5050
unsafe {
51-
let search_dirs: Vec<&std::path::Path> = search_dirs.iter().map(|p| p.as_ref()).collect();
51+
let search_dirs: Vec<&std::path::Path> = search_dirs.iter().map(AsRef::as_ref).collect();
5252
let mut error = ptr::null_mut();
5353
let mut full_path: *mut libc::c_char = ptr::null_mut();
5454
let _ = ffi::g_key_file_load_from_dirs(self.to_glib_none().0,

src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@
7575
//! conversions between high level Rust types (including the aforementioned
7676
//! wrappers) and their FFI counterparts.
7777
78-
#![cfg_attr(feature = "cargo-clippy", allow(doc_markdown))]
78+
#![allow(clippy::doc_markdown)]
79+
#![allow(clippy::unreadable_literal)]
7980

8081
#[macro_use]
8182
extern crate bitflags;
@@ -164,9 +165,9 @@ pub mod object;
164165

165166
pub use auto::*;
166167
pub use auto::functions::*;
167-
#[cfg_attr(feature = "cargo-clippy", allow(let_and_return))]
168-
#[cfg_attr(feature = "cargo-clippy", allow(let_unit_value))]
169-
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
168+
#[allow(clippy::let_and_return)]
169+
#[allow(clippy::let_unit_value)]
170+
#[allow(clippy::too_many_arguments)]
170171
#[allow(non_upper_case_globals)]
171172
mod auto;
172173

src/main_context.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use ffi;
66
use translate::*;
7-
use std::mem::transmute;
87
use std::mem;
98
use ffi as glib_ffi;
109
use ffi::{gpointer, gboolean};
@@ -96,9 +95,8 @@ impl MainContext {
9695
}
9796
}
9897

99-
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
10098
unsafe extern "C" fn trampoline<F: FnOnce() + 'static>(func: gpointer) -> gboolean {
101-
let func: &mut Option<F> = transmute(func);
99+
let func: &mut Option<F> = &mut *(func as *mut Option<F>);
102100
let func = func.take().expect("MainContext::invoke() closure called multiple times");
103101
func();
104102
glib_ffi::G_SOURCE_REMOVE

src/main_context_channel.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,16 +496,14 @@ impl<T> Receiver<T> {
496496
}
497497

498498
let source = Source::from_glib_full(mut_override(&(*source).source));
499-
let id = if let Some(context) = context {
499+
if let Some(context) = context {
500500
assert!(context.is_owner());
501501
source.attach(Some(context))
502502
} else {
503503
let context = MainContext::ref_thread_default();
504504
assert!(context.is_owner());
505505
source.attach(Some(&context))
506-
};
507-
508-
id
506+
}
509507
}
510508
}
511509
}

src/main_context_futures.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const NOT_READY: usize = 1;
2828
const READY: usize = 2;
2929
const DONE: usize = 3;
3030

31+
#[allow(clippy::type_complexity)]
3132
#[repr(C)]
3233
struct TaskSource {
3334
source: glib_ffi::GSource,
@@ -138,6 +139,7 @@ static SOURCE_FUNCS: glib_ffi::GSourceFuncs = glib_ffi::GSourceFuncs {
138139
};
139140

140141
impl TaskSource {
142+
#[allow(clippy::new_ret_no_self)]
141143
fn new(
142144
priority: Priority,
143145
future: Box<Future<Item = (), Error = Never> + 'static + Send>,
@@ -275,6 +277,7 @@ impl MainContext {
275277
///
276278
/// This must only be called if no `MainLoop` or anything else is running on this specific main
277279
/// context.
280+
#[allow(clippy::transmute_ptr_to_ptr)]
278281
pub fn block_on<F: Future>(&self, f: F) -> Result<F::Item, F::Error> {
279282
let mut res = None;
280283
let l = MainLoop::new(Some(&*self), false);

0 commit comments

Comments
 (0)