Skip to content

Commit ab83e1a

Browse files
committed
lint: fix clippy::pedantic (15 entries)
1 parent e6b3f11 commit ab83e1a

File tree

22 files changed

+150
-170
lines changed

22 files changed

+150
-170
lines changed

Cargo.toml

Lines changed: 0 additions & 3 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-
ptr_cast_constness = "allow" # 15
21-
redundant_else = "allow" # 15
22-
unnecessary_semicolon = "allow" # 15
2320
manual_assert = "allow" # 16
2421
inline_always = "allow" # 18
2522
from_iter_instead_of_collect = "allow" # 20

pad/editor/src/backend.rs

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -514,58 +514,57 @@ impl SysBackend for WebBackend {
514514
cache_url(&url, tree_res);
515515
unmark_working(&original_url);
516516
return;
517-
} else {
518-
let tree = tree_res.unwrap();
519-
let tree: serde_json::Value = serde_json::from_str(&tree).unwrap();
520-
let tree = tree.get("tree").unwrap().as_array().unwrap();
521-
let paths = tree
522-
.iter()
523-
.filter_map(|entry| {
524-
let path = entry.get("path")?.as_str()?;
525-
if Path::new(path)
526-
.extension()
527-
.is_some_and(|ext| ext.eq_ignore_ascii_case("ua"))
528-
{
529-
Some(path.to_string())
530-
} else {
531-
None
532-
}
533-
})
534-
.collect::<HashSet<_>>();
535-
536-
if !paths.contains("lib.ua") {
537-
cache_url(&url, Err("lib.ua not found".into()));
538-
unmark_working(&original_url);
539-
return;
540-
}
541-
542-
let results = join_all(paths.iter().map(|path| {
543-
let repo_owner = repo_owner.clone();
544-
let repo_name = repo_name.clone();
545-
async move {
546-
let fetch_url = format!(
547-
"https://raw.githubusercontent.com\
548-
/{repo_owner}/{repo_name}/main/{path}",
549-
);
550-
let internal_path = Path::new("uiua-modules")
551-
.join(repo_owner)
552-
.join(repo_name)
553-
.join(path.clone());
554-
555-
(path, internal_path, fetch(fetch_url.as_str()).await)
517+
}
518+
let tree = tree_res.unwrap();
519+
let tree: serde_json::Value = serde_json::from_str(&tree).unwrap();
520+
let tree = tree.get("tree").unwrap().as_array().unwrap();
521+
let paths = tree
522+
.iter()
523+
.filter_map(|entry| {
524+
let path = entry.get("path")?.as_str()?;
525+
if Path::new(path)
526+
.extension()
527+
.is_some_and(|ext| ext.eq_ignore_ascii_case("ua"))
528+
{
529+
Some(path.to_string())
530+
} else {
531+
None
556532
}
557-
}))
558-
.await;
533+
})
534+
.collect::<HashSet<_>>();
559535

560-
for (original_path, internal_path, res) in results {
561-
if original_path.eq("lib.ua") {
562-
cache_url(&url, res.clone());
563-
}
536+
if !paths.contains("lib.ua") {
537+
cache_url(&url, Err("lib.ua not found".into()));
538+
unmark_working(&original_url);
539+
return;
540+
}
564541

565-
if let Ok(text) = res {
566-
let contents = text.as_bytes().to_vec();
567-
drop_file(internal_path.clone(), contents);
568-
}
542+
let results = join_all(paths.iter().map(|path| {
543+
let repo_owner = repo_owner.clone();
544+
let repo_name = repo_name.clone();
545+
async move {
546+
let fetch_url = format!(
547+
"https://raw.githubusercontent.com\
548+
/{repo_owner}/{repo_name}/main/{path}",
549+
);
550+
let internal_path = Path::new("uiua-modules")
551+
.join(repo_owner)
552+
.join(repo_name)
553+
.join(path.clone());
554+
555+
(path, internal_path, fetch(fetch_url.as_str()).await)
556+
}
557+
}))
558+
.await;
559+
560+
for (original_path, internal_path, res) in results {
561+
if original_path.eq("lib.ua") {
562+
cache_url(&url, res.clone());
563+
}
564+
565+
if let Ok(text) = res {
566+
let contents = text.as_bytes().to_vec();
567+
drop_file(internal_path.clone(), contents);
569568
}
570569
}
571570

parser/src/lex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ impl<'a> Lexer<'a> {
13641364
self.errors
13651365
.push(self.end_span(start).sp(LexError::UnexpectedChar(c.into())));
13661366
}
1367-
};
1367+
}
13681368
}
13691369

13701370
(self.tokens, self.errors)

parser/src/parse.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ impl Parser<'_> {
685685
Vec::new()
686686
});
687687
init = Some(FieldInit { arrow_span, words })
688-
};
688+
}
689689

690690
trailing_newline |= self.ignore_whitespace();
691691
let mut bar_span = self.exact(Bar.into());
@@ -1309,9 +1309,8 @@ impl Parser<'_> {
13091309
}
13101310
span.merge_with(dspan);
13111311
return Some(span.sp((n, s)));
1312-
} else {
1313-
self.index = reset;
13141312
}
1313+
self.index = reset;
13151314
}
13161315
}
13171316
// Let 1-letter string be identifiers
@@ -1446,10 +1445,9 @@ impl Parser<'_> {
14461445
if s == "¯" {
14471446
self.index = reset;
14481447
return None;
1449-
} else {
1450-
// Just the number
1451-
(coef.into(), s, span)
14521448
}
1449+
// Just the number
1450+
(coef.into(), s, span)
14531451
} else {
14541452
self.index = reset;
14551453
return None;

parser/src/subscript.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl<N: fmt::Display> fmt::Display for Subscript<N> {
145145
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
146146
if self.num.is_none() && self.side.is_none() {
147147
return write!(f, ",");
148-
};
148+
}
149149
if let Some(num) = &self.num {
150150
num.fmt(f)?;
151151
}

site/src/docs.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -363,23 +363,20 @@ impl Allowed {
363363
classes: [prim.class()].into(),
364364
prims,
365365
};
366-
} else {
367-
for &part in &parts {
368-
if let Some(prim) = prim_matching_part_exactly(part) {
369-
prims.insert(prim);
370-
continue;
371-
}
372-
let matches = all()
373-
.filter(|p| p.name().to_lowercase().starts_with(part))
374-
.chain(all().filter(|p| {
375-
p.ascii()
376-
.is_some_and(|simple| part.contains(&simple.to_string()))
377-
}))
378-
.chain(
379-
all().filter(|p| p.glyph().is_some_and(|unicode| part.contains(unicode))),
380-
);
381-
prims.extend(matches);
366+
}
367+
for &part in &parts {
368+
if let Some(prim) = prim_matching_part_exactly(part) {
369+
prims.insert(prim);
370+
continue;
382371
}
372+
let matches = all()
373+
.filter(|p| p.name().to_lowercase().starts_with(part))
374+
.chain(all().filter(|p| {
375+
p.ascii()
376+
.is_some_and(|simple| part.contains(&simple.to_string()))
377+
}))
378+
.chain(all().filter(|p| p.glyph().is_some_and(|unicode| part.contains(unicode))));
379+
prims.extend(matches);
383380
}
384381
let mut classes: HashSet<PrimClass> = PrimClass::all().collect();
385382
let system_classes: Vec<PrimClass> = SysOpClass::all().map(PrimClass::Sys).collect();

src/algorithm/dyadic/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,10 +1885,9 @@ impl<T: RealArrayValue> Array<T> {
18851885
if n == f64::INFINITY {
18861886
slice[i * num_digits + j] = n;
18871887
break;
1888-
} else {
1889-
slice[i * num_digits + j] = n.rem_euclid(base);
1890-
n = n.div_euclid(base);
18911888
}
1889+
slice[i * num_digits + j] = n.rem_euclid(base);
1890+
n = n.div_euclid(base);
18921891
}
18931892
}
18941893
Ok(Array::new(new_shape, new_data))

src/algorithm/dyadic/search.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,13 @@ impl<T: ArrayValue> Array<T> {
317317
result_data.push(i as f64);
318318
cache.insert(elem_key, (i, false));
319319
continue 'needle;
320-
} else {
321-
for j in i + 1..haystack.row_count() {
322-
let of_key = ArrayCmpSlice(haystack.row_slice(j));
323-
if of_key == elem_key {
324-
result_data.push(j as f64);
325-
cache.insert(elem_key, (j, false));
326-
continue 'needle;
327-
}
320+
}
321+
for j in i + 1..haystack.row_count() {
322+
let of_key = ArrayCmpSlice(haystack.row_slice(j));
323+
if of_key == elem_key {
324+
result_data.push(j as f64);
325+
cache.insert(elem_key, (j, false));
326+
continue 'needle;
328327
}
329328
}
330329
} else {

src/algorithm/dyadic/structure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ impl<T: ArrayValue> Array<T> {
753753
for row in self.rows().take(end) {
754754
new_rows.push(row.drop(sub_index, env)?);
755755
}
756-
};
756+
}
757757
if row_count == abs_dropping {
758758
let mut shape = self.shape;
759759
for (s, n) in shape.iter_mut().zip(once(&Err(true)).chain(sub_index)) {

src/algorithm/loops.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,9 @@ fn repeat_impl(f: SigNode, inv: Option<SigNode>, n: f64, env: &mut Uiua) -> Uiua
205205
if converged {
206206
env.push(next);
207207
break;
208-
} else {
209-
env.push(next.clone());
210-
prev = next;
211208
}
209+
env.push(next.clone());
210+
prev = next;
212211
convergence_count += 1;
213212
}
214213
} else {

0 commit comments

Comments
 (0)