Skip to content

Commit ed15fa5

Browse files
committed
lint: fix clippy::format_push_string
1 parent 2ffdf87 commit ed15fa5

File tree

11 files changed

+64
-50
lines changed

11 files changed

+64
-50
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ print_stderr = "allow"
1818
dbg_macro = "warn"
1919
pedantic = {level = "warn", priority = -1}
2020
inline_always = "allow" # TODO: benchmark inlines
21-
format_push_string = "allow" # 27
2221
missing_panics_doc = "allow" # 37
2322
used_underscore_binding = "allow" # 39
2423
float_cmp = "allow" # 40

pad/editor/src/backend.rs

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

7272
thread_local! {
73+
static BREAKPOINTS: RefCell<HashMap<u64, (u64, usize)>> = RefCell::default();
7374
}
7475

7576
impl Default for WebBackend {

pad/editor/src/lib.rs

Lines changed: 2 additions & 1 deletion
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,
@@ -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})").ok();
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})").ok();
419420
}
420421
if prim.glyph().is_some() && glyph_only {
421422
if !title.is_empty() {

site/src/markdown.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ 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}").ok();
357357
}
358358
}
359359
} else {
@@ -372,7 +372,9 @@ fn node_html<'a>(node: &'a AstNode<'a>) -> String {
372372
{
373373
break;
374374
}
375-
Err(e) => line.push_str(&format!("# {e}")),
375+
Err(e) => {
376+
write!(line, "# {e}").ok();
377+
}
376378
}
377379
}
378380
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).ok();
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+
.ok();
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+
.ok();
7275
if let Some(outputs) = prim.outputs() {
7376
if outputs != 1 {
74-
sig.push_str(&format!(" {outputs}-output"));
77+
write!(sig, " {outputs}-output").ok();
7578
}
7679
} else {
7780
sig.push_str(" variable-output");

src/assembly.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::{
2-
fmt,
2+
fmt::{self, Write},
33
hash::{DefaultHasher, Hash, Hasher},
44
ops::{Index, IndexMut},
55
path::PathBuf,
@@ -263,7 +263,7 @@ impl Assembly {
263263
if map.len() == 1 {
264264
let key = map.keys().next().unwrap();
265265
let value = map.values().next().unwrap();
266-
uasm.push_str(&format!("{key} {value}\n"));
266+
writeln!(uasm, "{key} {value}").ok();
267267
continue;
268268
}
269269
}
@@ -293,7 +293,7 @@ impl Assembly {
293293
for entry in &self.inputs.files {
294294
let key = entry.key();
295295
let value = entry.value();
296-
uasm.push_str(&format!("{}: {:?}\n", key.display(), value));
296+
writeln!(uasm, "{}: {:?}", key.display(), value).ok();
297297
}
298298

299299
if !self.inputs.strings.is_empty() {

src/format.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ macro_rules! create_config {
113113

114114
#[test]
115115
fn generate_format_cfg_docs() {
116+
use std::fmt::Write;
116117
paste! {
117118
let mut s: String = r"
118119
# Uiua Formatter Configuration
@@ -125,19 +126,20 @@ Example with default values:
125126
```uiua
126127
".into();
127128
$(
128-
s.push_str(&format!("{} ← {}\n", stringify!([<$name:camel>]), default_to_uiua!($default)));
129+
write!(s, "{} ← {}\n", stringify!([<$name:camel>]), default_to_uiua!($default)).ok()
130+
;
129131
)*
130132
s.push_str(r"```
131133
The following configuration options are available:
132134
133135
");
134136

135137
$(
136-
s.push_str(&format!("### {}\n", stringify!([<$name:camel>])));
137-
s.push_str(&format!("Type: {}\n\n", param_type!($ty)));
138-
s.push_str(&format!("Default: `{}`\n\n", default_to_uiua!($default)));
139-
$(s.push_str(&format!("{}\n", $doc.trim()));)*
140-
s.push_str("\n---\n\n");
138+
writeln!(s, "### {}", stringify!([<$name:camel>])).ok();
139+
writeln!(s, "Type: {}\n", param_type!($ty)).ok();
140+
writeln!(s, "Default: `{}`\n", default_to_uiua!($default)).ok();
141+
$(writeln!(s, "{}", $doc.trim()).ok();)*
142+
writeln!(s, "\n---\n").ok();
141143
)*
142144

143145
fs::write("site/text/format_config.md", s).unwrap();

src/grid_fmt.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use std::{
44
collections::HashMap,
55
f64::consts::{E, PI, TAU},
6+
fmt::Write,
67
iter::{once, repeat_n},
78
mem::take,
89
};
@@ -274,10 +275,12 @@ impl GridFmt for f64 {
274275
round_sig_dec(mean, 4).grid_string(false)
275276
);
276277
if nan_count > 0 {
277-
s.push_str(&format!(
278+
write!(
279+
s,
278280
" ({nan_count} NaN{})",
279281
if nan_count > 1 { "s" } else { "" }
280-
));
282+
)
283+
.ok();
281284
}
282285
s
283286
}

0 commit comments

Comments
 (0)