Skip to content

Commit a02c8b4

Browse files
committed
lint: fix clippy::pedantic (1 entry)
1 parent 3d99461 commit a02c8b4

File tree

10 files changed

+22
-19
lines changed

10 files changed

+22
-19
lines changed

Cargo.toml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ print_stdout = "warn"
1717
print_stderr = "allow"
1818
dbg_macro = "warn"
1919
pedantic = {level = "warn", priority = -1}
20-
flat_map_option = "allow" # 1
21-
format_collect = "allow" # 1
22-
inefficient_to_string = "allow" # 1
23-
match_wild_err_arm = "allow" # 1
24-
maybe_infinite_iter = "allow" # 1
25-
missing_fields_in_debug = "allow" # 1
26-
same_functions_in_if_condition = "allow" # 1
27-
unnecessary_debug_formatting = "allow" # 1
28-
unreadable_literal = "allow" # 1
2920
implicit_clone = "allow" # 2
3021
inconsistent_struct_constructor = "allow" # 2
3122
match_bool = "allow" # 2

pad/editor/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub fn Editor<'a>(
7777
id.set(i + 1);
7878
i
7979
});
80-
let help: Vec<String> = help.iter().map(|s| s.to_string()).collect();
80+
let help: Vec<String> = help.iter().copied().map(|s| s.to_string()).collect();
8181
// Initialize all the examples
8282
let examples = match mode {
8383
EditorMode::Example if !nonprogressive => progressive_strings(example),

parser/src/inputs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl Inputs {
4848
InputSrc::File(path) => self
4949
.files
5050
.get(&**path)
51-
.unwrap_or_else(|| panic!("File {path:?} not found"))
51+
.unwrap_or_else(|| panic!("File {} not found", path.display()))
5252
.clone(),
5353
InputSrc::Str(index) => self
5454
.strings

parser/src/parse.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,11 @@ impl Parser<'_> {
12161216
if self.too_deep() {
12171217
return None;
12181218
}
1219+
#[expect(
1220+
clippy::same_functions_in_if_condition,
1221+
reason = "methods seem to mutate self, so the second if may or may not be needed",
1222+
// TODO
1223+
)]
12191224
let mut word = if let Some(n) = self.num() {
12201225
n.map(|(n, s)| Word::Number(n, s))
12211226
} else if let Some(prim) = self.prim() {

site/src/markdown.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ fn node_view<'a>(node: &'a AstNode<'a>) -> View {
217217

218218
#[cfg(test)]
219219
fn node_html<'a>(node: &'a AstNode<'a>) -> String {
220+
use std::fmt::Write;
220221
use uiua::{Compiler, PrimDoc, SafeSys, Uiua, UiuaErrorKind, Value};
221222
use uiua_editor::prim_class;
222223

@@ -394,8 +395,10 @@ fn node_html<'a>(node: &'a AstNode<'a>) -> String {
394395
&NodeValue::TableRow(is_header) => {
395396
let tag = if is_header { "th" } else { "td" };
396397
children_iter
397-
.map(|s| format!("<{tag}>{s}</{tag}>"))
398-
.collect()
398+
.try_fold(String::new(), |mut acc, cur| {
399+
write!(&mut acc, "<{tag}>{cur}</{tag}>").map(|_| acc)
400+
})
401+
.expect("write! on a String shouldn't fail")
399402
}
400403
_ => children(),
401404
}

src/algorithm/encode.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,9 @@ impl Value {
307307
&Data::Float(f) => f.into(),
308308
Data::String(s) => s.clone().into(),
309309
&Data::Bool(b) => b.into(),
310-
Data::DateTime(dt) => {
311-
((dt.as_f64() - 2.0) * 24.0 * 60.0 * 60.0 - 2208988800.0).into()
312-
}
310+
Data::DateTime(dt) => ((dt.as_f64() - 2.0) * 24.0 * 60.0 * 60.0
311+
- 2_208_988_800.0)
312+
.into(),
313313
Data::DateTimeIso(dt) => dt.clone().into(),
314314
Data::DurationIso(dur) => dur.clone().into(),
315315
Data::Error(e) => e.to_string().into(),

src/assembly.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,6 @@ impl fmt::Debug for Assembly {
648648
f.debug_struct("Assembly")
649649
.field("root", &self.root)
650650
.field("functions", &FmtFunctions(self))
651-
.finish()
651+
.finish_non_exhaustive() // TODO: maybe show all fields instead?
652652
}
653653
}

src/format.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,10 @@ impl Formatter<'_> {
14371437

14381438
let mut values = env.rt.output_comments;
14391439
if let Err(e) = res {
1440+
#[expect(
1441+
clippy::maybe_infinite_iter,
1442+
reason="values doesn't contain all possible keys,so this should terminate at some point",
1443+
)]
14401444
let next = (0..).take_while(|i| values.contains_key(i)).count();
14411445
values.insert(next, vec![vec![e.to_string().into()]]);
14421446
}

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ fn repl(mut env: Uiua, mut compiler: Compiler, color: bool, stack: bool, config:
11761176
code
11771177
}
11781178
Err(ReadlineError::Eof | ReadlineError::Interrupted) => break,
1179-
Err(_) => panic!("Failed to read from Stdin"),
1179+
Err(e) => panic!("Failed to read from Stdin: {e}"),
11801180
};
11811181
if code.is_empty() {
11821182
continue;

src/run_prim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,7 @@ fn regex(env: &mut Uiua) -> UiuaResult {
15351535
for caps in regex.captures_iter(&target) {
15361536
let row: EcoVec<Boxed> = caps
15371537
.iter()
1538-
.flat_map(|m| {
1538+
.filter_map(|m| {
15391539
m.map(|m| Boxed(Value::from(m.as_str()))).or_else(|| {
15401540
env.value_fill()
15411541
.map(|fv| fv.value.clone())

0 commit comments

Comments
 (0)