Skip to content

Commit 1f077f1

Browse files
committed
lint: fix clippy::pedantic (3 entries)
1 parent 0d43491 commit 1f077f1

File tree

12 files changed

+47
-24
lines changed

12 files changed

+47
-24
lines changed

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ print_stdout = "warn"
1717
print_stderr = "allow"
1818
dbg_macro = "warn"
1919
pedantic = {level = "warn", priority = -1}
20-
case_sensitive_file_extension_comparisons = "allow" # 3
21-
cloned_instead_of_copied = "allow" # 3
22-
ref_as_ptr = "allow" # 3
23-
unsafe_derive_deserialize = "allow" # 3
2420
doc_markdown = "allow" # 5
2521
match_wildcard_for_single_variants = "allow" # 5
2622
needless_continue = "allow" # 5

pad/editor/src/backend.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,10 @@ impl SysBackend for WebBackend {
491491
.replace("github.com", "raw.githubusercontent.com")
492492
.replace("src/branch/master", "raw/branch/master");
493493

494-
if !url.ends_with(".ua") {
494+
if !std::path::Path::new(&url)
495+
.extension()
496+
.is_some_and(|ext| ext.eq_ignore_ascii_case("ua"))
497+
{
495498
url = format!("{url}/main/lib.ua");
496499
}
497500

@@ -525,7 +528,10 @@ impl SysBackend for WebBackend {
525528
.iter()
526529
.filter_map(|entry| {
527530
let path = entry.get("path")?.as_str()?;
528-
if path.ends_with(".ua") {
531+
if Path::new(path)
532+
.extension()
533+
.is_some_and(|ext| ext.eq_ignore_ascii_case("ua"))
534+
{
529535
Some(path.to_string())
530536
} else {
531537
None

parser/src/parse.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ pub fn parse(
213213
errors,
214214
diagnostics,
215215
next_output_comment: 0,
216-
start_addr: &base as *const u8 as usize,
216+
start_addr: std::ptr::from_ref(&base) as usize,
217217
};
218218
let items = parser.items(ItemsKind::TopLevel);
219219
if parser.errors.is_empty() && parser.index < parser.tokens.len() {
@@ -1203,7 +1203,7 @@ impl Parser<'_> {
12031203
#[cfg(target_arch = "wasm32")]
12041204
const MAX_RECURSION_DEPTH: usize = 512 * 1024;
12051205
let curr = 0u8;
1206-
let curr_addr = &curr as *const u8 as usize;
1206+
let curr_addr = std::ptr::from_ref(&curr) as usize;
12071207
let diff = curr_addr.abs_diff(self.start_addr);
12081208
let too_deep = diff > MAX_RECURSION_DEPTH;
12091209
if too_deep {

src/algorithm/dyadic/search.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<T: ArrayValue> Array<T> {
6565
result_data.push(is_member as u8);
6666
}
6767
}
68-
let shape: Shape = elems.shape.iter().cloned().take(1).collect();
68+
let shape: Shape = elems.shape.iter().copied().take(1).collect();
6969
Array::new(shape, result_data)
7070
}
7171
Ordering::Greater => {

src/algorithm/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ where
817817
let acc_slice = acc.make_mut();
818818
for a in a.data {
819819
let mut i = 0;
820-
for b in b.data.iter().cloned() {
820+
for b in b.data.iter().copied() {
821821
acc_slice[i] = f(acc_slice[i], a);
822822
i += 1;
823823
acc_slice[i] = f(acc_slice[i], b);

src/array.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ use crate::{
2424
};
2525

2626
/// Uiua's array type
27+
#[expect(
28+
clippy::unsafe_derive_deserialize,
29+
reason = "done through ArrayRep which is safe"
30+
)]
2731
#[derive(Clone, Serialize, Deserialize)]
2832
#[serde(
2933
from = "ArrayRep<T>",

src/compile/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ impl Compiler {
472472
}
473473

474474
let base = 0u8;
475-
self.start_addrs.push(&base as *const u8 as usize);
475+
self.start_addrs.push(std::ptr::from_ref(&base) as usize);
476476
let res = self.catching_crash(input, |env| env.items(items, ItemCompMode::TopLevel));
477477
self.start_addrs.pop();
478478

@@ -1206,7 +1206,7 @@ impl Compiler {
12061206
};
12071207
let start_addr = *self.start_addrs.first().unwrap();
12081208
let curr = 0u8;
1209-
let curr_addr = &curr as *const u8 as usize;
1209+
let curr_addr = std::ptr::from_ref(&curr) as usize;
12101210
let diff = curr_addr.abs_diff(start_addr);
12111211
if diff > MAX_RECURSION_DEPTH {
12121212
return Err(self.error(span.clone(), "Compilation recursion limit reached"));

src/ffi.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -686,9 +686,13 @@ mod enabled {
686686
(self.arg_data.last().unwrap().downcast_ref::<T>())
687687
.unwrap_or_else(|| panic!("Value wasn't expected type {}", type_name::<T>())),
688688
));
689-
(self.arg_data.last().unwrap().downcast_ref::<T>())
690-
.unwrap_or_else(|| panic!("Value wasn't expected type {}", type_name::<T>()))
691-
as *const T as *mut ()
689+
std::ptr::from_ref(
690+
self.arg_data
691+
.last()
692+
.unwrap()
693+
.downcast_ref::<T>()
694+
.unwrap_or_else(|| panic!("Value wasn't expected type {}", type_name::<T>())),
695+
) as *mut ()
692696
}
693697
fn push_repr(&mut self, arg: Vec<u8>) -> *mut () {
694698
self.arg_data.push(Box::new(arg));
@@ -792,7 +796,7 @@ mod enabled {
792796
.or_else(|| {
793797
any.downcast_ref::<ListStorage<T>>().map(|(_, b)| {
794798
dbgln!(" list type");
795-
(&b[0], Some(&b[0] as *const T as *mut T))
799+
(&b[0], Some(std::ptr::from_ref(&b[0]) as *mut T))
796800
})
797801
})
798802
}

src/main.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
error::Error,
88
fmt, fs,
99
io::{self, stderr, stdin, stdout, BufRead, Write},
10-
path::{is_separator, Path, PathBuf},
10+
path::{Path, PathBuf},
1111
process::{exit, Child, Command, Stdio},
1212
sync::{
1313
atomic::{AtomicBool, Ordering},
@@ -123,12 +123,13 @@ fn main() {
123123
set_use_window(true);
124124
args.next();
125125
}
126-
if let Some(path) = args
127-
.next()
128-
.filter(|arg| arg.ends_with(".ua") || arg.contains(is_separator))
129-
{
126+
if let Some(path) = args.next().map(PathBuf::from).filter(|arg| {
127+
arg.extension()
128+
.is_some_and(|ext| ext.eq_ignore_ascii_case("ua"))
129+
|| arg.components().count() > 1
130+
}) {
130131
let args = args.collect();
131-
run(path.as_ref(), args, false, None, None, None, false);
132+
run(&path, args, false, None, None, None, false);
132133
return;
133134
}
134135

src/shape.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ use serde::*;
99
use smallvec::SmallVec;
1010

1111
/// Uiua's array shape type
12+
#[expect(
13+
clippy::unsafe_derive_deserialize,
14+
reason = "just a wrapper around SmallVec with no additional invariants"
15+
)]
1216
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Serialize, Deserialize)]
1317
#[serde(transparent)]
1418
pub struct Shape {

0 commit comments

Comments
 (0)