enable format_push_string lint

This commit is contained in:
Charles Hall 2024-05-12 16:36:51 -07:00
parent 5fd156a6bb
commit bd6ea4e358
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
3 changed files with 22 additions and 12 deletions

View file

@ -28,6 +28,7 @@ empty_structs_with_brackets = "warn"
error_impl_error = "warn" error_impl_error = "warn"
filetype_is_file = "warn" filetype_is_file = "warn"
float_cmp_const = "warn" float_cmp_const = "warn"
format_push_string = "warn"
get_unwrap = "warn" get_unwrap = "warn"
lossy_float_literal = "warn" lossy_float_literal = "warn"
mem_forget = "warn" mem_forget = "warn"

View file

@ -1,6 +1,7 @@
use std::{ use std::{
collections::BTreeMap, collections::BTreeMap,
fmt, fmt,
fmt::Write,
net::{IpAddr, Ipv4Addr}, net::{IpAddr, Ipv4Addr},
}; };
@ -191,7 +192,8 @@ impl fmt::Display for Config {
let mut msg: String = "Active config values:\n\n".to_owned(); let mut msg: String = "Active config values:\n\n".to_owned();
for line in lines.into_iter().enumerate() { for line in lines.into_iter().enumerate() {
msg += &format!("{}: {}\n", line.1 .0, line.1 .1); writeln!(msg, "{}: {}", line.1 .0, line.1 .1)
.expect("write to in-memory buffer should succeed");
} }
write!(f, "{msg}") write!(f, "{msg}")

View file

@ -1,6 +1,7 @@
use std::{ use std::{
collections::BTreeMap, collections::BTreeMap,
convert::{TryFrom, TryInto}, convert::{TryFrom, TryInto},
fmt::Write,
sync::Arc, sync::Arc,
time::Instant, time::Instant,
}; };
@ -413,13 +414,13 @@ impl Service {
for (r, (e, i)) in map.iter() { for (r, (e, i)) in map.iter() {
let elapsed = i.elapsed(); let elapsed = i.elapsed();
msg += &format!( writeln!(
"{} {}: {}m{}s\n", msg,
r, "{r} {e}: {}m{}s",
e,
elapsed.as_secs() / 60, elapsed.as_secs() / 60,
elapsed.as_secs() % 60 elapsed.as_secs() % 60
); )
.expect("write to in-memory buffer should succeed");
} }
RoomMessageEventContent::text_plain(&msg) RoomMessageEventContent::text_plain(&msg)
} }
@ -718,8 +719,10 @@ impl Service {
markdown_message.push_str("The following user ids are not valid:\n```\n"); markdown_message.push_str("The following user ids are not valid:\n```\n");
html_message.push_str("The following user ids are not valid:\n<pre>\n"); html_message.push_str("The following user ids are not valid:\n<pre>\n");
for invalid_user in invalid_users { for invalid_user in invalid_users {
markdown_message.push_str(&format!("{invalid_user}\n")); writeln!(markdown_message, "{invalid_user}")
html_message.push_str(&format!("{invalid_user}\n")); .expect("write to in-memory buffer should succeed");
writeln!(html_message, "{invalid_user}")
.expect("write to in-memory buffer should succeed");
} }
markdown_message.push_str("```\n\n"); markdown_message.push_str("```\n\n");
html_message.push_str("</pre>\n\n"); html_message.push_str("</pre>\n\n");
@ -730,8 +733,10 @@ impl Service {
html_message html_message
.push_str("The following users are not from this server:\n<pre>\n"); .push_str("The following users are not from this server:\n<pre>\n");
for remote_id in remote_ids { for remote_id in remote_ids {
markdown_message.push_str(&format!("{remote_id}\n")); writeln!(markdown_message, "{remote_id}")
html_message.push_str(&format!("{remote_id}\n")); .expect("write to in-memory buffer should succeed");
writeln!(html_message, "{remote_id}")
.expect("write to in-memory buffer should succeed");
} }
markdown_message.push_str("```\n\n"); markdown_message.push_str("```\n\n");
html_message.push_str("</pre>\n\n"); html_message.push_str("</pre>\n\n");
@ -740,8 +745,10 @@ impl Service {
markdown_message.push_str("The following users do not exist:\n```\n"); markdown_message.push_str("The following users do not exist:\n```\n");
html_message.push_str("The following users do not exist:\n<pre>\n"); html_message.push_str("The following users do not exist:\n<pre>\n");
for non_existant_id in non_existant_ids { for non_existant_id in non_existant_ids {
markdown_message.push_str(&format!("{non_existant_id}\n")); writeln!(markdown_message, "{non_existant_id}")
html_message.push_str(&format!("{non_existant_id}\n")); .expect("write to in-memory buffer should succeed");
writeln!(html_message, "{non_existant_id}")
.expect("write to in-memory buffer should succeed");
} }
markdown_message.push_str("```\n\n"); markdown_message.push_str("```\n\n");
html_message.push_str("</pre>\n\n"); html_message.push_str("</pre>\n\n");