Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix new clippy lints #816

Merged
merged 3 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cairo/src/paths.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
6 changes: 3 additions & 3 deletions gdk-pixbuf/src/auto/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ bitflags! {
#[doc(alias = "GdkPixbufFormatFlags")]
pub struct PixbufFormatFlags: u32 {
#[doc(alias = "GDK_PIXBUF_FORMAT_WRITABLE")]
const WRITABLE = ffi::GDK_PIXBUF_FORMAT_WRITABLE as u32;
const WRITABLE = ffi::GDK_PIXBUF_FORMAT_WRITABLE as _;
#[doc(alias = "GDK_PIXBUF_FORMAT_SCALABLE")]
const SCALABLE = ffi::GDK_PIXBUF_FORMAT_SCALABLE as u32;
const SCALABLE = ffi::GDK_PIXBUF_FORMAT_SCALABLE as _;
#[doc(alias = "GDK_PIXBUF_FORMAT_THREADSAFE")]
const THREADSAFE = ffi::GDK_PIXBUF_FORMAT_THREADSAFE as u32;
const THREADSAFE = ffi::GDK_PIXBUF_FORMAT_THREADSAFE as _;
}
}

Expand Down
2 changes: 1 addition & 1 deletion gdk-pixbuf/src/auto/pixbuf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl<O: IsA<PixbufLoader>> PixbufLoaderExt for O {
}

fn write(&self, buf: &[u8]) -> Result<(), glib::Error> {
let count = buf.len() as usize;
let count = buf.len() as _;
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::gdk_pixbuf_loader_write(
Expand Down
2 changes: 1 addition & 1 deletion gdk-pixbuf/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 952ff416b599)
Generated by gir (https://github.com/gtk-rs/gir @ 818f714dc796)
from gir-files (https://github.com/gtk-rs/gir-files @ 89a11aa6a362)
4 changes: 2 additions & 2 deletions gdk-pixbuf/src/pixbuf.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 952ff416b599)
Generated by gir (https://github.com/gtk-rs/gir @ 818f714dc796)
from gir-files (https://github.com/gtk-rs/gir-files @ 89a11aa6a362)
8 changes: 4 additions & 4 deletions gio/src/async_initable.rs
Original file line number Diff line number Diff line change
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
9 changes: 4 additions & 5 deletions gio/src/auto/action_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl<O: IsA<ActionGroup>> ActionGroupExt for O {
}
unsafe {
let f: Box_<F> = Box_::new(f);
let detailed_signal_name = detail.map(|name| format!("action-added::{}\0", name));
let detailed_signal_name = detail.map(|name| format!("action-added::{name}\0"));
let signal_name: &[u8] = detailed_signal_name
.as_ref()
.map_or(&b"action-added\0"[..], |n| n.as_bytes());
Expand Down Expand Up @@ -279,7 +279,7 @@ impl<O: IsA<ActionGroup>> ActionGroupExt for O {
unsafe {
let f: Box_<F> = Box_::new(f);
let detailed_signal_name =
detail.map(|name| format!("action-enabled-changed::{}\0", name));
detail.map(|name| format!("action-enabled-changed::{name}\0"));
let signal_name: &[u8] = detailed_signal_name
.as_ref()
.map_or(&b"action-enabled-changed\0"[..], |n| n.as_bytes());
Expand Down Expand Up @@ -315,7 +315,7 @@ impl<O: IsA<ActionGroup>> ActionGroupExt for O {
}
unsafe {
let f: Box_<F> = Box_::new(f);
let detailed_signal_name = detail.map(|name| format!("action-removed::{}\0", name));
let detailed_signal_name = detail.map(|name| format!("action-removed::{name}\0"));
let signal_name: &[u8] = detailed_signal_name
.as_ref()
.map_or(&b"action-removed\0"[..], |n| n.as_bytes());
Expand Down Expand Up @@ -353,8 +353,7 @@ impl<O: IsA<ActionGroup>> ActionGroupExt for O {
}
unsafe {
let f: Box_<F> = Box_::new(f);
let detailed_signal_name =
detail.map(|name| format!("action-state-changed::{}\0", name));
let detailed_signal_name = detail.map(|name| format!("action-state-changed::{name}\0"));
let signal_name: &[u8] = detailed_signal_name
.as_ref()
.map_or(&b"action-state-changed\0"[..], |n| n.as_bytes());
Expand Down
3 changes: 2 additions & 1 deletion gio/src/auto/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl Application {

#[doc(alias = "g_application_get_default")]
#[doc(alias = "get_default")]
#[allow(clippy::should_implement_trait)]
pub fn default() -> Option<Application> {
unsafe { from_glib_none(ffi::g_application_get_default()) }
}
Expand Down Expand Up @@ -412,7 +413,7 @@ impl<O: IsA<Application>> ApplicationExt for O {
}

fn open(&self, files: &[File], hint: &str) {
let n_files = files.len() as i32;
let n_files = files.len() as _;
unsafe {
ffi::g_application_open(
self.as_ref().to_glib_none().0,
Expand Down
Loading