Skip to content

Commit

Permalink
fix a bunch of lints
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Jun 26, 2024
1 parent 6383d4f commit 4a974d7
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
1 change: 0 additions & 1 deletion site/src/editor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion site/src/editor/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub struct State {
pub curr: Record,
pub challenge: Option<ChallengeDef>,
pub loading_module: bool,
pub min_height: String,
}

/// A record of a code change
Expand Down
2 changes: 1 addition & 1 deletion src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ impl<T: Clone> Array<T> {
U: Clone + 'static,
{
if TypeId::of::<T>() == TypeId::of::<U>() {
unsafe { std::mem::transmute(self) }
unsafe { std::mem::transmute::<Array<T>, Array<U>>(self) }
} else {
self.convert_with(Into::into)
}
Expand Down
12 changes: 9 additions & 3 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,23 +1135,29 @@ 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));
}
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)?);
}
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
Expand Down
7 changes: 2 additions & 5 deletions src/grid_fmt.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
//! Pretty printing Uiua arrays

use std::{
f64::{
consts::{PI, TAU},
INFINITY,
},
f64::consts::{PI, TAU},
iter::once,
mem::take,
};
Expand Down Expand Up @@ -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!['⋅']];
Expand Down
2 changes: 1 addition & 1 deletion src/primitive/defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions src/primitive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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,
}
}
Expand Down

0 comments on commit 4a974d7

Please sign in to comment.