Skip to content

Commit 5f48e69

Browse files
committed
More clippy fixes
1 parent 8756eee commit 5f48e69

File tree

7 files changed

+40
-34
lines changed

7 files changed

+40
-34
lines changed

objdiff-core/src/arch/mod.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
use alloc::{borrow::Cow, boxed::Box, format, string::String, vec::Vec};
1+
use alloc::{
2+
borrow::Cow,
3+
boxed::Box,
4+
format,
5+
string::{String, ToString},
6+
vec::Vec,
7+
};
28
use core::{
39
ffi::CStr,
410
fmt::{self, Debug},
@@ -50,14 +56,14 @@ pub enum DataType {
5056
impl fmt::Display for DataType {
5157
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5258
match self {
53-
DataType::Int8 => write!(f, "Int8"),
54-
DataType::Int16 => write!(f, "Int16"),
55-
DataType::Int32 => write!(f, "Int32"),
56-
DataType::Int64 => write!(f, "Int64"),
57-
DataType::Float => write!(f, "Float"),
58-
DataType::Double => write!(f, "Double"),
59-
DataType::Bytes => write!(f, "Bytes"),
60-
DataType::String => write!(f, "String"),
59+
DataType::Int8 => f.write_str("Int8"),
60+
DataType::Int16 => f.write_str("Int16"),
61+
DataType::Int32 => f.write_str("Int32"),
62+
DataType::Int64 => f.write_str("Int64"),
63+
DataType::Float => f.write_str("Float"),
64+
DataType::Double => f.write_str("Double"),
65+
DataType::Bytes => f.write_str("Bytes"),
66+
DataType::String => f.write_str("String"),
6167
}
6268
}
6369
}
@@ -66,7 +72,7 @@ impl DataType {
6672
pub fn display_labels(&self, endian: object::Endianness, bytes: &[u8]) -> Vec<String> {
6773
let mut strs = Vec::new();
6874
for (literal, label_override) in self.display_literals(endian, bytes) {
69-
let label = label_override.unwrap_or_else(|| format!("{self}"));
75+
let label = label_override.unwrap_or_else(|| self.to_string());
7076
strs.push(format!("{label}: {literal}"))
7177
}
7278
strs

objdiff-core/src/arch/ppc/flow_analysis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ fn generate_flow_analysis_result(
625625
Some(FlowAnalysisValue::Text(reg_name))
626626
}
627627
Some(RegisterContent::Unknown) | Some(RegisterContent::Variable) => None,
628-
Some(value) => Some(FlowAnalysisValue::Text(format!("{value}"))),
628+
Some(value) => Some(FlowAnalysisValue::Text(value.to_string())),
629629
None => None,
630630
};
631631
if let Some(analysis_value) = analysis_value {

objdiff-core/src/arch/superh/mod.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -214,20 +214,20 @@ mod test {
214214
impl Display for InstructionPart<'_> {
215215
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
216216
match self {
217-
InstructionPart::Basic(s) => write!(f, "{}", s),
218-
InstructionPart::Opcode(s, _o) => write!(f, "{} ", s),
219-
InstructionPart::Arg(arg) => write!(f, "{}", arg),
220-
InstructionPart::Separator => write!(f, ", "),
217+
InstructionPart::Basic(s) => f.write_str(s),
218+
InstructionPart::Opcode(s, _o) => write!(f, "{s} "),
219+
InstructionPart::Arg(arg) => write!(f, "{arg}"),
220+
InstructionPart::Separator => f.write_str(", "),
221221
}
222222
}
223223
}
224224

225225
impl Display for InstructionArg<'_> {
226226
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
227227
match self {
228-
InstructionArg::Value(v) => write!(f, "{}", v),
229-
InstructionArg::BranchDest(v) => write!(f, "{}", v),
230-
InstructionArg::Reloc => write!(f, "reloc"),
228+
InstructionArg::Value(v) => write!(f, "{v}"),
229+
InstructionArg::BranchDest(v) => write!(f, "{v}"),
230+
InstructionArg::Reloc => f.write_str("reloc"),
231231
}
232232
}
233233
}
@@ -264,7 +264,7 @@ mod test {
264264
)
265265
.unwrap();
266266

267-
let joined_str: String = parts.iter().map(|part| format!("{}", part)).collect();
267+
let joined_str: String = parts.iter().map(<_>::to_string).collect();
268268
assert_eq!(joined_str, expected_str.to_string());
269269
}
270270
}
@@ -342,7 +342,7 @@ mod test {
342342
)
343343
.unwrap();
344344

345-
let joined_str: String = parts.iter().map(|part| format!("{}", part)).collect();
345+
let joined_str: String = parts.iter().map(<_>::to_string).collect();
346346
assert_eq!(joined_str, expected_str.to_string());
347347
}
348348
}
@@ -425,7 +425,7 @@ mod test {
425425
)
426426
.unwrap();
427427

428-
let joined_str: String = parts.iter().map(|part| format!("{}", part)).collect();
428+
let joined_str: String = parts.iter().map(<_>::to_string).collect();
429429
assert_eq!(joined_str, expected_str.to_string());
430430
}
431431
}
@@ -462,7 +462,7 @@ mod test {
462462
)
463463
.unwrap();
464464

465-
let joined_str: String = parts.iter().map(|part| format!("{}", part)).collect();
465+
let joined_str: String = parts.iter().map(<_>::to_string).collect();
466466
assert_eq!(joined_str, expected_str.to_string());
467467
}
468468
}
@@ -516,7 +516,7 @@ mod test {
516516
)
517517
.unwrap();
518518

519-
let joined_str: String = parts.iter().map(|part| format!("{}", part)).collect();
519+
let joined_str: String = parts.iter().map(<_>::to_string).collect();
520520
assert_eq!(joined_str, expected_str.to_string());
521521
}
522522
}
@@ -557,7 +557,7 @@ mod test {
557557
)
558558
.unwrap();
559559

560-
let joined_str: String = parts.iter().map(|part| format!("{}", part)).collect();
560+
let joined_str: String = parts.iter().map(<_>::to_string).collect();
561561
assert_eq!(joined_str, expected_str.to_string());
562562
}
563563
}
@@ -601,7 +601,7 @@ mod test {
601601
)
602602
.unwrap();
603603

604-
let joined_str: String = parts.iter().map(|part| format!("{}", part)).collect();
604+
let joined_str: String = parts.iter().map(<_>::to_string).collect();
605605
assert_eq!(joined_str, expected_str.to_string());
606606
}
607607
}
@@ -645,7 +645,7 @@ mod test {
645645
)
646646
.unwrap();
647647

648-
let joined_str: String = parts.iter().map(|part| format!("{}", part)).collect();
648+
let joined_str: String = parts.iter().map(<_>::to_string).collect();
649649
assert_eq!(joined_str, expected_str.to_string());
650650
}
651651
}
@@ -682,7 +682,7 @@ mod test {
682682
)
683683
.unwrap();
684684

685-
let joined_str: String = parts.iter().map(|part| format!("{}", part)).collect();
685+
let joined_str: String = parts.iter().map(<_>::to_string).collect();
686686
assert_eq!(joined_str, expected_str.to_string());
687687
}
688688
}
@@ -716,7 +716,7 @@ mod test {
716716
)
717717
.unwrap();
718718

719-
let joined_str: String = parts.iter().map(|part| format!("{}", part)).collect();
719+
let joined_str: String = parts.iter().map(<_>::to_string).collect();
720720
assert_eq!(joined_str, expected_str.to_string());
721721
}
722722
}
@@ -764,7 +764,7 @@ mod test {
764764
)
765765
.unwrap();
766766

767-
let joined_str: String = parts.iter().map(|part| format!("{}", part)).collect();
767+
let joined_str: String = parts.iter().map(<_>::to_string).collect();
768768
assert_eq!(joined_str, expected_str.to_string());
769769
}
770770
}
@@ -814,7 +814,7 @@ mod test {
814814
)
815815
.unwrap();
816816

817-
let joined_str: String = parts.iter().map(|part| format!("{}", part)).collect();
817+
let joined_str: String = parts.iter().map(<_>::to_string).collect();
818818
assert_eq!(joined_str, expected_str.to_string());
819819
}
820820
}

objdiff-core/src/diff/display.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ pub fn instruction_hover(
609609
out.push(HoverItem::Separator);
610610
for (literal, label_override) in literals {
611611
out.push(HoverItem::Text {
612-
label: label_override.unwrap_or_else(|| format!("{ty}")),
612+
label: label_override.unwrap_or_else(|| ty.to_string()),
613613
value: literal,
614614
color: HoverItemColor::Normal,
615615
});

objdiff-core/tests/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn display_diff(
2020
separator = true;
2121
}
2222
let DiffTextSegment { text, color, pad_to } = segment;
23-
output.push_str(&format!("({:?}, {:?}, {:?})", text, color, pad_to));
23+
output.push_str(&format!("({text:?}, {color:?}, {pad_to:?})"));
2424
Ok(())
2525
})
2626
.unwrap();

objdiff-gui/src/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ impl App {
542542
Ok(()) => state.config_error = None,
543543
Err(e) => {
544544
log::error!("Failed to load project config: {e}");
545-
state.config_error = Some(format!("{e}"));
545+
state.config_error = Some(e.to_string());
546546
}
547547
}
548548
}

objdiff-gui/src/views/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ fn split_obj_config_ui(
808808
for (idx, glob) in state.config.watch_patterns.iter().enumerate() {
809809
ui.horizontal(|ui| {
810810
ui.label(
811-
RichText::new(format!("{glob}"))
811+
RichText::new(glob.to_string())
812812
.color(appearance.text_color)
813813
.family(FontFamily::Monospace),
814814
);

0 commit comments

Comments
 (0)