Skip to content

Commit 0a2ab15

Browse files
committed
lint: fix clippy::default_trait_access, clippy::format_push_string
1 parent a6057bb commit 0a2ab15

File tree

24 files changed

+94
-78
lines changed

24 files changed

+94
-78
lines changed

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ print_stderr = "allow"
1818
dbg_macro = "warn"
1919
pedantic = {level = "warn", priority = -1}
2020
inline_always = "allow" # TODO: benchmark inlines
21-
default_trait_access = "allow" # 23
22-
format_push_string = "allow" # 27
2321
missing_panics_doc = "allow" # 37
2422
used_underscore_binding = "allow" # 39
2523
float_cmp = "allow" # 40

pad/editor/src/backend.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub fn delete_file(path: &PathBuf) {
7070
}
7171

7272
thread_local! {
73-
static BREAKPOINTS: RefCell<HashMap<u64, (u64, usize)>> = Default::default();
73+
static BREAKPOINTS: RefCell<HashMap<u64, (u64, usize)>> = RefCell::default();
7474
}
7575

7676
impl Default for WebBackend {
@@ -434,8 +434,8 @@ impl SysBackend for WebBackend {
434434
}
435435
fn load_git_module(&self, original_url: &str, target: GitTarget) -> Result<PathBuf, String> {
436436
thread_local! {
437-
static CACHE: RefCell<HashMap<String, Result<String, String>>> = Default::default();
438-
static WORKING: RefCell<HashSet<String>> = Default::default();
437+
static CACHE: RefCell<HashMap<String, Result<String, String>>> = RefCell::default();
438+
static WORKING: RefCell<HashSet<String>> = RefCell::default();
439439
}
440440

441441
fn cache_url(url: &str, res: Result<String, String>) {

pad/editor/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pub mod utils;
33

44
use std::{
55
cell::Cell,
6+
fmt::Write,
67
iter::{once, repeat_n},
78
mem::take,
89
path::PathBuf,
@@ -129,7 +130,7 @@ pub fn Editor<'a>(
129130
let (fullscreen_enabled, set_fullscreen_enabled) = create_signal(false);
130131
let update_token_count = move |code: &str| {
131132
set_token_count.set(
132-
lex(code, (), &mut Default::default())
133+
lex(code, (), &mut uiua::Inputs::default())
133134
.0
134135
.into_iter()
135136
.filter(|tok| {
@@ -2255,7 +2256,7 @@ pub fn Prim(
22552256
let href = format!("/docs/{}", prim.name());
22562257
let mut title = String::new();
22572258
if let Some(ascii) = prim.ascii() {
2258-
title.push_str(&format!("({ascii})"));
2259+
write!(title, "({ascii})").expect("write! to string shouldn't fail");
22592260
}
22602261
if prim.glyph().is_some() && glyph_only {
22612262
if !title.is_empty() {

site/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ fn NotFound() -> impl IntoView {
403403

404404
#[cfg(test)]
405405
fn prim_html(prim: Primitive, glyph_only: bool, hide_docs: bool) -> String {
406+
use std::fmt::Write;
406407
use uiua::PrimDoc;
407408

408409
let symbol_class = format!("prim-glyph {}", uiua_editor::prim_class(prim));
@@ -415,7 +416,7 @@ fn prim_html(prim: Primitive, glyph_only: bool, hide_docs: bool) -> String {
415416
let href = format!("/docs/{}", prim.name());
416417
let mut title = String::new();
417418
if let Some(ascii) = prim.ascii() {
418-
title.push_str(&format!("({ascii})"));
419+
write!(title, "({ascii})").expect("write! to String shouldn't fail");
419420
}
420421
if prim.glyph().is_some() && glyph_only {
421422
if !title.is_empty() {

site/src/markdown.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn node_view<'a>(node: &'a AstNode<'a>) -> View {
182182
if block.literal.trim() == "LOGO" {
183183
view!(<Editor example=LOGO/>).into_view()
184184
} else if (block.info.is_empty() || block.info.starts_with("uiua"))
185-
&& uiua::parse(&block.literal, (), &mut Default::default())
185+
&& uiua::parse(&block.literal, (), &mut Inputs::default())
186186
.1
187187
.is_empty()
188188
{
@@ -353,7 +353,8 @@ fn node_html<'a>(node: &'a AstNode<'a>) -> String {
353353
line.push('\n');
354354
for formatted in formatted {
355355
for fline in formatted.lines() {
356-
line.push_str(&format!("\n# {fline}"));
356+
write!(line, "\n# {fline}")
357+
.expect("write! to String shouldn't fail");
357358
}
358359
}
359360
} else {
@@ -372,7 +373,7 @@ fn node_html<'a>(node: &'a AstNode<'a>) -> String {
372373
{
373374
break;
374375
}
375-
Err(e) => line.push_str(&format!("# {e}")),
376+
Err(e) => write!(line, "# {e}").expect("write! to String shouldn't fail"),
376377
}
377378
}
378379
let text = lines.join("\n");

site/src/other.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use leptos::*;
22
use leptos_meta::*;
3+
use std::fmt::Write;
34
use uiua::{ConstClass, Primitive, SysOp, CONSTANTS};
45
use uiua_editor::{lang, Editor};
56

@@ -459,7 +460,7 @@ pub fn Combinators() -> impl IntoView {
459460
if !line.starts_with('#') {
460461
for i in 0..inputs {
461462
let a = i * 3 + 1;
462-
ex.push_str(&format!(" {}_{}_{}", a, a + 1, a + 2));
463+
write!(ex, " {}_{}_{}", a, a+1, a+2).expect("write! to String shouldn't fail");
463464
}
464465
ex.push_str(" ");
465466
}

site/src/primitive.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use leptos::*;
22
use leptos_router::*;
3+
use std::fmt::Write;
34
use uiua::{PrimClass, PrimDoc, PrimDocFragment, PrimDocLine, Primitive, SysOp};
45
use uiua_editor::Editor;
56

@@ -49,11 +50,12 @@ pub fn PrimDocs(prim: Primitive) -> impl IntoView {
4950
sig.push_str("Constant");
5051
} else if let Some(margs) = prim.modifier_args() {
5152
match margs {
52-
1 => sig.push_str("Monadic"),
53-
2 => sig.push_str("Dyadic"),
54-
3 => sig.push_str("Triadic"),
55-
n => sig.push_str(&format!("{n}-function")),
53+
1 => write!(sig, "Monadic"),
54+
2 => write!(sig, "Dyadic"),
55+
3 => write!(sig, "Triadic"),
56+
n => write!(sig, "{n}-function"),
5657
}
58+
.expect("write! to String shouldn't fail");
5759
if let Some(args) = prim.args() {
5860
sig.push(' ');
5961
sig.push_str(&args.to_string());
@@ -62,16 +64,17 @@ pub fn PrimDocs(prim: Primitive) -> impl IntoView {
6264
sig.push_str(" modifier");
6365
} else {
6466
match prim.args() {
65-
Some(0) => sig.push_str("Noadic"),
66-
Some(1) => sig.push_str("Monadic"),
67-
Some(2) => sig.push_str("Dyadic"),
68-
Some(3) => sig.push_str("Triadic"),
69-
Some(n) => sig.push_str(&format!("{n}-argument")),
70-
None => sig.push_str("Variadic"),
67+
Some(0) => write!(sig, "Noadic"),
68+
Some(1) => write!(sig, "Monadic"),
69+
Some(2) => write!(sig, "Dyadic"),
70+
Some(3) => write!(sig, "Triadic"),
71+
Some(n) => write!(sig, "{n}-argument"),
72+
None => write!(sig, "Variadic"),
7173
}
74+
.expect("write! to String shouldn't fail");
7275
if let Some(outputs) = prim.outputs() {
7376
if outputs != 1 {
74-
sig.push_str(&format!(" {outputs}-output"));
77+
write!(sig, " {outputs}-output").expect("write! to String shouldn't fail");
7578
}
7679
} else {
7780
sig.push_str(" variable-output");

src/algorithm/ga.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ use ecow::{eco_vec, EcoVec};
99
use serde::*;
1010

1111
use crate::{
12-
algorithm::pervade::derive_new_shape, grid_fmt::GridFmt, is_default, Array, Boxed, Primitive,
13-
Shape, Uiua, UiuaResult, Value,
12+
algorithm::pervade::derive_new_shape,
13+
grid_fmt::{GridFmt, GridFmtParams},
14+
is_default, Array, Boxed, Primitive, Shape, Uiua, UiuaResult, Value,
1415
};
1516

1617
macro_rules! ga_op {
@@ -1259,7 +1260,7 @@ pub fn unparse(spec: Spec, val: Value, env: &Uiua) -> UiuaResult<Value> {
12591260
}
12601261
let mask = mask_table[i];
12611262
if n.abs() != 1.0 || mask == 0 {
1262-
let n_grid = n.abs().fmt_grid(Default::default());
1263+
let n_grid = n.abs().fmt_grid(GridFmtParams::default());
12631264
s.extend(n_grid.into_iter().next().unwrap());
12641265
}
12651266
if mask == 0 {

src/algorithm/groups.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use ecow::{eco_vec, EcoVec};
77

88
use crate::{
99
cowslice::CowSlice, get_ops, types::push_empty_rows_value, val_as_arr, Array, ArrayValue,
10-
Boxed, Node, Ops, Primitive, ScalarNum, Shape, SigNode, Uiua, UiuaResult, Value,
10+
Boxed, Node, Ops, PersistentMeta, Primitive, ScalarNum, Shape, SigNode, Uiua, UiuaResult,
11+
Value,
1112
};
1213

1314
use super::multi_output;
@@ -756,7 +757,7 @@ where
756757
.collect::<UiuaResult<_>>()?;
757758

758759
if indices.shape == [0]
759-
&& push_empty_rows_value(&f, &values, false, &mut Default::default(), env)
760+
&& push_empty_rows_value(&f, &values, false, &mut PersistentMeta::default(), env)
760761
{
761762
return Ok(());
762763
}

src/algorithm/media.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ pub fn gif_bytes_to_value(bytes: &[u8]) -> Result<(f64, Value), gif::DecodingErr
740740
let first_frame = decoder.read_next_frame()?.unwrap();
741741
let gif_width = first_frame.width as usize;
742742
let gif_height = first_frame.height as usize;
743-
let mut data: crate::cowslice::CowSlice<f64> = Default::default();
743+
let mut data = crate::cowslice::CowSlice::new();
744744
let mut frame_count = 1;
745745
let mut delay_sum = first_frame.delay as f64 / 100.0;
746746
// Init frame data with the first frame

0 commit comments

Comments
 (0)