From 8019dd7f8a91a5dfd71619495040b2e722c05e93 Mon Sep 17 00:00:00 2001 From: Abdul Rahman Sibahi Date: Fri, 12 Apr 2024 15:16:09 +0300 Subject: [PATCH] clippy fixes + comment out CORETEXT flag to make it compile on aarch64 --- build.rs | 14 +++++++------- src/blob.rs | 3 +-- src/buffer.rs | 9 ++------- src/common.rs | 1 - src/face.rs | 5 ++--- src/font.rs | 3 +-- 6 files changed, 13 insertions(+), 22 deletions(-) diff --git a/build.rs b/build.rs index 0b1e14e..d6bb92c 100644 --- a/build.rs +++ b/build.rs @@ -10,10 +10,10 @@ fn main() { let target = env::var("TARGET").unwrap(); println!("cargo:rerun-if-env-changed=HARFBUZZ_SYS_NO_PKG_CONFIG"); - if target.contains("wasm32") || env::var_os("HARFBUZZ_SYS_NO_PKG_CONFIG").is_none() { - if pkg_config::probe_library("harfbuzz").is_ok() { - return; - } + if (target.contains("wasm32") || env::var_os("HARFBUZZ_SYS_NO_PKG_CONFIG").is_none()) + && pkg_config::probe_library("harfbuzz").is_ok() + { + return; } let mut cfg = cc::Build::new(); @@ -27,9 +27,9 @@ fn main() { cfg.define("HAVE_PTHREAD", "1"); } - if target.contains("apple") { - cfg.define("HAVE_CORETEXT", "1"); - } + // if target.contains("apple") { + // cfg.define("HAVE_CORETEXT", "1"); + // } if target.contains("windows-gnu") { cfg.flag("-Wa,-mbig-obj"); diff --git a/src/blob.rs b/src/blob.rs index 02230b0..c34ae1e 100644 --- a/src/blob.rs +++ b/src/blob.rs @@ -1,6 +1,5 @@ use std::os::raw::c_void; -use std; use std::marker::PhantomData; use std::fmt; @@ -89,7 +88,7 @@ impl<'a> Blob<'a> { let data = Box::into_raw(boxxed); extern "C" fn destroy(ptr: *mut c_void) { - unsafe { Box::from_raw(ptr as *mut U) }; + _ = unsafe { Box::from_raw(ptr as *mut U) }; } let hb_blob = unsafe { diff --git a/src/buffer.rs b/src/buffer.rs index 52b8c08..96bce14 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -159,8 +159,9 @@ impl GlyphInfo { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Hash)] pub enum ClusterLevel { + #[default] MonotoneGraphemes, MonotoneCharacters, Characters, @@ -185,12 +186,6 @@ impl ClusterLevel { } } -impl Default for ClusterLevel { - fn default() -> Self { - ClusterLevel::MonotoneGraphemes - } -} - #[derive(Debug)] pub(crate) struct GenericBuffer { raw: NonNull, diff --git a/src/common.rs b/src/common.rs index d899b58..2b082ce 100644 --- a/src/common.rs +++ b/src/common.rs @@ -112,7 +112,6 @@ pub enum TagFromStrErr { ZeroLengthString, } -use std; use std::str::FromStr; impl FromStr for Tag { diff --git a/src/face.rs b/src/face.rs index 08cc649..8498d73 100644 --- a/src/face.rs +++ b/src/face.rs @@ -1,4 +1,3 @@ -use std; use std::os::raw::c_void; use std::ptr::NonNull; @@ -56,7 +55,7 @@ impl<'a> Face<'a> { /// Create a face from the bytes of a given slice and an index specifying /// which font to read from an OpenType font collection. - pub fn from_bytes<'b>(bytes: &'b [u8], index: u32) -> Owned> { + pub fn from_bytes(bytes: &[u8], index: u32) -> Owned> { let blob = Blob::with_bytes(bytes); Face::new(blob, index) } @@ -68,7 +67,7 @@ impl<'a> Face<'a> { F: 'b + Send + Sync + FnMut(Tag) -> Option>>, { extern "C" fn destroy_box(ptr: *mut c_void) { - unsafe { Box::from_raw(ptr as *mut U) }; + _ = unsafe { Box::from_raw(ptr as *mut U) }; } extern "C" fn table_func<'b, F>( _: *mut hb_face_t, diff --git a/src/font.rs b/src/font.rs index 5e794d2..54510ac 100644 --- a/src/font.rs +++ b/src/font.rs @@ -1,4 +1,3 @@ -use std; use std::ptr::NonNull; use std::os::raw::c_void; @@ -58,7 +57,7 @@ impl FontExtents { pub type GlyphExtents = hb_glyph_extents_t; pub(crate) extern "C" fn destroy_box(ptr: *mut c_void) { - unsafe { Box::from_raw(ptr as *mut U) }; + _ = unsafe { Box::from_raw(ptr as *mut U) }; } /// A type representing a single font (i.e. a specific combination of typeface,