Skip to content

Commit a791205

Browse files
committed
fix clippy warning
1 parent 344888a commit a791205

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clippy_lints/src/rc_clone_in_vec_init.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ fn construct_lint_suggestions(
9292
fn elem_snippet(cx: &LateContext<'_>, elem: &Expr<'_>, symbol_name: &str) -> String {
9393
let elem_snippet = snippet(cx, elem.span, "..").to_string();
9494
if elem_snippet.contains('\n') {
95+
// This string must be found in `elem_snippet`, otherwise we won't be constructing
96+
// the snippet in the first place.
9597
let reference_creation = format!("{symbol_name}::new");
9698
let (code_until_reference_creation, _right) = elem_snippet.split_once(&reference_creation).unwrap();
9799

@@ -132,14 +134,14 @@ fn emit_lint(cx: &LateContext<'_>, symbol: Symbol, lint_span: Span, elem: &Expr<
132134
let suggestions = construct_lint_suggestions(cx, lint_span, symbol_name, elem, len);
133135

134136
diag.note(format!("each element will point to the same `{symbol_name}` instance"));
135-
suggestions.iter().for_each(|suggestion| {
137+
for suggestion in suggestions {
136138
diag.span_suggestion(
137139
lint_span,
138140
&suggestion.message,
139141
&suggestion.snippet,
140142
Applicability::Unspecified,
141143
);
142-
});
144+
}
143145
},
144146
);
145147
}

0 commit comments

Comments
 (0)