Skip to content

Commit 3c70e73

Browse files
committed
Minor cleanup of suspicious_else_formatting
1 parent 0e03da2 commit 3c70e73

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

clippy_lints/src/formatting.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,16 @@ fn check_else(cx: &EarlyContext<'_>, expr: &Expr) {
216216
// it’s bad when there is a ‘\n’ after the “else”
217217
if let Some(else_snippet) = snippet_opt(cx, else_span);
218218
if let Some((pre_else, post_else)) = else_snippet.split_once("else");
219-
if let Some(post_else_eol_pos) = post_else.find('\n');
219+
if let Some((_, post_else_post_eol)) = post_else.split_once('\n');
220220

221221
then {
222222
// Allow allman style braces `} \n else \n {`
223223
if_chain! {
224224
if is_block(else_);
225-
if let Some(pre_else_eol_pos) = pre_else.find('\n');
225+
if let Some((_, pre_else_post_eol)) = pre_else.split_once('\n');
226226
// Exactly one eol before and after the else
227-
if !pre_else[pre_else_eol_pos + 1..].contains('\n');
228-
if !post_else[post_else_eol_pos + 1..].contains('\n');
227+
if !pre_else_post_eol.contains('\n');
228+
if !post_else_post_eol.contains('\n');
229229
then {
230230
return;
231231
}

0 commit comments

Comments
 (0)