From 4a974d7d8ef6e6919d53e451fa90fe777bb22f28 Mon Sep 17 00:00:00 2001 From: Kai Schmidt Date: Wed, 26 Jun 2024 10:11:46 -0700 Subject: [PATCH] fix a bunch of lints --- site/src/editor/mod.rs | 1 - site/src/editor/utils.rs | 1 - src/array.rs | 2 +- src/ffi.rs | 12 +++++++++--- src/grid_fmt.rs | 7 ++----- src/primitive/defs.rs | 2 +- src/primitive/mod.rs | 9 +++------ 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/site/src/editor/mod.rs b/site/src/editor/mod.rs index 966439a4..521f16bb 100644 --- a/site/src/editor/mod.rs +++ b/site/src/editor/mod.rs @@ -133,7 +133,6 @@ pub fn Editor<'a>( future: Vec::new(), challenge, loading_module: false, - min_height: format!("{code_height_em}em"), curr: { let code = initial_code.get_untracked().unwrap(); let len = code.chars().count() as u32; diff --git a/site/src/editor/utils.rs b/site/src/editor/utils.rs index b7d100dd..fc76f641 100644 --- a/site/src/editor/utils.rs +++ b/site/src/editor/utils.rs @@ -44,7 +44,6 @@ pub struct State { pub curr: Record, pub challenge: Option, pub loading_module: bool, - pub min_height: String, } /// A record of a code change diff --git a/src/array.rs b/src/array.rs index dc973476..19232905 100644 --- a/src/array.rs +++ b/src/array.rs @@ -514,7 +514,7 @@ impl Array { U: Clone + 'static, { if TypeId::of::() == TypeId::of::() { - unsafe { std::mem::transmute(self) } + unsafe { std::mem::transmute::, Array>(self) } } else { self.convert_with(Into::into) } diff --git a/src/ffi.rs b/src/ffi.rs index d4119bd7..d250bb15 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -1135,7 +1135,9 @@ mod enabled { bytes.copy_from_slice( &repr[offset..offset + size_of::<*const c_char>()], ); - let ptr = unsafe { transmute::<_, *const c_char>(bytes) }; + let ptr = unsafe { + transmute::<[u8; size_of::<*const c_char>()], *const c_char>(bytes) + }; let c_str = unsafe { CStr::from_ptr(ptr) }; let s = c_str.to_str().map_err(|e| e.to_string())?; rows.push(Value::from(s)); @@ -1143,7 +1145,9 @@ mod enabled { FfiType::Struct { fields } => { let mut bytes: [u8; size_of::<*const u8>()] = Default::default(); bytes.copy_from_slice(&repr[offset..offset + size_of::<*const u8>()]); - let ptr = unsafe { transmute::<_, *const u8>(bytes) }; + let ptr = unsafe { + transmute::<[u8; size_of::<*const u8>()], *const u8>(bytes) + }; let (size, _) = struct_fields_size_align(fields); let inner_repr = unsafe { slice::from_raw_parts(ptr, size) }; rows.push(self.struct_repr_to_value(inner_repr, fields)?); @@ -1151,7 +1155,9 @@ mod enabled { inner => { let mut bytes: [u8; size_of::<*const u8>()] = Default::default(); bytes.copy_from_slice(&repr[offset..offset + size_of::<*const u8>()]); - let ptr = unsafe { transmute::<_, *const u8>(bytes) }; + let ptr = unsafe { + transmute::<[u8; size_of::<*const u8>()], *const u8>(bytes) + }; let (size, _) = inner.size_align(); let inner_repr = unsafe { slice::from_raw_parts(ptr, size) }; let mut row = self diff --git a/src/grid_fmt.rs b/src/grid_fmt.rs index 81712e30..830edd96 100644 --- a/src/grid_fmt.rs +++ b/src/grid_fmt.rs @@ -1,10 +1,7 @@ //! Pretty printing Uiua arrays use std::{ - f64::{ - consts::{PI, TAU}, - INFINITY, - }, + f64::consts::{PI, TAU}, iter::once, mem::take, }; @@ -65,7 +62,7 @@ impl GridFmt for f64 { format!("{minus}τ") } else if (positive - PI / 2.0).abs() <= f64::EPSILON { format!("{minus}η") - } else if positive == INFINITY { + } else if positive == f64::INFINITY { format!("{minus}∞") } else if f.to_bits() == EMPTY_NAN.to_bits() || f.to_bits() == TOMBSTONE_NAN.to_bits() { return vec![vec!['⋅']]; diff --git a/src/primitive/defs.rs b/src/primitive/defs.rs index b923fae4..e447c248 100644 --- a/src/primitive/defs.rs +++ b/src/primitive/defs.rs @@ -106,7 +106,7 @@ constant!( /// The imaginary unit ("i", crate::Complex::I), /// IEEE 754-2008's `NaN` - ("NaN", std::f64::NAN), + ("NaN", f64::NAN), /// The wildcard `NaN` value that equals any other number ("W", WILDCARD_NAN), /// The maximum integer that can be represented exactly diff --git a/src/primitive/mod.rs b/src/primitive/mod.rs index 13552db4..d1896204 100644 --- a/src/primitive/mod.rs +++ b/src/primitive/mod.rs @@ -11,10 +11,7 @@ use std::{ borrow::{BorrowMut, Cow}, cell::RefCell, collections::HashMap, - f64::{ - consts::{PI, TAU}, - INFINITY, - }, + f64::consts::{PI, TAU}, fmt, sync::{ atomic::{self, AtomicUsize}, @@ -274,7 +271,7 @@ macro_rules! constant { constant!(eta, PI / 2.0); constant!(pi, PI); constant!(tau, TAU); -constant!(inf, INFINITY); +constant!(inf, f64::INFINITY); /// A wrapper that nicely prints a `Primitive` #[derive(Clone, Copy, PartialEq, Eq, Hash)] @@ -351,7 +348,7 @@ impl Primitive { Eta => Some(PI / 2.0), Pi => Some(PI), Tau => Some(TAU), - Infinity => Some(INFINITY), + Infinity => Some(f64::INFINITY), _ => None, } }