Skip to content

Commit 268ffbb

Browse files
committed
lint: fix clippy::pedantic (7 entries)
1 parent d9649de commit 268ffbb

File tree

20 files changed

+93
-108
lines changed

20 files changed

+93
-108
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ print_stdout = "warn"
1717
print_stderr = "allow"
1818
dbg_macro = "warn"
1919
pedantic = {level = "warn", priority = -1}
20-
needless_raw_string_hashes = "allow" # 7
21-
non_std_lazy_statics = "allow" # 7
22-
unnecessary_wraps = "allow" # 7
2320
unnested_or_patterns = "allow" # 8
2421
borrow_as_ptr = "allow" # 9
2522
explicit_iter_loop = "allow" # 9
@@ -72,7 +69,6 @@ js-sys = "0.3.69"
7269
leptos = "0.6.11"
7370
leptos_router = {version = "0.6.11", features = ["csr"]}
7471
leptos_meta = {version = "0.6.11", features = ["csr"]}
75-
once_cell = "1"
7672
rand = {version = "0.8.5", features = ["small_rng"]}
7773
serde = {version = "1", features = ["derive"]}
7874
serde_json = "1.0.115"
@@ -142,7 +138,6 @@ ecow.workspace = true
142138
enum-iterator.workspace = true
143139
indexmap = {version = "2", features = ["serde"]}
144140
num_cpus = "1.16.0"
145-
once_cell.workspace = true
146141
parking_lot = "0.12.1"
147142
paste = "1.0.14"
148143
pathdiff = "0.2.1"

parser/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ colored.workspace = true
2424
dashmap.workspace = true
2525
ecow.workspace = true
2626
enum-iterator.workspace = true
27-
once_cell.workspace = true
2827
serde = {workspace = true, features = ["rc"]}
2928
unicode-segmentation.workspace = true
3029
serde_tuple = "1.0.0"

parser/src/split.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
use std::{collections::HashMap, fmt};
1+
use std::{collections::HashMap, fmt, sync::LazyLock};
22

33
use enum_iterator::Sequence;
4-
use once_cell::sync::Lazy;
54

65
use crate::{ast::NumWord, Complex, SysOp};
76

87
use super::Primitive;
98

10-
static ALIASES: Lazy<HashMap<Primitive, &[&str]>> = Lazy::new(|| {
9+
static ALIASES: LazyLock<HashMap<Primitive, &[&str]>> = LazyLock::new(|| {
1110
[
1211
(Primitive::Identity, &["id"] as &[_]),
1312
(Primitive::Gap, &["ga"]),
@@ -145,7 +144,7 @@ impl Primitive {
145144
if name.len() < 2 {
146145
return None;
147146
}
148-
static REVERSE_ALIASES: Lazy<HashMap<&'static str, Primitive>> = Lazy::new(|| {
147+
static REVERSE_ALIASES: LazyLock<HashMap<&'static str, Primitive>> = LazyLock::new(|| {
149148
ALIASES
150149
.iter()
151150
.flat_map(|(prim, aliases)| aliases.iter().map(|&s| (s, *prim)))

site/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ pub fn MainPage() -> impl IntoView {
246246
rich_prim(
247247
Under,
248248
"for modifying only part of an array (among other things)",
249-
r#"⍜(↙2|×10) 1_2_3_4_5"#,
249+
r"⍜(↙2|×10) 1_2_3_4_5",
250250
),
251251
];
252252

site/src/markdown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub fn markdown_html(text: &str) -> String {
6060
.replace("``", "` `")
6161
.replace("<code block delim>", "```");
6262
let root = parse_document(&arena, &text, &options());
63-
let body = format!(r#"<body><div id=top>{}</div></body>"#, node_html(root));
63+
let body = format!(r"<body><div id=top>{}</div></body>", node_html(root));
6464
let head = r#"
6565
<meta charset="utf-8">
6666
<meta name="viewport" content="width=device-width, initial-scale=1">

site/src/tutorial.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,9 +1435,9 @@ fn TutorialThinkingWithArrays() -> impl IntoView {
14351435
number=2
14361436
prompt="returns the last word of a string"
14371437
example=r#""What's the last word?""#
1438-
answer=r#"▽ ⍜⇌\× ⊸≠@ "#
1438+
answer=r"▽ ⍜⇌\× ⊸≠@ "
14391439
tests={&[r#""Um, I um, arrays""#, r#""I like trains""#]}
1440-
hidden=r#"Wow"#/>
1440+
hidden=r"Wow"/>
14411441

14421442
<Challenge
14431443
number=3

src/algorithm/groups.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ pub fn split_by(f: SigNode, by_scalar: bool, keep_empty: bool, env: &mut Uiua) -
3434
if let Some(Primitive::Box) = f.node.as_primitive() {
3535
let val = haystack.generic_bin_ref(
3636
&delim,
37-
|a, b| a.split_by(b, keep_empty, |data| Boxed(data.into())),
38-
|a, b| a.split_by(b, keep_empty, |data| Boxed(data.into())),
37+
|a, b| Ok(a.split_by(b, keep_empty, |data| Boxed(data.into()))),
38+
|a, b| Ok(a.split_by(b, keep_empty, |data| Boxed(data.into()))),
3939
|_, _| unreachable!("split by complex"),
40-
|a, b| a.split_by(b, keep_empty, |data| Boxed(data.into())),
41-
|a, b| a.split_by(b, keep_empty, |data| Boxed(data.into())),
40+
|a, b| Ok(a.split_by(b, keep_empty, |data| Boxed(data.into()))),
41+
|a, b| Ok(a.split_by(b, keep_empty, |data| Boxed(data.into()))),
4242
|a, b| {
4343
env.error(format!(
4444
"Cannot split {} by {}",
@@ -51,11 +51,11 @@ pub fn split_by(f: SigNode, by_scalar: bool, keep_empty: bool, env: &mut Uiua) -
5151
} else {
5252
let parts = haystack.generic_bin_ref(
5353
&delim,
54-
|a, b| a.split_by(b, keep_empty, Value::from),
55-
|a, b| a.split_by(b, keep_empty, Value::from),
54+
|a, b| Ok(a.split_by(b, keep_empty, Value::from)),
55+
|a, b| Ok(a.split_by(b, keep_empty, Value::from)),
5656
|_, _| unreachable!("split by complex"),
57-
|a, b| a.split_by(b, keep_empty, Value::from),
58-
|a, b| a.split_by(b, keep_empty, Value::from),
57+
|a, b| Ok(a.split_by(b, keep_empty, Value::from)),
58+
|a, b| Ok(a.split_by(b, keep_empty, Value::from)),
5959
|a, b| {
6060
env.error(format!(
6161
"Cannot split {} by {}",
@@ -97,11 +97,11 @@ where
9797
delim: &Self,
9898
keep_empty: bool,
9999
f: impl Fn(CowSlice<T>) -> R,
100-
) -> UiuaResult<EcoVec<R>> {
100+
) -> EcoVec<R> {
101101
let haystack = self.data.as_slice();
102102
let delim_slice = delim.data.as_slice();
103103
if delim_slice.is_empty() {
104-
return Ok(eco_vec![f(self.data.clone())]);
104+
return eco_vec![f(self.data.clone())];
105105
}
106106
let mut curr = 0;
107107
let mut data = EcoVec::new();
@@ -136,7 +136,7 @@ where
136136
data.push(f(CowSlice::new()));
137137
}
138138
}
139-
Ok(data)
139+
data
140140
}
141141
}
142142

src/check.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,8 @@ impl VirtualEnv {
169169
fn nodes(&mut self, nodes: &[Node]) -> Result<(), SigCheckError> {
170170
nodes.iter().try_for_each(|node| self.node(node))
171171
}
172-
fn sig_node(&mut self, sn: &SigNode) -> Result<(), SigCheckError> {
172+
fn sig_node(&mut self, sn: &SigNode) {
173173
self.handle_sig(sn.sig);
174-
Ok(())
175174
}
176175
fn node(&mut self, node: &Node) -> Result<(), SigCheckError> {
177176
use ImplPrimitive::*;
@@ -294,7 +293,7 @@ impl VirtualEnv {
294293
}
295294
Each | Rows | Inventory => {
296295
let [f] = get_args_nodes(args)?;
297-
self.sig_node(f)?;
296+
self.sig_node(f);
298297
}
299298
Table | Tuples => {
300299
let [sig] = get_args(args)?;
@@ -318,7 +317,7 @@ impl VirtualEnv {
318317
Repeat => {
319318
let [f] = get_args_nodes(args)?;
320319
self.pop();
321-
self.repeat(f)?;
320+
self.repeat(f);
322321
}
323322
Do => {
324323
let [body, cond] = get_args(args)?;
@@ -381,38 +380,38 @@ impl VirtualEnv {
381380
Both => {
382381
let [f] = get_args_nodes(args)?;
383382
self.stack.pop_n(f.sig.args());
384-
self.sig_node(f)?;
383+
self.sig_node(f);
385384
self.stack.push_n(f.sig.args());
386-
self.sig_node(f)?;
385+
self.sig_node(f);
387386
}
388387
Dip => {
389388
let [f] = get_args_nodes(args)?;
390389
self.pop();
391-
self.sig_node(f)?;
390+
self.sig_node(f);
392391
self.push();
393392
}
394393
Gap => {
395394
let [f] = get_args_nodes(args)?;
396395
self.pop();
397-
self.sig_node(f)?;
396+
self.sig_node(f);
398397
}
399398
Reach => {
400399
let [f] = get_args_nodes(args)?;
401400
self.pop();
402401
self.pop();
403402
self.push();
404-
self.sig_node(f)?;
403+
self.sig_node(f);
405404
}
406405
On => {
407406
let [f] = get_args_nodes(args)?;
408407
self.pop();
409408
self.push();
410-
self.sig_node(f)?;
409+
self.sig_node(f);
411410
self.push();
412411
}
413412
By => {
414413
let [f] = get_args_nodes(args)?;
415-
self.sig_node(f)?;
414+
self.sig_node(f);
416415
self.push();
417416
}
418417
Above | Below => {
@@ -456,7 +455,7 @@ impl VirtualEnv {
456455
let [sn] = get_args_nodes(args)?;
457456
let args = sn.sig.args().max(n);
458457
self.handle_args_outputs(args, args);
459-
self.sig_node(sn)?;
458+
self.sig_node(sn);
460459
self.handle_args_outputs(0, n);
461460
}
462461
ReduceContent | ReduceDepth(_) => {
@@ -476,11 +475,11 @@ impl VirtualEnv {
476475
));
477476
}
478477
self.pop();
479-
self.repeat(f)?;
478+
self.repeat(f);
480479
}
481480
RepeatCountConvergence => {
482481
let [f] = get_args_nodes(args)?;
483-
self.repeat(f)?;
482+
self.repeat(f);
484483
self.push();
485484
}
486485
UnFill | SidedFill(_) => self.fill(args)?,
@@ -499,7 +498,7 @@ impl VirtualEnv {
499498
}
500499
EachSub(_) => {
501500
let [f] = get_args_nodes(args)?;
502-
self.sig_node(f)?;
501+
self.sig_node(f);
503502
}
504503
RowsSub(sub, _) => {
505504
let [mut f] = get_args(args)?;
@@ -513,7 +512,7 @@ impl VirtualEnv {
513512
UndoRows | UndoInventory => {
514513
let [f] = get_args_nodes(args)?;
515514
self.stack.pop();
516-
self.sig_node(f)?;
515+
self.sig_node(f);
517516
}
518517
UnScan => self.handle_args_outputs(1, 1),
519518
SplitBy | SplitByScalar | SplitByKeepEmpty => {
@@ -582,18 +581,18 @@ impl VirtualEnv {
582581
fn fill(&mut self, args: &[SigNode]) -> Result<(), SigCheckError> {
583582
let [fill, f] = get_args_nodes(args)?;
584583
if fill.sig.outputs() > 0 || fill.sig.args() > 0 && fill.sig.outputs() != 0 {
585-
self.sig_node(fill)?;
584+
self.sig_node(fill);
586585
}
587586
self.handle_args_outputs(fill.sig.outputs(), 0);
588-
self.sig_node(f)
587+
self.sig_node(f);
588+
Ok(())
589589
}
590-
fn repeat(&mut self, sn: &SigNode) -> Result<(), SigCheckError> {
590+
fn repeat(&mut self, sn: &SigNode) {
591591
let sig = sn.sig;
592-
self.sig_node(sn)?;
592+
self.sig_node(sn);
593593
if sig.outputs() > sig.args() {
594594
self.stack.pop_n(sig.args());
595595
}
596-
Ok(())
597596
}
598597
}
599598

src/compile/binding.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ impl Compiler {
455455
sig = declared_sig.value;
456456
}
457457
let func = make_fn(node, sig, self);
458-
self.compile_bind_function(name, local, func, spandex, meta)?;
458+
self.compile_bind_function(name, local, func, spandex, meta);
459459
} else {
460460
// Binds some |0.1 code
461461
self.compile_bind_const(name, local, None, spandex, meta);
@@ -467,7 +467,7 @@ impl Compiler {
467467
} else {
468468
// Binding is a normal function
469469
let func = make_fn(node, sig, self);
470-
self.compile_bind_function(name, local, func, spandex, meta)?;
470+
self.compile_bind_function(name, local, func, spandex, meta);
471471
}
472472

473473
self.code_meta.function_sigs.insert(
@@ -517,7 +517,7 @@ impl Compiler {
517517
};
518518
// Compile items
519519
let (module, ()) = self.in_scope(scope_kind, |comp| {
520-
comp.items(m.items, ItemCompMode::TopLevel)?;
520+
comp.items(m.items, ItemCompMode::TopLevel);
521521
comp.end_enum()?;
522522
Ok(())
523523
})?;

0 commit comments

Comments
 (0)