Skip to content

Commit 4a7314b

Browse files
committed
clean-up a bit
1 parent 44052c4 commit 4a7314b

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

clippy_lints/src/entry.rs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use clippy_utils::{
66
SpanlessEq, can_move_expr_to_closure_no_visit, higher, is_expr_final_block_expr, is_expr_used_or_unified,
77
peel_hir_expr_while,
88
};
9-
use core::fmt::{self, Write};
9+
use core::fmt::Write;
1010
use rustc_errors::Applicability;
1111
use rustc_hir::hir_id::HirIdSet;
1212
use rustc_hir::intravisit::{Visitor, walk_body, walk_expr};
@@ -628,11 +628,8 @@ impl<'tcx> InsertSearchResults<'tcx> {
628628
if is_expr_used_or_unified(cx.tcx, insertion.call) {
629629
write_wrapped(&mut res, insertion, ctxt, app);
630630
} else {
631-
let _: fmt::Result = write!(
632-
res,
633-
"e.insert({})",
634-
snippet_with_context(cx, insertion.value.span, ctxt, "..", app).0
635-
);
631+
let value_str = snippet_with_context(cx, insertion.value.span, ctxt, "..", app).0;
632+
let _ = write!(res, "e.insert({value_str})");
636633
}
637634
span = span.trim_start(insertion.call.span).unwrap_or(DUMMY_SP);
638635
}
@@ -644,11 +641,8 @@ impl<'tcx> InsertSearchResults<'tcx> {
644641
(
645642
self.snippet(cx, span, app, |res, insertion, ctxt, app| {
646643
// Insertion into a map would return `Some(&mut value)`, but the entry returns `&mut value`
647-
let _: fmt::Result = write!(
648-
res,
649-
"Some(e.insert({}))",
650-
snippet_with_context(cx, insertion.value.span, ctxt, "..", app).0
651-
);
644+
let value_str = snippet_with_context(cx, insertion.value.span, ctxt, "..", app).0;
645+
let _ = write!(res, "Some(e.insert({value_str}))");
652646
}),
653647
"Occupied(mut e)",
654648
)
@@ -658,19 +652,15 @@ impl<'tcx> InsertSearchResults<'tcx> {
658652
(
659653
self.snippet(cx, span, app, |res, insertion, ctxt, app| {
660654
// Insertion into a map would return `None`, but the entry returns a mutable reference.
661-
let _: fmt::Result = if is_expr_final_block_expr(cx.tcx, insertion.call) {
655+
let value_str = snippet_with_context(cx, insertion.value.span, ctxt, "..", app).0;
656+
let _ = if is_expr_final_block_expr(cx.tcx, insertion.call) {
662657
write!(
663658
res,
664-
"e.insert({});\n{}None",
665-
snippet_with_context(cx, insertion.value.span, ctxt, "..", app).0,
666-
snippet_indent(cx, insertion.call.span).as_deref().unwrap_or(""),
659+
"e.insert({value_str});\n{indent}None",
660+
indent = snippet_indent(cx, insertion.call.span).as_deref().unwrap_or(""),
667661
)
668662
} else {
669-
write!(
670-
res,
671-
"{{ e.insert({}); None }}",
672-
snippet_with_context(cx, insertion.value.span, ctxt, "..", app).0,
673-
)
663+
write!(res, "{{ e.insert({value_str}); None }}")
674664
};
675665
}),
676666
"Vacant(e)",
@@ -690,7 +680,8 @@ impl<'tcx> InsertSearchResults<'tcx> {
690680
"..",
691681
app,
692682
));
693-
res.push_str(&snippet_with_context(cx, insertion.value.span, ctxt, "..", app).0);
683+
let value_str = snippet_with_context(cx, insertion.value.span, ctxt, "..", app).0;
684+
_ = write!(res, "{value_str}");
694685
span = span.trim_start(insertion.call.span).unwrap_or(DUMMY_SP);
695686
},
696687
Edit::RemoveSemi(semi_span) => {

0 commit comments

Comments
 (0)