Skip to content

Commit

Permalink
Satisfy clippy 1.63 (#2244)
Browse files Browse the repository at this point in the history
  • Loading branch information
xStrom committed Aug 16, 2022
1 parent 3269a69 commit df5783a
Show file tree
Hide file tree
Showing 22 changed files with 40 additions and 32 deletions.
7 changes: 6 additions & 1 deletion clippy.toml
Expand Up @@ -2,4 +2,9 @@
# Given that druid is being designed for the future and already even mobile phones have 64-bit CPUs,
# it makes sense to optimize for 64-bit and accept the performance hits on 32-bit.
# 16 bytes is the number of bytes that fits into two 64-bit CPU registers.
trivial-copy-size-limit = 16
trivial-copy-size-limit = 16

# The default clippy value for this is 250, which causes warnings for rather simple types
# like Box<dyn Fn(&mut Env, &T)>, which seems overly strict. The new value of 400 is
# a simple guess. It might be worth lowering this, or using the default, in the future.
type-complexity-threshold = 400
2 changes: 1 addition & 1 deletion druid-derive/src/attr.rs
Expand Up @@ -68,7 +68,7 @@ pub struct Field<Attrs> {
pub attrs: Attrs,
}

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum DataAttr {
Empty,
Ignore,
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/backend/gtk/window.rs
Expand Up @@ -216,7 +216,7 @@ impl std::fmt::Debug for WindowState {
}
}

#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq)]
pub struct CustomCursor(gtk::gdk::Cursor);

impl WindowBuilder {
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/backend/mac/window.rs
Expand Up @@ -180,7 +180,7 @@ struct ViewState {
parent: Option<crate::WindowHandle>,
}

#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq)]
// TODO: support custom cursors
pub struct CustomCursor;

Expand Down
4 changes: 2 additions & 2 deletions druid-shell/src/backend/wayland/pointers.rs
Expand Up @@ -201,7 +201,7 @@ impl Pointer {

fn get_cursor_buffer(&self, cursor: &mouse::Cursor) -> Option<CursorImageBuffer> {
#[allow(deprecated)]
return match cursor {
match cursor {
mouse::Cursor::Arrow => self.unpack_image_buffer("left_ptr"),
mouse::Cursor::IBeam => self.unpack_image_buffer("xterm"),
mouse::Cursor::Crosshair => self.unpack_image_buffer("cross"),
Expand All @@ -214,7 +214,7 @@ impl Pointer {
tracing::warn!("custom cursors not implemented");
self.unpack_image_buffer("left_ptr")
}
};
}
}

// Just use the first image, people using animated cursors have already made bad life
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/backend/wayland/surfaces/buffers.rs
Expand Up @@ -526,7 +526,7 @@ impl Drop for Mmap {
}
}
}
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct RawSize {
pub width: i32,
pub height: i32,
Expand Down
4 changes: 3 additions & 1 deletion druid-shell/src/backend/wayland/window.rs
Expand Up @@ -293,6 +293,8 @@ impl std::cmp::PartialEq for WindowHandle {
}
}

impl Eq for WindowHandle {}

impl std::default::Default for WindowHandle {
fn default() -> WindowHandle {
WindowHandle {
Expand All @@ -316,7 +318,7 @@ unsafe impl HasRawWindowHandle for WindowHandle {
}
}

#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq)]
pub struct CustomCursor;

/// Builder abstraction for creating new windows
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/backend/web/window.rs
Expand Up @@ -127,7 +127,7 @@ struct WindowState {
}

// TODO: support custom cursors
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq)]
pub struct CustomCursor;

impl WindowState {
Expand Down
4 changes: 2 additions & 2 deletions druid-shell/src/backend/windows/window.rs
Expand Up @@ -302,10 +302,10 @@ struct DxgiState {
composition_visual: Option<ComPtr<IDCompositionVisual>>,
}

#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq)]
pub struct CustomCursor(Arc<HCursor>);

#[derive(PartialEq)]
#[derive(PartialEq, Eq)]
struct HCursor(HCURSOR);

impl Drop for HCursor {
Expand Down
4 changes: 2 additions & 2 deletions druid-shell/src/backend/x11/window.rs
Expand Up @@ -397,7 +397,7 @@ impl WindowBuilder {
let mut wm_class = Vec::with_capacity(2 * (name.len() + 1));
wm_class.extend(name.as_bytes());
wm_class.push(0);
if let Some(&first) = wm_class.get(0) {
if let Some(&first) = wm_class.first() {
wm_class.push(first.to_ascii_uppercase());
wm_class.extend(&name.as_bytes()[1..]);
}
Expand Down Expand Up @@ -662,7 +662,7 @@ struct PresentData {
last_ust: Option<u64>,
}

#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq)]
pub struct CustomCursor(xproto::Cursor);

impl Window {
Expand Down
4 changes: 2 additions & 2 deletions druid-shell/src/dialog.rs
Expand Up @@ -41,7 +41,7 @@ pub struct FileInfo {
all(feature = "x11", any(target_os = "linux", target_os = "openbsd")),
feature = "wayland"
)))]
#[derive(Clone, Copy, PartialEq)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum FileDialogType {
/// File open dialog.
Open,
Expand Down Expand Up @@ -164,7 +164,7 @@ pub struct FileDialogOptions {
///
/// [`COMDLG_FILTERSPEC`]: https://docs.microsoft.com/en-ca/windows/win32/api/shtypes/ns-shtypes-comdlg_filterspec
/// [packages]: struct.FileDialogOptions.html#packages
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct FileSpec {
/// A human readable name, describing this filetype.
///
Expand Down
4 changes: 2 additions & 2 deletions druid-shell/src/hotkey.rs
Expand Up @@ -55,7 +55,7 @@ use crate::{IntoKey, KbKey, KeyEvent, Modifiers};
/// ```
///
/// [`SysMods`]: enum.SysMods.html
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HotKey {
pub(crate) mods: RawMods,
pub(crate) key: KbKey,
Expand Down Expand Up @@ -140,7 +140,7 @@ pub enum SysMods {
/// A representation of the active modifier keys.
///
/// This is intended to be clearer than `Modifiers`, when describing hotkeys.
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RawMods {
None,
Alt,
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/mouse.rs
Expand Up @@ -248,7 +248,7 @@ impl std::fmt::Debug for MouseButtons {
//NOTE: this currently only contains cursors that are included by default on
//both Windows and macOS. We may want to provide polyfills for various additional cursors.
/// Mouse cursors.
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq)]
pub enum Cursor {
/// The default arrow cursor.
Arrow,
Expand Down
6 changes: 3 additions & 3 deletions druid-shell/src/window.rs
Expand Up @@ -148,7 +148,7 @@ impl FileDialogToken {
/// Levels in the window system - Z order for display purposes.
/// Describes the purpose of a window and should be mapped appropriately to match platform
/// conventions.
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq)]
pub enum WindowLevel {
/// A top level app window.
AppWindow,
Expand All @@ -161,15 +161,15 @@ pub enum WindowLevel {
}

/// Contains the different states a Window can be in.
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WindowState {
Maximized,
Minimized,
Restored,
}

/// A handle to a platform window object.
#[derive(Clone, Default, PartialEq)]
#[derive(Clone, Default, PartialEq, Eq)]
pub struct WindowHandle(pub(crate) backend::WindowHandle);

impl WindowHandle {
Expand Down
2 changes: 1 addition & 1 deletion druid/src/app.rs
Expand Up @@ -40,7 +40,7 @@ pub struct AppLauncher<T> {
}

/// Defines how a windows size should be determined
#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum WindowSizePolicy {
/// Use the content of the window to determine the size.
///
Expand Down
2 changes: 1 addition & 1 deletion druid/src/command.rs
Expand Up @@ -138,7 +138,7 @@ pub struct SingleUse<T>(Mutex<Option<T>>);
/// The target of a [`Command`].
///
/// [`Command`]: struct.Command.html
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Target {
/// The target is the top-level application.
///
Expand Down
4 changes: 2 additions & 2 deletions druid/src/env.rs
Expand Up @@ -87,7 +87,7 @@ struct EnvImpl {
///
/// [`ValueType`]: trait.ValueType.html
/// [`Env`]: struct.Env.html
#[derive(Clone, Debug, PartialEq, Data)]
#[derive(Clone, Debug, PartialEq, Eq, Data)]
pub struct Key<T> {
key: &'static str,
value_type: PhantomData<T>,
Expand Down Expand Up @@ -120,7 +120,7 @@ pub enum Value {
///
/// [`Key<T>`]: struct.Key.html
/// [`Env`]: struct.Env.html
#[derive(Clone, PartialEq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum KeyOrValue<T> {
/// A concrete [`Value`] of type `T`.
///
Expand Down
1 change: 1 addition & 0 deletions druid/src/lib.rs
Expand Up @@ -133,6 +133,7 @@
)]
#![warn(missing_docs)]
#![allow(clippy::new_ret_no_self, clippy::needless_doctest_main)]
#![allow(clippy::duplicate_mod)] // TODO: Remove this after the text/mod.rs format_priv hack has been removed (0.8.0+)
#![cfg_attr(docsrs, feature(doc_cfg))]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/linebender/druid/screenshots/images/doc_logo.png"
Expand Down
2 changes: 1 addition & 1 deletion druid/src/widget/common.rs
Expand Up @@ -16,7 +16,7 @@ use crate::{Affine, Data, Size};

// These are based on https://api.flutter.dev/flutter/painting/BoxFit-class.html
/// Strategies for inscribing a rectangle inside another rectangle.
#[derive(Clone, Data, Copy, PartialEq)]
#[derive(Clone, Data, Copy, PartialEq, Eq)]
pub enum FillStrat {
/// As large as possible without changing aspect ratio of image and all of image shown
Contain,
Expand Down
6 changes: 3 additions & 3 deletions druid/src/widget/flex.rs
Expand Up @@ -189,7 +189,7 @@ pub struct FlexParams {
/// Most often used by widgets to describe
/// the direction in which they grow as their number of children increases.
/// Has some methods for manipulating geometry with respect to the axis.
#[derive(Data, Debug, Clone, Copy, PartialEq)]
#[derive(Data, Debug, Clone, Copy, PartialEq, Eq)]
pub enum Axis {
/// The x axis
Horizontal,
Expand Down Expand Up @@ -291,7 +291,7 @@ impl Axis {
///
/// If a widget is smaller than the container on the minor axis, this determines
/// where it is positioned.
#[derive(Debug, Clone, Copy, PartialEq, Data)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Data)]
pub enum CrossAxisAlignment {
/// Top or leading.
///
Expand Down Expand Up @@ -323,7 +323,7 @@ pub enum CrossAxisAlignment {
///
/// If there is surplus space on the main axis after laying out children, this
/// enum represents how children are laid out in this space.
#[derive(Debug, Clone, Copy, PartialEq, Data)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Data)]
pub enum MainAxisAlignment {
/// Top or leading.
///
Expand Down
2 changes: 1 addition & 1 deletion druid/src/widget/label.rs
Expand Up @@ -103,7 +103,7 @@ pub struct RawLabel<T> {
}

/// Options for handling lines that are too wide for the label.
#[derive(Debug, Clone, Copy, PartialEq, Data)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Data)]
pub enum LineBreaking {
/// Lines are broken at word boundaries.
WordWrap,
Expand Down
4 changes: 2 additions & 2 deletions druid/src/widget/tabs.rs
Expand Up @@ -754,7 +754,7 @@ impl<TP: TabsPolicy> ScopePolicy for TabsScopePolicy<TP> {
}

/// Determines whether the tabs will have a transition animation when a new tab is selected.
#[derive(Data, Copy, Clone, Debug, PartialOrd, PartialEq)]
#[derive(Data, Copy, Clone, Debug, PartialOrd, PartialEq, Eq)]
pub enum TabsTransition {
/// Change tabs instantly with no animation
Instant,
Expand All @@ -778,7 +778,7 @@ impl TabsTransition {
}

/// Determines where the tab bar should be placed relative to the cross axis
#[derive(Debug, Copy, Clone, PartialEq, Data)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Data)]
pub enum TabsEdge {
/// For horizontal tabs, top. For vertical tabs, left.
Leading,
Expand Down

0 comments on commit df5783a

Please sign in to comment.