From a57f2c38680c83f8802120cfbf0cb021db2a6aef Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Mon, 1 Apr 2024 16:24:29 +0200 Subject: [PATCH] Fix nightly clippy warnings --- gdk4-x11/src/functions.rs | 2 +- gdk4-x11/src/x11_display.rs | 2 +- gdk4/src/content_formats_builder.rs | 2 +- gdk4/src/display.rs | 22 +++++++++----------- gdk4/src/rgba.rs | 2 +- gsk4/src/transform.rs | 2 +- gtk4-macros/src/attribute_parser.rs | 12 +++-------- gtk4-macros/src/composite_template_derive.rs | 1 - gtk4/src/application.rs | 2 +- gtk4/src/builder.rs | 2 +- gtk4/src/dialog.rs | 2 +- gtk4/src/entry.rs | 2 -- gtk4/src/entry_buffer.rs | 2 +- gtk4/src/file_chooser.rs | 3 +-- gtk4/src/file_chooser_dialog.rs | 2 +- gtk4/src/icon_theme.rs | 2 +- gtk4/src/message_dialog.rs | 7 +++---- gtk4/src/response_type.rs | 6 +----- gtk4/src/snapshot.rs | 2 +- gtk4/src/string_list.rs | 2 -- gtk4/src/text.rs | 2 +- 21 files changed, 31 insertions(+), 50 deletions(-) diff --git a/gdk4-x11/src/functions.rs b/gdk4-x11/src/functions.rs index 852c82229ac7..fc34f03df142 100644 --- a/gdk4-x11/src/functions.rs +++ b/gdk4-x11/src/functions.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use glib::{translate::*, IntoGStr}; +use glib::translate::*; #[cfg(feature = "xlib")] #[cfg_attr(docsrs, doc(cfg(feature = "xlib")))] use x11::xlib::Atom as XAtom; diff --git a/gdk4-x11/src/x11_display.rs b/gdk4-x11/src/x11_display.rs index 63443439d0ed..723dc0339961 100644 --- a/gdk4-x11/src/x11_display.rs +++ b/gdk4-x11/src/x11_display.rs @@ -7,7 +7,7 @@ use std::{boxed::Box as Box_, mem::transmute}; #[cfg(feature = "xlib")] #[cfg_attr(docsrs, doc(cfg(feature = "xlib")))] use glib::signal::{connect_raw, SignalHandlerId}; -use glib::{translate::*, IntoGStr}; +use glib::translate::*; #[cfg(all(feature = "v4_4", feature = "egl"))] #[cfg_attr(docsrs, doc(cfg(all(feature = "v4_4", feature = "egl"))))] use khronos_egl as egl; diff --git a/gdk4/src/content_formats_builder.rs b/gdk4/src/content_formats_builder.rs index 98d314fd128a..1365953aa0da 100644 --- a/gdk4/src/content_formats_builder.rs +++ b/gdk4/src/content_formats_builder.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use glib::{translate::*, IntoGStr}; +use glib::translate::*; use crate::{ContentFormats, ContentFormatsBuilder}; diff --git a/gdk4/src/display.rs b/gdk4/src/display.rs index 729cb655ac97..3639dbc21a0a 100644 --- a/gdk4/src/display.rs +++ b/gdk4/src/display.rs @@ -1,8 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use std::{mem, ptr}; - -use glib::{translate::*, IntoGStr}; +use glib::translate::*; use crate::{prelude::*, Display, Key, KeymapKey, ModifierType}; @@ -69,10 +67,10 @@ pub trait DisplayExtManual: sealed::Sealed + IsA + 'static { group: i32, ) -> Option<(Key, i32, i32, ModifierType)> { unsafe { - let mut keyval = mem::MaybeUninit::uninit(); - let mut effective_group = mem::MaybeUninit::uninit(); - let mut level = mem::MaybeUninit::uninit(); - let mut consumed = mem::MaybeUninit::uninit(); + let mut keyval = std::mem::MaybeUninit::uninit(); + let mut effective_group = std::mem::MaybeUninit::uninit(); + let mut level = std::mem::MaybeUninit::uninit(); + let mut consumed = std::mem::MaybeUninit::uninit(); let ret = from_glib(ffi::gdk_display_translate_key( self.as_ref().to_glib_none().0, keycode, @@ -122,8 +120,8 @@ pub trait DisplayExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "gdk_display_map_keyval")] fn map_keyval(&self, keyval: Key) -> Option> { unsafe { - let mut keys = ptr::null_mut(); - let mut n_keys = mem::MaybeUninit::uninit(); + let mut keys = std::ptr::null_mut(); + let mut n_keys = std::mem::MaybeUninit::uninit(); let ret = from_glib(ffi::gdk_display_map_keyval( self.as_ref().to_glib_none().0, keyval.into_glib(), @@ -144,9 +142,9 @@ pub trait DisplayExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "gdk_display_map_keycode")] fn map_keycode(&self, keycode: u32) -> Option> { unsafe { - let mut keys = ptr::null_mut(); - let mut keyvals = ptr::null_mut(); - let mut n_entries = mem::MaybeUninit::uninit(); + let mut keys = std::ptr::null_mut(); + let mut keyvals = std::ptr::null_mut(); + let mut n_entries = std::mem::MaybeUninit::uninit(); let ret = from_glib(ffi::gdk_display_map_keycode( self.as_ref().to_glib_none().0, keycode, diff --git a/gdk4/src/rgba.rs b/gdk4/src/rgba.rs index c16981f778eb..f3266a56b801 100644 --- a/gdk4/src/rgba.rs +++ b/gdk4/src/rgba.rs @@ -2,7 +2,7 @@ use std::{fmt, str::FromStr}; -use glib::{translate::*, IntoGStr}; +use glib::translate::*; use crate::RGBA; diff --git a/gsk4/src/transform.rs b/gsk4/src/transform.rs index e464538db71f..bdb214a52c9c 100644 --- a/gsk4/src/transform.rs +++ b/gsk4/src/transform.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use glib::{translate::*, IntoGStr}; +use glib::translate::*; use crate::Transform; diff --git a/gtk4-macros/src/attribute_parser.rs b/gtk4-macros/src/attribute_parser.rs index 13589b09b618..267efc50ecf3 100644 --- a/gtk4-macros/src/attribute_parser.rs +++ b/gtk4-macros/src/attribute_parser.rs @@ -136,6 +136,8 @@ fn parse_attribute(meta: &NestedMeta) -> Result<(String, String)> { } pub enum FieldAttributeArg { + #[allow(dead_code)] + // The span is needed for xml_validation feature Id(String, Span), Internal(bool), } @@ -148,8 +150,6 @@ pub enum FieldAttributeType { pub struct FieldAttribute { pub ty: FieldAttributeType, pub args: Vec, - pub path_span: Span, - pub span: Span, } pub struct AttributedField { @@ -292,7 +292,6 @@ fn parse_field(field: &Field) -> Result, Error> { for field_attr in field_attrs { let span = field_attr.span(); - let path_span = field_attr.path.span(); let ty = if field_attr.path.is_ident("template_child") { Some(FieldAttributeType::TemplateChild) } else { @@ -303,12 +302,7 @@ fn parse_field(field: &Field) -> Result, Error> { let args = parse_field_attr_args(&ty, field_attr)?; if attr.is_none() { - attr = Some(FieldAttribute { - ty, - args, - path_span, - span, - }) + attr = Some(FieldAttribute { ty, args }) } else { return Err(Error::new( span, diff --git a/gtk4-macros/src/composite_template_derive.rs b/gtk4-macros/src/composite_template_derive.rs index 94db95677139..ed05ec13973a 100644 --- a/gtk4-macros/src/composite_template_derive.rs +++ b/gtk4-macros/src/composite_template_derive.rs @@ -2,7 +2,6 @@ #[cfg(feature = "xml_validation")] use std::collections::HashMap; -use std::string::ToString; use proc_macro2::TokenStream; use proc_macro_error::{emit_call_site_error, emit_error}; diff --git a/gtk4/src/application.rs b/gtk4/src/application.rs index 405b9ec3e26d..9f72e4678955 100644 --- a/gtk4/src/application.rs +++ b/gtk4/src/application.rs @@ -3,7 +3,7 @@ use std::{cell::RefCell, rc::Rc}; use gio::ApplicationFlags; -use glib::{signal::SignalHandlerId, translate::*, IntoOptionalGStr}; +use glib::{signal::SignalHandlerId, translate::*}; use crate::{prelude::*, rt, Application}; diff --git a/gtk4/src/builder.rs b/gtk4/src/builder.rs index 7622a9eb78dc..5aa6c398c9d6 100644 --- a/gtk4/src/builder.rs +++ b/gtk4/src/builder.rs @@ -2,7 +2,7 @@ use std::path::Path; -use glib::{translate::*, IntoGStr, Object}; +use glib::{translate::*, Object}; use crate::{prelude::*, Builder}; diff --git a/gtk4/src/dialog.rs b/gtk4/src/dialog.rs index b02b6c579486..3d77806b20f5 100644 --- a/gtk4/src/dialog.rs +++ b/gtk4/src/dialog.rs @@ -8,7 +8,7 @@ use std::{ rc::Rc, }; -use glib::{translate::*, IntoOptionalGStr}; +use glib::translate::*; use crate::{prelude::*, Dialog, DialogFlags, ResponseType, Widget, Window}; diff --git a/gtk4/src/entry.rs b/gtk4/src/entry.rs index 10ba80978562..05bcc621d0a4 100644 --- a/gtk4/src/entry.rs +++ b/gtk4/src/entry.rs @@ -1,7 +1,5 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use std::convert::TryFrom; - use glib::translate::*; use crate::{prelude::*, Entry}; diff --git a/gtk4/src/entry_buffer.rs b/gtk4/src/entry_buffer.rs index 775491710a1f..c61a27683199 100644 --- a/gtk4/src/entry_buffer.rs +++ b/gtk4/src/entry_buffer.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use glib::{translate::*, GString, IntoGStr, IntoOptionalGStr}; +use glib::{translate::*, GString}; use libc::{c_int, c_uint}; use crate::{prelude::*, EntryBuffer}; diff --git a/gtk4/src/file_chooser.rs b/gtk4/src/file_chooser.rs index fe4cbadaafd0..210d02791c92 100644 --- a/gtk4/src/file_chooser.rs +++ b/gtk4/src/file_chooser.rs @@ -1,8 +1,7 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use glib::{translate::*, IntoGStr}; - use crate::{prelude::*, FileChooser}; +use glib::translate::*; mod sealed { pub trait Sealed {} diff --git a/gtk4/src/file_chooser_dialog.rs b/gtk4/src/file_chooser_dialog.rs index 2ed4025987e9..f7276f4a92d7 100644 --- a/gtk4/src/file_chooser_dialog.rs +++ b/gtk4/src/file_chooser_dialog.rs @@ -2,7 +2,7 @@ use std::ptr; -use glib::{translate::*, IntoOptionalGStr}; +use glib::translate::*; use libc::c_char; use crate::{prelude::*, FileChooserAction, FileChooserDialog, ResponseType, Widget, Window}; diff --git a/gtk4/src/icon_theme.rs b/gtk4/src/icon_theme.rs index 9ecf18d3ebfb..716c5f5e48f2 100644 --- a/gtk4/src/icon_theme.rs +++ b/gtk4/src/icon_theme.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use glib::{translate::*, IntoGStr, Slice}; +use glib::{translate::*, Slice}; use crate::IconTheme; diff --git a/gtk4/src/message_dialog.rs b/gtk4/src/message_dialog.rs index 525fcc0ef27f..1fd0b7acf23e 100644 --- a/gtk4/src/message_dialog.rs +++ b/gtk4/src/message_dialog.rs @@ -2,8 +2,7 @@ use std::ptr; -use glib::{translate::*, IntoGStr, IntoOptionalGStr}; -use libc::c_char; +use glib::translate::*; use crate::{prelude::*, ButtonsType, DialogFlags, MessageDialog, MessageType, Widget, Window}; @@ -26,9 +25,9 @@ impl MessageDialog { flags.into_glib(), type_.into_glib(), buttons.into_glib(), - b"%s\0".as_ptr() as *const c_char, + b"%s\0".as_ptr() as *const libc::c_char, message.as_ptr(), - ptr::null::(), + ptr::null::(), )) .unsafe_cast() }) diff --git a/gtk4/src/response_type.rs b/gtk4/src/response_type.rs index ea2953bbc6a2..874284112b0a 100644 --- a/gtk4/src/response_type.rs +++ b/gtk4/src/response_type.rs @@ -3,11 +3,7 @@ use std::fmt; use crate::prelude::*; -use glib::{ - translate::*, - value::{FromValue, ValueType}, - Type, Value, -}; +use glib::{translate::*, value::FromValue, Type, Value}; #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] #[doc(alias = "GtkResponseType")] diff --git a/gtk4/src/snapshot.rs b/gtk4/src/snapshot.rs index 95580f2e4567..1b3735d42445 100644 --- a/gtk4/src/snapshot.rs +++ b/gtk4/src/snapshot.rs @@ -2,7 +2,7 @@ use std::borrow::Borrow; -use glib::{translate::*, IntoGStr}; +use glib::translate::*; use crate::{prelude::*, Snapshot}; diff --git a/gtk4/src/string_list.rs b/gtk4/src/string_list.rs index 0f8a792209a9..404ca2a3dd77 100644 --- a/gtk4/src/string_list.rs +++ b/gtk4/src/string_list.rs @@ -1,7 +1,5 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use std::iter::FromIterator; - use crate::{prelude::*, StringList}; impl FromIterator<&'static str> for StringList { diff --git a/gtk4/src/text.rs b/gtk4/src/text.rs index 9b0bbc7feae9..012b98c73304 100644 --- a/gtk4/src/text.rs +++ b/gtk4/src/text.rs @@ -5,7 +5,7 @@ use std::mem::transmute; use glib::{ signal::{connect_raw, SignalHandlerId}, translate::*, - GString, IntoGStr, + GString, }; use crate::{prelude::*, DeleteType, MovementStep, Text, Widget};