Skip to content

Commit

Permalink
Fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Oct 25, 2022
1 parent fea8ed7 commit 28acedc
Show file tree
Hide file tree
Showing 64 changed files with 687 additions and 742 deletions.
2 changes: 1 addition & 1 deletion cairo/src/paths.rs
Expand Up @@ -102,7 +102,7 @@ impl<'a> Iterator for PathSegments<'a> {
to_tuple(&self.data[self.i + 3].point),
),
PathDataType::ClosePath => PathSegment::ClosePath,
PathDataType::__Unknown(x) => panic!("Unknown value: {}", x),
PathDataType::__Unknown(x) => panic!("Unknown value: {x}"),
};

self.i += self.data[self.i].header.length as usize;
Expand Down
2 changes: 1 addition & 1 deletion cairo/sys/build.rs
Expand Up @@ -7,7 +7,7 @@ fn main() {} // prevent linking libraries to avoid documentation failure
#[cfg(not(feature = "dox"))]
fn main() {
if let Err(s) = system_deps::Config::new().probe() {
println!("cargo:warning={}", s);
println!("cargo:warning={s}");
process::exit(1);
}
}
2 changes: 1 addition & 1 deletion examples/gio_cancellable_future/main.rs
Expand Up @@ -27,7 +27,7 @@ fn main() {
let cancellable_task = gio::CancellableFuture::new(a_very_long_task(), cancellable.clone())
.map(move |res| {
if let Err(error) = res {
println!("{:?}", error);
println!("{error:?}");
}

main_loop.quit();
Expand Down
10 changes: 5 additions & 5 deletions examples/gio_futures/main.rs
Expand Up @@ -17,7 +17,7 @@ fn main() {
// error first print that error.
.map(move |res| {
if let Err(err) = res {
eprintln!("Got error: {}", err);
eprintln!("Got error: {err}");
}

l_clone.quit();
Expand All @@ -36,7 +36,7 @@ fn read_and_print_file(
file: &gio::File,
) -> impl Future<Output = Result<(), String>> + std::marker::Unpin {
file.read_future(glib::PRIORITY_DEFAULT)
.map_err(|err| format!("Failed to open file: {}", err))
.map_err(|err| format!("Failed to open file: {err}"))
.and_then(read_and_print_chunks)
}

Expand Down Expand Up @@ -98,9 +98,9 @@ fn read_and_print_next_chunk(
) -> impl Future<Output = Result<Option<Vec<u8>>, String>> + std::marker::Unpin {
let strm_clone = strm.clone();
strm.read_future(buf, glib::PRIORITY_DEFAULT)
.map_err(|(_buf, err)| format!("Failed to read from stream: {}", err))
.map_err(|(_buf, err)| format!("Failed to read from stream: {err}"))
.and_then(move |(buf, len)| {
println!("line {}: {:?}", idx, str::from_utf8(&buf[0..len]).unwrap());
println!("line {idx}: {:?}", str::from_utf8(&buf[0..len]).unwrap());

// 0 is only returned when the input stream is finished, in which case
// we drop the buffer and close the stream asynchronously.
Expand All @@ -111,7 +111,7 @@ fn read_and_print_next_chunk(
futures::future::Either::Left(
strm_clone
.close_future(glib::PRIORITY_DEFAULT)
.map_err(|err| format!("Failed to close stream: {}", err))
.map_err(|err| format!("Failed to close stream: {err}"))
.map_ok(|_| None),
)
} else {
Expand Down
10 changes: 5 additions & 5 deletions examples/gio_futures_await/main.rs
Expand Up @@ -14,7 +14,7 @@ fn main() {
let future = clone!(@strong l => async move {
match read_file(file).await {
Ok(()) => (),
Err(err) => eprintln!("Got error: {}", err),
Err(err) => eprintln!("Got error: {err}"),
}
l.quit();
});
Expand All @@ -30,7 +30,7 @@ async fn read_file(file: gio::File) -> Result<(), String> {
// Try to open the file.
let strm = file
.read_future(glib::PRIORITY_DEFAULT)
.map_err(|err| format!("Failed to open file: {}", err))
.map_err(|err| format!("Failed to open file: {err}"))
.await?;

// If opening the file succeeds, we asynchronously loop and
Expand All @@ -42,7 +42,7 @@ async fn read_file(file: gio::File) -> Result<(), String> {
loop {
let (b, len) = strm
.read_future(buf, glib::PRIORITY_DEFAULT)
.map_err(|(_buf, err)| format!("Failed to read from stream: {}", err))
.map_err(|(_buf, err)| format!("Failed to read from stream: {err}"))
.await?;

// Once 0 is returned, we know that we're done with reading, otherwise
Expand All @@ -53,14 +53,14 @@ async fn read_file(file: gio::File) -> Result<(), String> {

buf = b;

println!("line {}: {:?}", idx, str::from_utf8(&buf[0..len]).unwrap());
println!("line {idx}: {:?}", str::from_utf8(&buf[0..len]).unwrap());

idx += 1;
}

// Asynchronously close the stream in the end.
strm.close_future(glib::PRIORITY_DEFAULT)
.map_err(|err| format!("Failed to close stream: {}", err))
.map_err(|err| format!("Failed to close stream: {err}"))
.await?;

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions examples/gio_task/main.rs
Expand Up @@ -58,7 +58,7 @@ fn run_unsafe(send: oneshot::Sender<()>) {
return;
}

println!("Unsafe callback - Returned value from task: {}", ret);
println!("Unsafe callback - Returned value from task: {ret}");
println!(
"Unsafe callback - FileSize::size: {}",
file_size::ffi::my_file_size_get_retrieved_size(
Expand Down Expand Up @@ -89,7 +89,7 @@ fn run_safe(send: oneshot::Sender<()>) {
let cancellable = gio::Cancellable::new();

let closure = move |value: i64, source_object: &FileSize| {
println!("Safe callback - Returned value from task: {}", value);
println!("Safe callback - Returned value from task: {value}");
println!(
"Safe callback - FileSize::size: {}",
source_object.retrieved_size().unwrap()
Expand Down
4 changes: 2 additions & 2 deletions gdk-pixbuf/src/pixbuf.rs
Expand Up @@ -50,7 +50,7 @@ impl Pixbuf {
let ptr = {
let data: &mut [u8] = (*data).as_mut();
assert!(
data.len() >= ((height - 1) * row_stride + last_row_len) as usize,
data.len() >= ((height - 1) * row_stride + last_row_len),
"data.len() must fit the width, height, and row_stride"
);
data.as_mut_ptr()
Expand Down Expand Up @@ -406,7 +406,7 @@ impl Pixbuf {
if error.is_null() {
Ok(FromGlibContainer::from_glib_full_num(
buffer,
buffer_size.assume_init() as usize,
buffer_size.assume_init() as _,
))
} else {
Err(from_glib_full(error))
Expand Down
2 changes: 1 addition & 1 deletion gdk-pixbuf/sys/build.rs
Expand Up @@ -11,7 +11,7 @@ fn main() {} // prevent linking libraries to avoid documentation failure
#[cfg(not(feature = "dox"))]
fn main() {
if let Err(s) = system_deps::Config::new().probe() {
println!("cargo:warning={}", s);
println!("cargo:warning={s}");
process::exit(1);
}
}
26 changes: 13 additions & 13 deletions gdk-pixbuf/sys/src/lib.rs
Expand Up @@ -127,7 +127,7 @@ pub struct GdkPixbufAnimationClass {

impl ::std::fmt::Debug for GdkPixbufAnimationClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GdkPixbufAnimationClass @ {:p}", self))
f.debug_struct(&format!("GdkPixbufAnimationClass @ {self:p}"))
.field("parent_class", &self.parent_class)
.field("is_static_image", &self.is_static_image)
.field("get_static_image", &self.get_static_image)
Expand All @@ -152,7 +152,7 @@ pub struct GdkPixbufAnimationIterClass {

impl ::std::fmt::Debug for GdkPixbufAnimationIterClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GdkPixbufAnimationIterClass @ {:p}", self))
f.debug_struct(&format!("GdkPixbufAnimationIterClass @ {self:p}"))
.field("parent_class", &self.parent_class)
.field("get_delay_time", &self.get_delay_time)
.field("get_pixbuf", &self.get_pixbuf)
Expand Down Expand Up @@ -181,7 +181,7 @@ pub struct GdkPixbufFormat {

impl ::std::fmt::Debug for GdkPixbufFormat {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GdkPixbufFormat @ {:p}", self))
f.debug_struct(&format!("GdkPixbufFormat @ {self:p}"))
.field("name", &self.name)
.field("signature", &self.signature)
.field("domain", &self.domain)
Expand All @@ -208,7 +208,7 @@ pub struct GdkPixbufLoaderClass {

impl ::std::fmt::Debug for GdkPixbufLoaderClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GdkPixbufLoaderClass @ {:p}", self))
f.debug_struct(&format!("GdkPixbufLoaderClass @ {self:p}"))
.field("parent_class", &self.parent_class)
.field("size_prepared", &self.size_prepared)
.field("area_prepared", &self.area_prepared)
Expand Down Expand Up @@ -242,7 +242,7 @@ pub struct GdkPixbufModule {

impl ::std::fmt::Debug for GdkPixbufModule {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GdkPixbufModule @ {:p}", self))
f.debug_struct(&format!("GdkPixbufModule @ {self:p}"))
.field("module_name", &self.module_name)
.field("module_path", &self.module_path)
.field("module", &self.module)
Expand Down Expand Up @@ -274,7 +274,7 @@ pub struct GdkPixbufModulePattern {

impl ::std::fmt::Debug for GdkPixbufModulePattern {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GdkPixbufModulePattern @ {:p}", self))
f.debug_struct(&format!("GdkPixbufModulePattern @ {self:p}"))
.field("prefix", &self.prefix)
.field("mask", &self.mask)
.field("relevance", &self.relevance)
Expand All @@ -299,7 +299,7 @@ pub struct GdkPixbuf {

impl ::std::fmt::Debug for GdkPixbuf {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GdkPixbuf @ {:p}", self)).finish()
f.debug_struct(&format!("GdkPixbuf @ {self:p}")).finish()
}
}

Expand All @@ -311,7 +311,7 @@ pub struct GdkPixbufAnimation {

impl ::std::fmt::Debug for GdkPixbufAnimation {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GdkPixbufAnimation @ {:p}", self))
f.debug_struct(&format!("GdkPixbufAnimation @ {self:p}"))
.field("parent_instance", &self.parent_instance)
.finish()
}
Expand All @@ -325,7 +325,7 @@ pub struct GdkPixbufAnimationIter {

impl ::std::fmt::Debug for GdkPixbufAnimationIter {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GdkPixbufAnimationIter @ {:p}", self))
f.debug_struct(&format!("GdkPixbufAnimationIter @ {self:p}"))
.field("parent_instance", &self.parent_instance)
.finish()
}
Expand All @@ -340,7 +340,7 @@ pub struct GdkPixbufLoader {

impl ::std::fmt::Debug for GdkPixbufLoader {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GdkPixbufLoader @ {:p}", self))
f.debug_struct(&format!("GdkPixbufLoader @ {self:p}"))
.finish()
}
}
Expand All @@ -353,7 +353,7 @@ pub struct GdkPixbufNonAnim {

impl ::std::fmt::Debug for GdkPixbufNonAnim {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GdkPixbufNonAnim @ {:p}", self))
f.debug_struct(&format!("GdkPixbufNonAnim @ {self:p}"))
.finish()
}
}
Expand All @@ -366,7 +366,7 @@ pub struct GdkPixbufSimpleAnim {

impl ::std::fmt::Debug for GdkPixbufSimpleAnim {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GdkPixbufSimpleAnim @ {:p}", self))
f.debug_struct(&format!("GdkPixbufSimpleAnim @ {self:p}"))
.finish()
}
}
Expand All @@ -379,7 +379,7 @@ pub struct GdkPixbufSimpleAnimIter {

impl ::std::fmt::Debug for GdkPixbufSimpleAnimIter {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GdkPixbufSimpleAnimIter @ {:p}", self))
f.debug_struct(&format!("GdkPixbufSimpleAnimIter @ {self:p}"))
.finish()
}
}
Expand Down
2 changes: 1 addition & 1 deletion gdk-pixbuf/sys/versions.txt
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 952ff416b599)
Generated by gir (https://github.com/gtk-rs/gir @ f0e953c094a5)
from gir-files (https://github.com/gtk-rs/gir-files @ 89a11aa6a362)
8 changes: 4 additions & 4 deletions gio/src/async_initable.rs
Expand Up @@ -57,7 +57,7 @@ impl AsyncInitable {
callback: Q,
) {
if !type_.is_a(AsyncInitable::static_type()) {
panic!("Type '{}' is not async initable", type_);
panic!("Type '{type_}' is not async initable");
}

let mut property_values = smallvec::SmallVec::<[_; 16]>::with_capacity(properties.len());
Expand Down Expand Up @@ -85,7 +85,7 @@ impl AsyncInitable {
io_priority: glib::Priority,
) -> Pin<Box_<dyn std::future::Future<Output = Result<Object, glib::Error>> + 'static>> {
if !type_.is_a(AsyncInitable::static_type()) {
panic!("Type '{}' is not async initable", type_);
panic!("Type '{type_}' is not async initable");
}

let mut property_values = smallvec::SmallVec::<[_; 16]>::with_capacity(properties.len());
Expand Down Expand Up @@ -121,7 +121,7 @@ impl AsyncInitable {
callback: Q,
) {
if !type_.is_a(AsyncInitable::static_type()) {
panic!("Type '{}' is not async initable", type_);
panic!("Type '{type_}' is not async initable");
}

let mut property_values = smallvec::SmallVec::<[_; 16]>::with_capacity(properties.len());
Expand Down Expand Up @@ -149,7 +149,7 @@ impl AsyncInitable {
io_priority: glib::Priority,
) -> Pin<Box_<dyn std::future::Future<Output = Result<Object, glib::Error>> + 'static>> {
if !type_.is_a(AsyncInitable::static_type()) {
panic!("Type '{}' is not async initable", type_);
panic!("Type '{type_}' is not async initable");
}

let mut property_values = smallvec::SmallVec::<[_; 16]>::with_capacity(properties.len());
Expand Down
2 changes: 1 addition & 1 deletion gio/src/cancellable.rs
Expand Up @@ -26,7 +26,7 @@ impl TryFromGlib<libc::c_ulong> for CancelledHandlerId {
type Error = GlibNoneError;
#[inline]
unsafe fn try_from_glib(val: libc::c_ulong) -> Result<Self, GlibNoneError> {
NonZeroU64::new(val as u64).map(Self).ok_or(GlibNoneError)
NonZeroU64::new(val as _).map(Self).ok_or(GlibNoneError)
}
}

Expand Down
2 changes: 1 addition & 1 deletion gio/src/dbus_proxy.rs
Expand Up @@ -95,7 +95,7 @@ impl<O: IsA<DBusProxy>> DBusProxyExtManual for O {
}
unsafe {
let f: Box_<F> = Box_::new(f);
let detailed_signal_name = detail.map(|name| format!("g-signal::{}\0", name));
let detailed_signal_name = detail.map(|name| format!("g-signal::{name}\0"));
let signal_name: &[u8] = detailed_signal_name
.as_ref()
.map_or(&b"g-signal\0"[..], |n| n.as_bytes());
Expand Down
2 changes: 1 addition & 1 deletion gio/src/file.rs
Expand Up @@ -683,7 +683,7 @@ impl<O: IsA<File>> FileExtManual for O {
);
let result = if error.is_null() {
Ok((
FromGlibContainer::from_glib_full_num(contents, length.assume_init() as usize),
FromGlibContainer::from_glib_full_num(contents, length.assume_init() as _),
from_glib_full(etag_out),
))
} else {
Expand Down
4 changes: 2 additions & 2 deletions gio/src/initable.rs
Expand Up @@ -36,7 +36,7 @@ impl Initable {
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<Object, glib::Error> {
if !type_.is_a(Initable::static_type()) {
panic!("Type '{}' is not initable", type_);
panic!("Type '{type_}' is not initable");
}

let mut property_values = smallvec::SmallVec::<[_; 16]>::with_capacity(properties.len());
Expand All @@ -63,7 +63,7 @@ impl Initable {
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<Object, glib::Error> {
if !type_.is_a(Initable::static_type()) {
panic!("Type '{}' is not initable", type_);
panic!("Type '{type_}' is not initable");
}

let mut property_values = smallvec::SmallVec::<[_; 16]>::with_capacity(properties.len());
Expand Down
1 change: 1 addition & 0 deletions gio/src/lib.rs
Expand Up @@ -7,6 +7,7 @@
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::upper_case_acronyms)]
#![allow(clippy::non_send_fields_in_send_ty)]
#![allow(clippy::should_implement_trait)]
#![doc = include_str!("../README.md")]

pub use ffi;
Expand Down
4 changes: 2 additions & 2 deletions gio/src/list_model.rs
Expand Up @@ -103,8 +103,8 @@ impl<'a, T: IsA<glib::Object>> Iterator for ListModelIter<'a, T> {
}

fn size_hint(&self) -> (usize, Option<usize>) {
let n = (self.reverse_pos - self.i) as usize;
(n as usize, Some(n))
let n: usize = (self.reverse_pos - self.i) as _;
(n as _, Some(n))
}

fn count(self) -> usize {
Expand Down
2 changes: 1 addition & 1 deletion gio/src/output_stream.rs
Expand Up @@ -148,7 +148,7 @@ impl<O: IsA<OutputStream>> OutputStreamExtManual for O {
) -> Result<(usize, Option<glib::Error>), glib::Error> {
let cancellable = cancellable.map(|c| c.as_ref());
let gcancellable = cancellable.to_glib_none();
let count = buffer.len() as usize;
let count = buffer.len();
unsafe {
let mut bytes_written = mem::MaybeUninit::uninit();
let mut error = ptr::null_mut();
Expand Down
2 changes: 1 addition & 1 deletion gio/src/pollable_input_stream.rs
Expand Up @@ -120,7 +120,7 @@ impl<O: IsA<PollableInputStream>> PollableInputStreamExtManual for O {
) -> Result<isize, glib::Error> {
let cancellable = cancellable.map(|c| c.as_ref());
let gcancellable = cancellable.to_glib_none();
let count = buffer.len() as usize;
let count = buffer.len();
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::g_pollable_input_stream_read_nonblocking(
Expand Down

0 comments on commit 28acedc

Please sign in to comment.