Skip to content

Commit

Permalink
Minor cleanup of suspicious_else_formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarcho committed Apr 16, 2021
1 parent 0e03da2 commit 3c70e73
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions clippy_lints/src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 3c70e73

Please sign in to comment.