From 4154537176a3ab6f665b1bc9d5581e15e009ed19 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Mon, 16 Dec 2024 23:42:00 -0500 Subject: [PATCH] Fix and un-allow `clippy::use_self` lints (#235) --- fontique/src/generic.rs | 28 ++++++++++++++-------------- fontique/src/lib.rs | 1 - fontique/src/script.rs | 2 +- parley/src/layout/cursor.rs | 2 +- parley/src/lib.rs | 1 - parley/src/tests/utils/env.rs | 2 +- 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/fontique/src/generic.rs b/fontique/src/generic.rs index 447900ec..c8c6608f 100644 --- a/fontique/src/generic.rs +++ b/fontique/src/generic.rs @@ -84,21 +84,21 @@ impl GenericFamily { } /// Returns a slice containing all generic family variants. - pub const fn all() -> &'static [GenericFamily] { + pub const fn all() -> &'static [Self] { &[ - GenericFamily::SansSerif, - GenericFamily::Serif, - GenericFamily::Monospace, - GenericFamily::Cursive, - GenericFamily::Fantasy, - GenericFamily::SystemUi, - GenericFamily::UiSerif, - GenericFamily::UiSansSerif, - GenericFamily::UiMonospace, - GenericFamily::UiRounded, - GenericFamily::Emoji, - GenericFamily::Math, - GenericFamily::FangSong, + Self::SansSerif, + Self::Serif, + Self::Monospace, + Self::Cursive, + Self::Fantasy, + Self::SystemUi, + Self::UiSerif, + Self::UiSansSerif, + Self::UiMonospace, + Self::UiRounded, + Self::Emoji, + Self::Math, + Self::FangSong, ] } } diff --git a/fontique/src/lib.rs b/fontique/src/lib.rs index d85fbfb6..d8734ac8 100644 --- a/fontique/src/lib.rs +++ b/fontique/src/lib.rs @@ -21,7 +21,6 @@ #![allow(clippy::exhaustive_enums)] #![allow(clippy::partial_pub_fields)] #![allow(clippy::shadow_unrelated)] -#![allow(clippy::use_self)] #[cfg(not(any(feature = "std", feature = "libm")))] compile_error!("fontique requires either the `std` or `libm` feature to be enabled"); diff --git a/fontique/src/script.rs b/fontique/src/script.rs index 3bbb6d80..cab4dabd 100644 --- a/fontique/src/script.rs +++ b/fontique/src/script.rs @@ -17,7 +17,7 @@ pub struct Script(pub [u8; 4]); impl Script { /// Returns a mapping of scripts to sample text. - pub fn all_samples() -> &'static [(Script, &'static str)] { + pub fn all_samples() -> &'static [(Self, &'static str)] { SCRIPT_SAMPLES } diff --git a/parley/src/layout/cursor.rs b/parley/src/layout/cursor.rs index 614e23bd..a60784c2 100644 --- a/parley/src/layout/cursor.rs +++ b/parley/src/layout/cursor.rs @@ -479,7 +479,7 @@ impl Selection { /// Creates a new selection bounding the line at the given coordinates. pub fn line_from_point(layout: &Layout, x: f32, y: f32) -> Self { - let Selection { anchor, focus, .. } = Self::from_point(layout, x, y) + let Self { anchor, focus, .. } = Self::from_point(layout, x, y) .line_start(layout, false) .line_end(layout, true); Self { diff --git a/parley/src/lib.rs b/parley/src/lib.rs index 251ccd60..5d9a5e35 100644 --- a/parley/src/lib.rs +++ b/parley/src/lib.rs @@ -90,7 +90,6 @@ #![allow(clippy::missing_assert_message)] #![allow(clippy::missing_panics_doc)] #![allow(clippy::shadow_unrelated)] -#![allow(clippy::use_self)] #[cfg(not(any(feature = "std", feature = "libm")))] compile_error!("parley requires either the `std` or `libm` feature to be enabled"); diff --git a/parley/src/tests/utils/env.rs b/parley/src/tests/utils/env.rs index e0721d3b..180130a8 100644 --- a/parley/src/tests/utils/env.rs +++ b/parley/src/tests/utils/env.rs @@ -115,7 +115,7 @@ impl TestEnv { collection .family_id(DEFAULT_FONT_NAME) .unwrap_or_else(|| panic!("{} font not found", DEFAULT_FONT_NAME)); - TestEnv { + Self { test_name: test_name.to_string(), check_counter: 0, font_cx: FontContext {