diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs index c4857cf58561..3bd6a09d3653 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -216,16 +216,16 @@ fn check_else(cx: &EarlyContext<'_>, expr: &Expr) { // it’s bad when there is a ‘\n’ after the “else” if let Some(else_snippet) = snippet_opt(cx, else_span); if let Some((pre_else, post_else)) = else_snippet.split_once("else"); - if let Some(post_else_eol_pos) = post_else.find('\n'); + if let Some((_, post_else_post_eol)) = post_else.split_once('\n'); then { // Allow allman style braces `} \n else \n {` if_chain! { if is_block(else_); - if let Some(pre_else_eol_pos) = pre_else.find('\n'); + if let Some((_, pre_else_post_eol)) = pre_else.split_once('\n'); // Exactly one eol before and after the else - if !pre_else[pre_else_eol_pos + 1..].contains('\n'); - if !post_else[post_else_eol_pos + 1..].contains('\n'); + if !pre_else_post_eol.contains('\n'); + if !post_else_post_eol.contains('\n'); then { return; }